(Hotfix) (Temporary) nuclear option for raid population (#339)

* Another attempt to fix RaidCombobox loading

* Final nuclear option of getting raids to populate

No matter what I do, raids won't populate from state specifically in production. I will have to investigate this more, but for now we are going with the nuclear option of passing raids down from the context object we get from SSR through all components into RaidCombobox
This commit is contained in:
Justin Edmund 2023-07-04 02:20:48 -07:00 committed by GitHub
parent e2effa0d66
commit 702566e2ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 34 additions and 25 deletions

View file

@ -22,6 +22,7 @@ interface Props {
scrolled: boolean scrolled: boolean
element?: number element?: number
raid?: string raid?: string
raidGroups: RaidGroup[]
recency?: number recency?: number
onFilter: (filters: FilterSet) => void onFilter: (filters: FilterSet) => void
onAdvancedFilter: (filters: FilterSet) => void onAdvancedFilter: (filters: FilterSet) => void
@ -147,6 +148,7 @@ const FilterBar = (props: Props) => {
<RaidCombobox <RaidCombobox
currentRaid={currentRaid} currentRaid={currentRaid}
showAllRaidsOption={true} showAllRaidsOption={true}
raidGroups={props.raidGroups}
minimal={true} minimal={true}
size="small" size="small"
onChange={raidSelectChanged} onChange={raidSelectChanged}

View file

@ -33,12 +33,14 @@ import styles from './index.module.scss'
interface Props extends DialogProps { interface Props extends DialogProps {
open: boolean open: boolean
party?: Party party?: Party
raidGroups: RaidGroup[]
onOpenChange?: (open: boolean) => void onOpenChange?: (open: boolean) => void
updateParty: (details: DetailsObject) => Promise<any> updateParty: (details: DetailsObject) => Promise<any>
} }
const EditPartyModal = ({ const EditPartyModal = ({
open, open,
raidGroups,
updateParty, updateParty,
onOpenChange, onOpenChange,
...props ...props
@ -425,6 +427,7 @@ const EditPartyModal = ({
<RaidCombobox <RaidCombobox
showAllRaidsOption={false} showAllRaidsOption={false}
currentRaid={raid} currentRaid={raid}
raidGroups={raidGroups}
onChange={receiveRaid} onChange={receiveRaid}
/> />
) )

View file

@ -28,6 +28,7 @@ interface Props {
new?: boolean new?: boolean
team?: Party team?: Party
selectedTab: GridType selectedTab: GridType
raidGroups: RaidGroup[]
handleTabChanged: (value: string) => void handleTabChanged: (value: string) => void
pushHistory?: (path: string) => void pushHistory?: (path: string) => void
} }
@ -440,6 +441,7 @@ const Party = (props: Props) => {
party={props.team} party={props.team}
new={props.new || false} new={props.new || false}
editable={props.new ? true : party.editable} editable={props.new ? true : party.editable}
raidGroups={props.raidGroups}
deleteCallback={deleteTeam} deleteCallback={deleteTeam}
remixCallback={remixTeam} remixCallback={remixTeam}
updateCallback={updateDetails} updateCallback={updateDetails}
@ -453,6 +455,7 @@ const Party = (props: Props) => {
party={props.team} party={props.team}
new={props.new || false} new={props.new || false}
editable={party.editable} editable={party.editable}
raidGroups={props.raidGroups}
remixCallback={remixTeam} remixCallback={remixTeam}
updateCallback={updateDetails} updateCallback={updateDetails}
/> />

View file

@ -33,6 +33,7 @@ interface Props {
party?: Party party?: Party
new: boolean new: boolean
editable: boolean editable: boolean
raidGroups: RaidGroup[]
remixCallback: () => void remixCallback: () => void
updateCallback: (details: DetailsObject) => Promise<any> updateCallback: (details: DetailsObject) => Promise<any>
} }
@ -225,6 +226,7 @@ const PartyFooter = (props: Props) => {
<EditPartyModal <EditPartyModal
open={detailsOpen} open={detailsOpen}
party={props.party} party={props.party}
raidGroups={props.raidGroups}
onOpenChange={handleDetailsOpenChange} onOpenChange={handleDetailsOpenChange}
updateParty={props.updateCallback} updateParty={props.updateCallback}
> >

View file

@ -33,6 +33,7 @@ interface Props {
party?: Party party?: Party
new: boolean new: boolean
editable: boolean editable: boolean
raidGroups: RaidGroup[]
deleteCallback: () => void deleteCallback: () => void
remixCallback: () => void remixCallback: () => void
updateCallback: (details: DetailsObject) => Promise<any> updateCallback: (details: DetailsObject) => Promise<any>
@ -383,6 +384,7 @@ const PartyHeader = (props: Props) => {
<EditPartyModal <EditPartyModal
open={detailsOpen} open={detailsOpen}
party={props.party} party={props.party}
raidGroups={props.raidGroups}
onOpenChange={handleDetailsOpenChange} onOpenChange={handleDetailsOpenChange}
updateParty={props.updateCallback} updateParty={props.updateCallback}
> >

View file

@ -1,4 +1,4 @@
import { createRef, useCallback, useEffect, useState, useRef } from 'react' import { createRef, useCallback, useEffect, useState } from 'react'
import { useRouter } from 'next/router' import { useRouter } from 'next/router'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import classNames from 'classnames' import classNames from 'classnames'
@ -10,20 +10,6 @@ import Segment from '~components/common/Segment'
import RaidItem from '~components/raids/RaidItem' import RaidItem from '~components/raids/RaidItem'
import Tooltip from '~components/common/Tooltip' import Tooltip from '~components/common/Tooltip'
import api from '~utils/api'
import { appState } from '~utils/appState'
interface Props {
showAllRaidsOption: boolean
currentRaid?: Raid
defaultRaid?: Raid
minimal?: boolean
tabIndex?: number
size?: 'small' | 'medium' | 'large'
onChange?: (raid?: Raid) => void
onBlur?: (event: React.ChangeEvent<HTMLSelectElement>) => void
}
import Button from '~components/common/Button' import Button from '~components/common/Button'
import ArrowIcon from '~public/icons/Arrow.svg' import ArrowIcon from '~public/icons/Arrow.svg'
import CrossIcon from '~public/icons/Cross.svg' import CrossIcon from '~public/icons/Cross.svg'
@ -67,6 +53,18 @@ const allRaidsOption: Raid = {
element: 0, element: 0,
} }
interface Props {
showAllRaidsOption: boolean
currentRaid?: Raid
defaultRaid?: Raid
raidGroups: RaidGroup[]
minimal?: boolean
tabIndex?: number
size?: 'small' | 'medium' | 'large'
onChange?: (raid?: Raid) => void
onBlur?: (event: React.ChangeEvent<HTMLSelectElement>) => void
}
const RaidCombobox = (props: Props) => { const RaidCombobox = (props: Props) => {
// Set up router for locale // Set up router for locale
const router = useRouter() const router = useRouter()
@ -114,12 +112,13 @@ const RaidCombobox = (props: Props) => {
useEffect(() => { useEffect(() => {
const sections: [RaidGroup[], RaidGroup[], RaidGroup[]] = [[], [], []] const sections: [RaidGroup[], RaidGroup[], RaidGroup[]] = [[], [], []]
appState.raidGroups.forEach((group) => {
props.raidGroups.forEach((group) => {
if (group.section > 0) sections[group.section - 1].push(group) if (group.section > 0) sections[group.section - 1].push(group)
}) })
if (appState.raidGroups[0]) { if (props.raidGroups[0]) {
setFarmingRaid(appState.raidGroups[0].raids[0]) setFarmingRaid(props.raidGroups[0].raids[0])
} }
setSections(sections) setSections(sections)
@ -521,13 +520,6 @@ const RaidCombobox = (props: Props) => {
// ---------------------------------------------- // ----------------------------------------------
// Methods: Utility // Methods: Utility
// ---------------------------------------------- // ----------------------------------------------
function slugToRaid(slug: string) {
return appState.raidGroups
.filter((group) => group.section > 0)
.flatMap((group) => group.raids)
.find((raid) => raid.slug === slug)
}
const linkClass = classNames({ const linkClass = classNames({
wind: currentRaid && currentRaid.element == 1, wind: currentRaid && currentRaid.element == 1,
fire: currentRaid && currentRaid.element == 2, fire: currentRaid && currentRaid.element == 2,

View file

@ -278,6 +278,7 @@ const ProfileRoute: React.FC<Props> = ({
scrolled={scrolled} scrolled={scrolled}
element={element} element={element}
raid={raid} raid={raid}
raidGroups={context.raidGroups}
recency={recency} recency={recency}
> >
<UserInfo user={context.user!} /> <UserInfo user={context.user!} />

View file

@ -150,6 +150,7 @@ const NewRoute: React.FC<Props> = ({
new={true} new={true}
pushHistory={callback} pushHistory={callback}
selectedTab={selectedTab} selectedTab={selectedTab}
raidGroups={context.raidGroups}
handleTabChanged={handleTabChange} handleTabChanged={handleTabChange}
/> />
</React.Fragment> </React.Fragment>

View file

@ -128,6 +128,7 @@ const PartyRoute: React.FC<Props> = ({
<Party <Party
team={context.party} team={context.party}
selectedTab={selectedTab} selectedTab={selectedTab}
raidGroups={context.raidGroups}
handleTabChanged={handleTabChange} handleTabChanged={handleTabChange}
/> />
</React.Fragment> </React.Fragment>

View file

@ -318,6 +318,7 @@ const SavedRoute: React.FC<Props> = ({
scrolled={scrolled} scrolled={scrolled}
element={element} element={element}
raid={raid} raid={raid}
raidGroups={context.raidGroups}
recency={recency} recency={recency}
> >
<h1>{t('saved.title')}</h1> <h1>{t('saved.title')}</h1>

View file

@ -329,6 +329,7 @@ const TeamsRoute: React.FC<Props> = ({
scrolled={scrolled} scrolled={scrolled}
element={element} element={element}
raid={raid} raid={raid}
raidGroups={context.raidGroups}
recency={recency} recency={recency}
> >
<h1>{t('teams.title')}</h1> <h1>{t('teams.title')}</h1>