fix bug fetch data
All checks were successful
Gitea Auto Deploy / Deploy-Container (push) Successful in 1m35s
All checks were successful
Gitea Auto Deploy / Deploy-Container (push) Successful in 1m35s
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -10,6 +10,8 @@ import { ToastContainer } from 'react-toastify';
|
||||
import AvatarBar from "@/components/avatarBar";
|
||||
import ActionBar from "@/components/actionBar";
|
||||
import QueryProviderWrapper from "@/components/queryProvider";
|
||||
import ClientDataFetcher from "@/components/clientDataFetcher";
|
||||
|
||||
|
||||
const geistSans = Geist({
|
||||
variable: "--font-geist-sans",
|
||||
@@ -60,6 +62,7 @@ export default async function RootLayout({
|
||||
}>) {
|
||||
const messages = await getMessages();
|
||||
const locale = await getLocale()
|
||||
|
||||
return (
|
||||
<html lang={locale} suppressHydrationWarning>
|
||||
<body
|
||||
@@ -70,6 +73,7 @@ export default async function RootLayout({
|
||||
<QueryProviderWrapper>
|
||||
<ThemeProvider>
|
||||
<ClientThemeWrapper>
|
||||
<ClientDataFetcher />
|
||||
<div className="min-h-screen w-full">
|
||||
<Header />
|
||||
<div className="grid grid-cols-12 w-full">
|
||||
|
||||
@@ -5,17 +5,6 @@ import CharacterCard from "../card/characterCard"
|
||||
import useLocaleStore from "@/stores/localeStore"
|
||||
import useAvatarStore from "@/stores/avatarStore"
|
||||
import { useTranslations } from "next-intl"
|
||||
import {
|
||||
useFetchASData,
|
||||
useFetchAvatarData,
|
||||
useFetchConfigData,
|
||||
useFetchLightconeData,
|
||||
useFetchMOCData,
|
||||
useFetchMonsterData,
|
||||
useFetchPEAKData,
|
||||
useFetchPFData,
|
||||
useFetchRelicData
|
||||
} from "@/hooks"
|
||||
|
||||
|
||||
export default function AvatarBar() {
|
||||
@@ -25,15 +14,7 @@ export default function AvatarBar() {
|
||||
const transI18n = useTranslations("DataPage")
|
||||
const { locale } = useLocaleStore()
|
||||
|
||||
useFetchConfigData()
|
||||
useFetchAvatarData()
|
||||
useFetchLightconeData()
|
||||
useFetchRelicData()
|
||||
useFetchMonsterData()
|
||||
useFetchPFData()
|
||||
useFetchMOCData()
|
||||
useFetchASData()
|
||||
useFetchPEAKData()
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
setFilter({ ...filter, locale: locale, element: Object.keys(listElement).filter((key) => listElement[key]), path: Object.keys(listPath).filter((key) => listPath[key]) })
|
||||
|
||||
27
src/components/clientDataFetcher/index.tsx
Normal file
27
src/components/clientDataFetcher/index.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
useFetchASData,
|
||||
useFetchAvatarData,
|
||||
useFetchConfigData,
|
||||
useFetchLightconeData,
|
||||
useFetchMOCData,
|
||||
useFetchMonsterData,
|
||||
useFetchPEAKData,
|
||||
useFetchPFData,
|
||||
useFetchRelicData
|
||||
} from "@/hooks";
|
||||
|
||||
export default function ClientDataFetcher() {
|
||||
useFetchConfigData();
|
||||
useFetchAvatarData();
|
||||
useFetchLightconeData();
|
||||
useFetchRelicData();
|
||||
useFetchMonsterData();
|
||||
useFetchPFData();
|
||||
useFetchMOCData();
|
||||
useFetchASData();
|
||||
useFetchPEAKData();
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import { MonsterStore } from "@/types";
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
import useMazeStore from "@/stores/mazeStore";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { listCurrentLanguageApi } from "@/constant/constant";
|
||||
|
||||
export default function AsBar() {
|
||||
const { ASEvent, mapASInfo } = useEventStore()
|
||||
@@ -53,84 +54,88 @@ export default function AsBar() {
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
const challenge = mapASInfo[as_config.event_id.toString()]?.Level.find((as) => as.Id === as_config.challenge_id)
|
||||
if (as_config.event_id !== 0 && as_config.challenge_id !== 0 && challenge) {
|
||||
const newBattleConfig = cloneDeep(as_config)
|
||||
newBattleConfig.cycle_count = 0
|
||||
if (!challengeSelected || as_config.event_id === 0 || as_config.challenge_id === 0) return
|
||||
const newBattleConfig = cloneDeep(as_config)
|
||||
newBattleConfig.cycle_count = 0
|
||||
|
||||
newBattleConfig.blessings = []
|
||||
if (as_config.buff_id !== 0) {
|
||||
newBattleConfig.blessings.push({
|
||||
id: as_config.buff_id,
|
||||
level: 1
|
||||
})
|
||||
}
|
||||
if (AS[as_config.challenge_id.toString()]) {
|
||||
newBattleConfig.blessings.push({
|
||||
id: Number(AS[as_config.challenge_id.toString()].maze_buff),
|
||||
level: 1
|
||||
})
|
||||
}
|
||||
|
||||
newBattleConfig.monsters = []
|
||||
newBattleConfig.stage_id = 0
|
||||
if ((as_config.floor_side === "Upper" || as_config.floor_side === "Upper -> Lower") && challenge.EventIDList1.length > 0) {
|
||||
newBattleConfig.stage_id = challenge.EventIDList1[0].StageID
|
||||
for (const wave of challenge.EventIDList1[0].MonsterList) {
|
||||
const newWave: MonsterStore[] = []
|
||||
for (const value of Object.values(wave)) {
|
||||
newWave.push({
|
||||
monster_id: Number(value),
|
||||
level: challenge.EventIDList1[0].Level,
|
||||
amount: 1,
|
||||
})
|
||||
}
|
||||
newBattleConfig.monsters.push(newWave)
|
||||
}
|
||||
}
|
||||
if ((as_config.floor_side === "Lower" || as_config.floor_side === "Lower -> Upper") && challenge.EventIDList2.length > 0) {
|
||||
newBattleConfig.stage_id = challenge.EventIDList2[0].StageID
|
||||
for (const wave of challenge.EventIDList2[0].MonsterList) {
|
||||
const newWave: MonsterStore[] = []
|
||||
for (const value of Object.values(wave)) {
|
||||
newWave.push({
|
||||
monster_id: Number(value),
|
||||
level: challenge.EventIDList2[0].Level,
|
||||
amount: 1,
|
||||
})
|
||||
}
|
||||
newBattleConfig.monsters.push(newWave)
|
||||
}
|
||||
}
|
||||
if (as_config.floor_side === "Lower -> Upper" && challenge.EventIDList1.length > 0) {
|
||||
for (const wave of challenge.EventIDList1[0].MonsterList) {
|
||||
const newWave: MonsterStore[] = []
|
||||
for (const value of Object.values(wave)) {
|
||||
newWave.push({
|
||||
monster_id: Number(value),
|
||||
level: challenge.EventIDList1[0].Level,
|
||||
amount: 1,
|
||||
})
|
||||
}
|
||||
newBattleConfig.monsters.push(newWave)
|
||||
}
|
||||
} else if (as_config.floor_side === "Upper -> Lower" && challenge.EventIDList2.length > 0) {
|
||||
for (const wave of challenge.EventIDList2[0].MonsterList) {
|
||||
const newWave: MonsterStore[] = []
|
||||
for (const value of Object.values(wave)) {
|
||||
newWave.push({
|
||||
monster_id: Number(value),
|
||||
level: challenge.EventIDList2[0].Level,
|
||||
amount: 1,
|
||||
})
|
||||
}
|
||||
newBattleConfig.monsters.push(newWave)
|
||||
}
|
||||
}
|
||||
setAsConfig(newBattleConfig)
|
||||
newBattleConfig.blessings = []
|
||||
if (as_config.buff_id !== 0) {
|
||||
newBattleConfig.blessings.push({
|
||||
id: as_config.buff_id,
|
||||
level: 1
|
||||
})
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
if (AS[as_config.challenge_id.toString()]) {
|
||||
newBattleConfig.blessings.push({
|
||||
id: Number(AS[as_config.challenge_id.toString()].maze_buff),
|
||||
level: 1
|
||||
})
|
||||
}
|
||||
|
||||
newBattleConfig.monsters = []
|
||||
newBattleConfig.stage_id = 0
|
||||
if ((as_config.floor_side === "Upper" || as_config.floor_side === "Upper -> Lower")
|
||||
&& challengeSelected.EventIDList1.length > 0) {
|
||||
newBattleConfig.stage_id = challengeSelected.EventIDList1[0].StageID
|
||||
for (const wave of challengeSelected.EventIDList1[0].MonsterList) {
|
||||
const newWave: MonsterStore[] = []
|
||||
for (const value of Object.values(wave)) {
|
||||
newWave.push({
|
||||
monster_id: Number(value),
|
||||
level: challengeSelected.EventIDList1[0].Level,
|
||||
amount: 1,
|
||||
})
|
||||
}
|
||||
newBattleConfig.monsters.push(newWave)
|
||||
}
|
||||
}
|
||||
if ((as_config.floor_side === "Lower" || as_config.floor_side === "Lower -> Upper")
|
||||
&& challengeSelected.EventIDList2.length > 0) {
|
||||
newBattleConfig.stage_id = challengeSelected.EventIDList2[0].StageID
|
||||
for (const wave of challengeSelected.EventIDList2[0].MonsterList) {
|
||||
const newWave: MonsterStore[] = []
|
||||
for (const value of Object.values(wave)) {
|
||||
newWave.push({
|
||||
monster_id: Number(value),
|
||||
level: challengeSelected.EventIDList2[0].Level,
|
||||
amount: 1,
|
||||
})
|
||||
}
|
||||
newBattleConfig.monsters.push(newWave)
|
||||
}
|
||||
}
|
||||
if (as_config.floor_side === "Lower -> Upper"
|
||||
&& challengeSelected.EventIDList1.length > 0) {
|
||||
for (const wave of challengeSelected.EventIDList1[0].MonsterList) {
|
||||
const newWave: MonsterStore[] = []
|
||||
for (const value of Object.values(wave)) {
|
||||
newWave.push({
|
||||
monster_id: Number(value),
|
||||
level: challengeSelected.EventIDList1[0].Level,
|
||||
amount: 1,
|
||||
})
|
||||
}
|
||||
newBattleConfig.monsters.push(newWave)
|
||||
}
|
||||
} else if (as_config.floor_side === "Upper -> Lower"
|
||||
&& challengeSelected.EventIDList2.length > 0) {
|
||||
for (const wave of challengeSelected.EventIDList2[0].MonsterList) {
|
||||
const newWave: MonsterStore[] = []
|
||||
for (const value of Object.values(wave)) {
|
||||
newWave.push({
|
||||
monster_id: Number(value),
|
||||
level: challengeSelected.EventIDList2[0].Level,
|
||||
amount: 1,
|
||||
})
|
||||
}
|
||||
newBattleConfig.monsters.push(newWave)
|
||||
}
|
||||
}
|
||||
setAsConfig(newBattleConfig)
|
||||
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [
|
||||
challengeSelected,
|
||||
as_config.event_id,
|
||||
as_config.challenge_id,
|
||||
as_config.floor_side,
|
||||
@@ -139,7 +144,7 @@ export default function AsBar() {
|
||||
AS,
|
||||
])
|
||||
|
||||
|
||||
if (!ASEvent) return null
|
||||
return (
|
||||
<div className="container mx-auto px-4 py-8 relative">
|
||||
|
||||
@@ -147,7 +152,7 @@ export default function AsBar() {
|
||||
<div className="rounded-xl p-4 mb-2 border border-warning">
|
||||
<div className="mb-4 w-full">
|
||||
<SelectCustomText
|
||||
customSet={ASEvent.filter(as => as.lang.get(locale)).map((as) => ({
|
||||
customSet={ASEvent.filter(as => as.lang.get(listCurrentLanguageApi[locale])).map((as) => ({
|
||||
id: as.id,
|
||||
name: getLocaleName(locale, as),
|
||||
time: `${as.begin} - ${as.end}`,
|
||||
|
||||
@@ -111,7 +111,7 @@ export default function MocBar() {
|
||||
moc_config.use_cycle_count,
|
||||
moc_config.use_turbulence_buff,
|
||||
])
|
||||
|
||||
if (!MOCEvent) return null
|
||||
return (
|
||||
<div className="container mx-auto px-4 py-8 relative">
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import useUserDataStore from "@/stores/userDataStore";
|
||||
import useMonsterStore from "@/stores/monsterStore";
|
||||
import Image from "next/image";
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
|
||||
import { useTranslations } from "next-intl";
|
||||
import { MonsterStore } from "@/types";
|
||||
|
||||
@@ -99,6 +98,7 @@ export default function PeakBar() {
|
||||
mapPEAKInfo,
|
||||
])
|
||||
|
||||
if (!PEAKEvent) return null
|
||||
|
||||
return (
|
||||
<div className="container mx-auto px-4 py-8 relative">
|
||||
@@ -106,8 +106,11 @@ export default function PeakBar() {
|
||||
{/* Title Card */}
|
||||
<div className="rounded-xl p-4 mb-2 border border-warning">
|
||||
<div className="mb-4 w-full">
|
||||
{PEAKEvent.map((peak) => (
|
||||
<div key={peak.id}>{peak.id}</div>
|
||||
))}
|
||||
<SelectCustomText
|
||||
customSet={PEAKEvent.filter(peak => peak.lang.get(locale)).map((peak) => ({
|
||||
customSet={PEAKEvent.map((peak) => ({
|
||||
id: peak.id,
|
||||
name: `${getLocaleName(locale, peak)} (${peak.id}) `,
|
||||
}))}
|
||||
|
||||
@@ -32,83 +32,84 @@ export default function PfBar() {
|
||||
}, [pf_config, mapPFInfo])
|
||||
|
||||
useEffect(() => {
|
||||
const challenge = mapPFInfo[pf_config.event_id.toString()]?.Level.find((pf) => pf.Id === pf_config.challenge_id)
|
||||
if (pf_config.event_id !== 0 && pf_config.challenge_id !== 0 && challenge) {
|
||||
const newBattleConfig = cloneDeep(pf_config)
|
||||
newBattleConfig.cycle_count = 4
|
||||
newBattleConfig.blessings = []
|
||||
if (pf_config.buff_id !== 0) {
|
||||
newBattleConfig.blessings.push({
|
||||
id: pf_config.buff_id,
|
||||
level: 1
|
||||
})
|
||||
}
|
||||
if (PF[pf_config.challenge_id.toString()]) {
|
||||
newBattleConfig.blessings.push({
|
||||
id: Number(PF[pf_config.challenge_id.toString()].maze_buff),
|
||||
level: 1
|
||||
})
|
||||
}
|
||||
|
||||
newBattleConfig.monsters = []
|
||||
newBattleConfig.stage_id = 0
|
||||
if ((pf_config.floor_side === "Upper" || pf_config.floor_side === "Upper -> Lower" ) && challenge.EventIDList1.length > 0 ) {
|
||||
newBattleConfig.stage_id = challenge.EventIDList1[0].StageID
|
||||
for (const wave of challenge.EventIDList1[0].MonsterList) {
|
||||
const newWave: MonsterStore[] = []
|
||||
for (const value of Object.values(wave)) {
|
||||
newWave.push({
|
||||
monster_id: Number(value),
|
||||
level: challenge.EventIDList1[0].Level,
|
||||
amount: 1,
|
||||
})
|
||||
}
|
||||
newBattleConfig.monsters.push(newWave)
|
||||
}
|
||||
}
|
||||
if ((pf_config.floor_side === "Lower" || pf_config.floor_side === "Lower -> Upper") && challenge.EventIDList2.length > 0) {
|
||||
newBattleConfig.stage_id = challenge.EventIDList2[0].StageID
|
||||
for (const wave of challenge.EventIDList2[0].MonsterList) {
|
||||
const newWave: MonsterStore[] = []
|
||||
for (const value of Object.values(wave)) {
|
||||
newWave.push({
|
||||
monster_id: Number(value),
|
||||
level: challenge.EventIDList2[0].Level,
|
||||
amount: 1,
|
||||
})
|
||||
}
|
||||
newBattleConfig.monsters.push(newWave)
|
||||
}
|
||||
}
|
||||
if (pf_config.floor_side === "Lower -> Upper" && challenge.EventIDList1.length > 0) {
|
||||
for (const wave of challenge.EventIDList1[0].MonsterList) {
|
||||
const newWave: MonsterStore[] = []
|
||||
for (const value of Object.values(wave)) {
|
||||
newWave.push({
|
||||
monster_id: Number(value),
|
||||
level: challenge.EventIDList1[0].Level,
|
||||
amount: 1,
|
||||
})
|
||||
}
|
||||
newBattleConfig.monsters.push(newWave)
|
||||
}
|
||||
} else if (pf_config.floor_side === "Upper -> Lower" && challenge.EventIDList2.length > 0) {
|
||||
for (const wave of challenge.EventIDList2[0].MonsterList) {
|
||||
const newWave: MonsterStore[] = []
|
||||
for (const value of Object.values(wave)) {
|
||||
newWave.push({
|
||||
monster_id: Number(value),
|
||||
level: challenge.EventIDList2[0].Level,
|
||||
amount: 1,
|
||||
})
|
||||
}
|
||||
newBattleConfig.monsters.push(newWave)
|
||||
}
|
||||
}
|
||||
setPfConfig(newBattleConfig)
|
||||
if (!challengeSelected || pf_config.event_id === 0 || pf_config.challenge_id === 0) {
|
||||
return
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
const newBattleConfig = cloneDeep(pf_config)
|
||||
newBattleConfig.cycle_count = 4
|
||||
newBattleConfig.blessings = []
|
||||
if (pf_config.buff_id !== 0) {
|
||||
newBattleConfig.blessings.push({
|
||||
id: pf_config.buff_id,
|
||||
level: 1
|
||||
})
|
||||
}
|
||||
if (PF[pf_config.challenge_id.toString()]) {
|
||||
newBattleConfig.blessings.push({
|
||||
id: Number(PF[pf_config.challenge_id.toString()].maze_buff),
|
||||
level: 1
|
||||
})
|
||||
}
|
||||
|
||||
newBattleConfig.monsters = []
|
||||
newBattleConfig.stage_id = 0
|
||||
if ((pf_config.floor_side === "Upper" || pf_config.floor_side === "Upper -> Lower") && challengeSelected.EventIDList1.length > 0) {
|
||||
newBattleConfig.stage_id = challengeSelected.EventIDList1[0].StageID
|
||||
for (const wave of challengeSelected.EventIDList1[0].MonsterList) {
|
||||
const newWave: MonsterStore[] = []
|
||||
for (const value of Object.values(wave)) {
|
||||
newWave.push({
|
||||
monster_id: Number(value),
|
||||
level: challengeSelected.EventIDList1[0].Level,
|
||||
amount: 1,
|
||||
})
|
||||
}
|
||||
newBattleConfig.monsters.push(newWave)
|
||||
}
|
||||
}
|
||||
if ((pf_config.floor_side === "Lower" || pf_config.floor_side === "Lower -> Upper") && challengeSelected.EventIDList2.length > 0) {
|
||||
newBattleConfig.stage_id = challengeSelected.EventIDList2[0].StageID
|
||||
for (const wave of challengeSelected.EventIDList2[0].MonsterList) {
|
||||
const newWave: MonsterStore[] = []
|
||||
for (const value of Object.values(wave)) {
|
||||
newWave.push({
|
||||
monster_id: Number(value),
|
||||
level: challengeSelected.EventIDList2[0].Level,
|
||||
amount: 1,
|
||||
})
|
||||
}
|
||||
newBattleConfig.monsters.push(newWave)
|
||||
}
|
||||
}
|
||||
if (pf_config.floor_side === "Lower -> Upper" && challengeSelected.EventIDList1.length > 0) {
|
||||
for (const wave of challengeSelected.EventIDList1[0].MonsterList) {
|
||||
const newWave: MonsterStore[] = []
|
||||
for (const value of Object.values(wave)) {
|
||||
newWave.push({
|
||||
monster_id: Number(value),
|
||||
level: challengeSelected.EventIDList1[0].Level,
|
||||
amount: 1,
|
||||
})
|
||||
}
|
||||
newBattleConfig.monsters.push(newWave)
|
||||
}
|
||||
} else if (pf_config.floor_side === "Upper -> Lower" && challengeSelected.EventIDList2.length > 0) {
|
||||
for (const wave of challengeSelected.EventIDList2[0].MonsterList) {
|
||||
const newWave: MonsterStore[] = []
|
||||
for (const value of Object.values(wave)) {
|
||||
newWave.push({
|
||||
monster_id: Number(value),
|
||||
level: challengeSelected.EventIDList2[0].Level,
|
||||
amount: 1,
|
||||
})
|
||||
}
|
||||
newBattleConfig.monsters.push(newWave)
|
||||
}
|
||||
}
|
||||
setPfConfig(newBattleConfig)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [
|
||||
challengeSelected,
|
||||
pf_config.event_id,
|
||||
pf_config.challenge_id,
|
||||
pf_config.floor_side,
|
||||
@@ -116,7 +117,7 @@ export default function PfBar() {
|
||||
mapPFInfo,
|
||||
PF,
|
||||
])
|
||||
|
||||
if (!PFEvent) return null
|
||||
|
||||
return (
|
||||
<div className="container mx-auto px-4 py-8 relative">
|
||||
|
||||
Reference in New Issue
Block a user