'use client'; import { useState, useEffect, useMemo } from 'react'; import { useInventoryStore } from '@/store/useInventoryStore'; import styles from '../styles/Home.module.css'; import { isNamedDLC } from '@/lib/utils'; export default function Home() { const store = useInventoryStore(); const [charCount, setCharCount] = useState(0); const [custCount, setCustCount] = useState(0); const [itemsCount, setItemsCount] = useState(0); const [offeringsCount, setOfferingsCount] = useState(0); const [dlcsCount, setDlcsCount] = useState(0); const [importText, setImportText] = useState(''); useEffect(() => { Promise.all([ fetch('/data/characters.json').then(r => r.json()).catch(() => []), fetch('/data/items.json').then(r => r.json()).catch(() => []), fetch('/data/offerings.json').then(r => r.json()).catch(() => []), fetch('/data/customization_items.json').then(r => r.json()).catch(() => []), fetch('/data/dlcs.json').then(r => r.json()).catch(() => []) ]).then(([chars, items, offerings, customizations, dlcs]) => { setCharCount(chars.length); setItemsCount(items.length); setOfferingsCount(offerings.length); setCustCount(customizations.length); setDlcsCount(dlcs.filter(isNamedDLC).length); }); }, []); /* profile handling */ const handleDownload = () => { const blob = new Blob([importText], { type: 'application/json' }); const url = URL.createObjectURL(blob); const link = document.createElement('a'); link.href = url; link.download = 'profile.json'; link.click(); URL.revokeObjectURL(url); }; const handleCopy = () => { navigator.clipboard.writeText(importText); }; const getExportText = () => { return JSON.stringify({ unlockedCharacters: store.unlockedCharacters, unlockedCustomizations: store.unlockedCustomizations, unlockedDLCs: store.unlockedDLCs, items: store.items, offerings: store.offerings }, null, 2); }; const handleImport = async () => { const parsed = JSON.parse(importText); store.importProfile(parsed); }; useEffect(() => { setImportText(getExportText()); }, [store.unlockedCharacters, store.unlockedCustomizations, store.unlockedDLCs, store.items, store.offerings]); /* stats */ const unlockedItems = useMemo(() => Object.values(store.items).filter(qty => qty > 0).length, [store.items]); const unlockedOfferings = useMemo(() => Object.values(store.offerings).filter(qty => qty > 0).length, [store.offerings]); return (

Dashboard

Status overview and profile management

{/* stats cards */}
Characters
{store.unlockedCharacters.length} / {charCount || '-'}
Customizations
{store.unlockedCustomizations.length} / {custCount || '-'}
DLCs
{store.unlockedDLCs.length} / {dlcsCount || '-'}
Items
{unlockedItems} / {itemsCount || '-'}
Offerings
{unlockedOfferings} / {offeringsCount || '-'}
{/* profile import export stuff */}

Profile Import / Export