import React, { PropsWithChildren, useEffect, useState } from 'react' import { useTranslation } from 'next-i18next' import classNames from 'classnames' import { Popover, PopoverAnchor, PopoverContent, } from '~components/PopoverContent' import TranscendenceStar from '~components/TranscendenceStar' import './index.scss' interface Props extends React.DetailedHTMLProps< React.DialogHTMLAttributes, HTMLDivElement > { open: boolean stage: number onOpenChange?: (open: boolean) => void sendValue?: (stage: number) => void } const TranscendencePopover = ({ children, open: popoverOpen, stage, tabIndex, onOpenChange, sendValue, }: PropsWithChildren) => { const { t } = useTranslation('common') const [open, setOpen] = useState(false) const [currentStage, setCurrentStage] = useState(0) const popoverRef = React.createRef() const classes = classNames({ Transcendence: true, }) const levelClasses = classNames({ Pending: stage != currentStage, }) useEffect(() => { if (open) popoverRef.current?.focus() }, []) useEffect(() => { setCurrentStage(stage) }, [stage]) useEffect(() => { setOpen(popoverOpen) }, [popoverOpen]) function handleFragmentClicked(newStage: number) { setCurrentStage(newStage) if (sendValue) sendValue(newStage) } function handleFragmentHovered(newStage: number) { setCurrentStage(newStage) } return ( {children}

{t('level')}  {200 + 10 * currentStage}

) } export default TranscendencePopover