import { useEffect, useState, useRef, useMemo } from 'react'
import { usePicked, useEnd, useProfile } from '@remake/hooks'
import { useEndJudge } from '@/hooks/judge'
import { properties, judgeDisplay } from '@/display'
import { isDev } from '@/config'
import TalentComponent from '@/components/Talent'
import './Summary.css'
function Judges() {
const judges = useEndJudge()
return (
{judges.map(([key, { value, grade, level }]) => (
-
{properties[key]}
{value}
{judgeDisplay(key, level)}
))}
)
}
interface TalentListProps {
picked: Set
picker: (id: number) => void
}
function TalentList({ picked, picker }: TalentListProps) {
const [profile] = useProfile()
const items = usePicked()
const talents = useMemo(() => {
if (!isDev || !profile.locked) return items
return new Set([...items, ...profile.locked])
}, [])
const hasInitialized = useRef(false)
useEffect(() => {
if (!profile.locked) return
if (!hasInitialized.current) {
for (const id of profile.locked) {
if (talents.has(id) && !picked.has(id)) {
picker(id)
}
}
hasInitialized.current = true
}
}, [picked, picker])
return (
{Array.from(talents, id => (
- picker(id)}>
))}
)
}
export default function Summary() {
const [locked, picker, end] = useEnd()
const handleEnd = () => {
const achievements = end()
// TODO: Show achievements
console.log('Achievements', achievements)
}
return (
)
}