"use client" import { useMemo } from "react" import Image from "next/image"; import useLocaleStore from "@/stores/localeStore" import LightconeCard from "../card/lightconeCard"; import useUserDataStore from "@/stores/userDataStore"; import useModelStore from "@/stores/modelStore"; import { useTranslations } from "next-intl"; import useCurrentDataStore from "@/stores/currentDataStore"; import useDetailDataStore from "@/stores/detailDataStore"; import { calcRarity, getLocaleName } from "@/helper"; export default function LightconeBar() { const { locale } = useLocaleStore() const { avatarSelected, mapLightconePathActive, mapLightconeRankActive, setMapLightconePathActive, setMapLightconeRankActive, lightconeSearch, setLightconeSearch } = useCurrentDataStore() const { setAvatar, avatars } = useUserDataStore() const { setIsOpenLightcone } = useModelStore() const { mapLightCone, baseType } = useDetailDataStore() const transI18n = useTranslations("DataPage") const listLightcone = useMemo(() => { if (!mapLightCone || !locale) return [] let list = Object.values(mapLightCone) if (lightconeSearch) { list = list.filter(item => getLocaleName(locale, item.Name).toLowerCase().includes(lightconeSearch.toLowerCase())) } const allRankFalse = !Object.values(mapLightconeRankActive).some(v => v) const allPathFalse = !Object.values(mapLightconePathActive).some(v => v) list = list.filter(item => (allRankFalse || mapLightconeRankActive[item.Rarity]) && (allPathFalse || mapLightconePathActive[item.BaseType]) ) list.sort((a, b) => { const r = calcRarity(b.Rarity) - calcRarity(a.Rarity) if (r !== 0) return r return b.ID - a.ID }) return list }, [mapLightCone, mapLightconePathActive, mapLightconeRankActive, lightconeSearch, locale]) return (

{transI18n("lightConeSetting")}

Search
setLightconeSearch(e.target.value)} type="text" placeholder="LightCone Name" className="input input-accent mt-1 w-full" />
Filter
{Object.entries(baseType).filter(([key]) => key !== "").map(([key, value]) => (
{ setMapLightconePathActive({ ...mapLightconePathActive, [key]: !mapLightconePathActive[key] }) }} className="h-9.5 w-9.5 md:h-12.5 md:w-12.5 hover:bg-gray-600 grid place-items-center rounded-md shadow-lg cursor-pointer" style={{ backgroundColor: mapLightconePathActive[key] ? "#374151" : "#6B7280" }} > {key}
))}
{Object.keys(mapLightconeRankActive).map((key, index) => (
{ setMapLightconeRankActive({ ...mapLightconeRankActive, [key]: !mapLightconeRankActive[key] }) }} className="h-9.5 w-9.5 md:h-12.5 md:w-12.5 hover:bg-gray-600 grid place-items-center rounded-md shadow-lg cursor-pointer" style={{ backgroundColor: mapLightconeRankActive[key] ? "#374151" : "#6B7280" }} >
{key}*
))}
{listLightcone.map((item, index) => (
{ if (avatarSelected) { const avatar = avatars[avatarSelected?.ID?.toString()] avatar.profileList[avatar.profileSelect].lightcone = { level: 80, item_id: item.ID, rank: 1, promotion: 6 } setAvatar({ ...avatar }) setIsOpenLightcone(false) } }}>
))}
) }