Pre-fetch weapon keys on grids
This commit is contained in:
parent
ea02474bd2
commit
802705a812
2 changed files with 19 additions and 3 deletions
|
|
@ -4,17 +4,20 @@ import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
||||||
import Party from '~components/Party'
|
import Party from '~components/Party'
|
||||||
|
|
||||||
import { appState } from '~utils/appState'
|
import { appState } from '~utils/appState'
|
||||||
|
import { groupWeaponKeys } from '~utils/groupWeaponKeys'
|
||||||
import organizeRaids from '~utils/organizeRaids'
|
import organizeRaids from '~utils/organizeRaids'
|
||||||
import setUserToken from '~utils/setUserToken'
|
import setUserToken from '~utils/setUserToken'
|
||||||
import api from '~utils/api'
|
import api from '~utils/api'
|
||||||
|
|
||||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||||
|
import type { GroupedWeaponKeys } from '~utils/groupWeaponKeys'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
jobs: Job[]
|
jobs: Job[]
|
||||||
jobSkills: JobSkill[]
|
jobSkills: JobSkill[]
|
||||||
raids: Raid[]
|
raids: Raid[]
|
||||||
sortedRaids: Raid[][]
|
sortedRaids: Raid[][]
|
||||||
|
weaponKeys: GroupedWeaponKeys
|
||||||
}
|
}
|
||||||
|
|
||||||
const NewRoute: React.FC<Props> = (props: Props) => {
|
const NewRoute: React.FC<Props> = (props: Props) => {
|
||||||
|
|
@ -31,6 +34,7 @@ const NewRoute: React.FC<Props> = (props: Props) => {
|
||||||
appState.raids = props.raids
|
appState.raids = props.raids
|
||||||
appState.jobs = props.jobs
|
appState.jobs = props.jobs
|
||||||
appState.jobSkills = props.jobSkills
|
appState.jobSkills = props.jobSkills
|
||||||
|
appState.weaponKeys = props.weaponKeys
|
||||||
}
|
}
|
||||||
|
|
||||||
return <Party new={true} raids={props.sortedRaids} pushHistory={callback} />
|
return <Party new={true} raids={props.sortedRaids} pushHistory={callback} />
|
||||||
|
|
@ -61,9 +65,11 @@ export const getServerSideProps = async ({ req, res, locale, query }: { req: Nex
|
||||||
return response.data
|
return response.data
|
||||||
})
|
})
|
||||||
|
|
||||||
let jobSkills = await api.allJobSkills().then((response) => {
|
let jobSkills = await api.allJobSkills().then((response) => response.data)
|
||||||
return response.data
|
|
||||||
})
|
let weaponKeys = await api.endpoints.weapon_keys
|
||||||
|
.getAll()
|
||||||
|
.then((response) => groupWeaponKeys(response.data))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
|
|
@ -71,6 +77,7 @@ export const getServerSideProps = async ({ req, res, locale, query }: { req: Nex
|
||||||
jobSkills: jobSkills,
|
jobSkills: jobSkills,
|
||||||
raids: raids,
|
raids: raids,
|
||||||
sortedRaids: sortedRaids,
|
sortedRaids: sortedRaids,
|
||||||
|
weaponKeys: weaponKeys,
|
||||||
...(await serverSideTranslations(locale, ['common'])),
|
...(await serverSideTranslations(locale, ['common'])),
|
||||||
// Will be passed to the page component as props
|
// Will be passed to the page component as props
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,12 @@ import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
||||||
import Party from '~components/Party'
|
import Party from '~components/Party'
|
||||||
|
|
||||||
import { appState } from '~utils/appState'
|
import { appState } from '~utils/appState'
|
||||||
|
import { groupWeaponKeys } from '~utils/groupWeaponKeys'
|
||||||
import organizeRaids from '~utils/organizeRaids'
|
import organizeRaids from '~utils/organizeRaids'
|
||||||
import api from '~utils/api'
|
import api from '~utils/api'
|
||||||
|
|
||||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||||
|
import type { GroupedWeaponKeys } from '~utils/groupWeaponKeys'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
party: Party
|
party: Party
|
||||||
|
|
@ -16,6 +18,7 @@ interface Props {
|
||||||
jobSkills: JobSkill[]
|
jobSkills: JobSkill[]
|
||||||
raids: Raid[]
|
raids: Raid[]
|
||||||
sortedRaids: Raid[][]
|
sortedRaids: Raid[][]
|
||||||
|
weaponKeys: GroupedWeaponKeys
|
||||||
}
|
}
|
||||||
|
|
||||||
const PartyRoute: React.FC<Props> = (props: Props) => {
|
const PartyRoute: React.FC<Props> = (props: Props) => {
|
||||||
|
|
@ -27,6 +30,7 @@ const PartyRoute: React.FC<Props> = (props: Props) => {
|
||||||
appState.raids = props.raids
|
appState.raids = props.raids
|
||||||
appState.jobs = props.jobs
|
appState.jobs = props.jobs
|
||||||
appState.jobSkills = props.jobSkills
|
appState.jobSkills = props.jobSkills
|
||||||
|
appState.weaponKeys = props.weaponKeys
|
||||||
}
|
}
|
||||||
|
|
||||||
return <Party team={props.party} raids={props.sortedRaids} />
|
return <Party team={props.party} raids={props.sortedRaids} />
|
||||||
|
|
@ -65,6 +69,10 @@ export const getServerSideProps = async ({ req, res, locale, query }: { req: Nex
|
||||||
})
|
})
|
||||||
|
|
||||||
let jobSkills = await api.allJobSkills(headers).then((response) => response.data)
|
let jobSkills = await api.allJobSkills(headers).then((response) => response.data)
|
||||||
|
|
||||||
|
let weaponKeys = await api.endpoints.weapon_keys
|
||||||
|
.getAll()
|
||||||
|
.then((response) => groupWeaponKeys(response.data))
|
||||||
|
|
||||||
let party: Party | null = null
|
let party: Party | null = null
|
||||||
if (query.party) {
|
if (query.party) {
|
||||||
|
|
@ -81,6 +89,7 @@ export const getServerSideProps = async ({ req, res, locale, query }: { req: Nex
|
||||||
jobSkills: jobSkills,
|
jobSkills: jobSkills,
|
||||||
raids: raids,
|
raids: raids,
|
||||||
sortedRaids: sortedRaids,
|
sortedRaids: sortedRaids,
|
||||||
|
weaponKeys: weaponKeys,
|
||||||
...(await serverSideTranslations(locale, ["common"])),
|
...(await serverSideTranslations(locale, ["common"])),
|
||||||
// Will be passed to the page component as props
|
// Will be passed to the page component as props
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue