/* eslint-disable react-hooks/exhaustive-deps */ "use client" import useUserDataStore from "@/stores/userDataStore"; import { useEffect, useMemo } from "react"; import LightconeBar from '../lightconeBar' import { calcPromotion, calcRarity, replaceByParam } from '@/helper'; import { getSkillTree } from '@/helper/getSkillTree'; import { useTranslations } from 'next-intl'; import ParseText from '../parseText'; import useLocaleStore from '@/stores/localeStore'; import useModelStore from '@/stores/modelStore'; import Image from 'next/image'; import useCurrentDataStore from "@/stores/currentDataStore"; import useDetailDataStore from "@/stores/detailDataStore"; import { getLocaleName } from "@/helper/getName"; import { useShallow } from "zustand/react/shallow"; export default function AvatarInfo() { const { avatarSelected, setResetDataLightcone } = useCurrentDataStore( useShallow((state) => ({ avatarSelected: state.avatarSelected, setResetDataLightcone: state.setResetDataLightcone, })) ) const { avatars, setAvatars, setAvatar } = useUserDataStore( useShallow((state) => ({ avatars: state.avatars, setAvatars: state.setAvatars, setAvatar: state.setAvatar, })) ) const { isOpenLightcone, setIsOpenLightcone } = useModelStore( useShallow((state) => ({ isOpenLightcone: state.isOpenLightcone, setIsOpenLightcone: state.setIsOpenLightcone, })) ) const { mapLightCone, baseType } = useDetailDataStore( useShallow((state) => ({ mapLightCone: state.mapLightCone, baseType: state.baseType, })) ) const transI18n = useTranslations("DataPage") const { locale } = useLocaleStore( useShallow((state) => ({ locale: state.locale })) ); const lightcone = useMemo(() => { if (!avatarSelected) return null; const avatar = avatars[avatarSelected.ID]; return avatar?.profileList?.[avatar?.profileSelect]?.lightcone ?? avatar?.profileList?.[0]?.lightcone ?? null; }, [avatarSelected, avatars]); const handleUpdateLightcone = (updater: (lc: typeof lightcone) => typeof lightcone) => { if (!avatarSelected || !avatars[avatarSelected.ID]) return; const avatar = avatars[avatarSelected.ID]; const profileIndex = avatar.profileSelect; const currentProfile = avatar.profileList?.[profileIndex]; if (!currentProfile) return; const newProfileList = [...avatar.profileList]; newProfileList[profileIndex] = { ...currentProfile, lightcone: updater(currentProfile.lightcone), }; setAvatar({ ...avatar, profileList: newProfileList, }); }; const lightconeDetail = useMemo(() => { if (!mapLightCone || !lightcone?.item_id) return null; return mapLightCone?.[lightcone.item_id.toString()] || null; }, [lightcone, mapLightCone]); const handleShow = (modalId: string) => { const modal = document.getElementById(modalId) as HTMLDialogElement | null; if (modal) { setIsOpenLightcone(true); modal.showModal(); } }; // Close modal handler const handleCloseModal = (modalId: string) => { setIsOpenLightcone(false); const modal = document.getElementById(modalId) as HTMLDialogElement | null; if (modal) { modal.close(); } }; // Handle ESC key to close modal useEffect(() => { if (!isOpenLightcone) { handleCloseModal("action_detail_modal"); return; } const handleEscKey = (event: KeyboardEvent) => { if (event.key === 'Escape' && isOpenLightcone) { handleCloseModal("action_detail_modal"); } }; window.addEventListener('keydown', handleEscKey); return () => window.removeEventListener('keydown', handleEscKey); }, [isOpenLightcone]); return (
{transI18n("techniqueNote")}
{transI18n("enhancedNote")}
{transI18n("equipLightconeNote")}