import React, { useEffect, useState } from 'react' import { useRouter } from 'next/router' import { useTranslation } from 'next-i18next' import classNames from 'classnames' import * as ElementTransformer from '~transformers/ElementTransformer' import * as ToggleGroup from '@radix-ui/react-toggle-group' import styles from './index.module.scss' interface Props { currentElement: GranblueElement sendValue: (value: GranblueElement) => void } const ElementToggle = ({ currentElement, sendValue, ...props }: Props) => { // Router and localization const router = useRouter() const locale = router.locale && ['en', 'ja'].includes(router.locale) ? router.locale : 'en' const { t } = useTranslation('common') // State: Component const [element, setElement] = useState(currentElement) // Methods: Handlers const handleElementChange = (value: string) => { const newElement = ElementTransformer.toObject(parseInt(value)) setElement(newElement) sendValue(newElement) } // Methods: Rendering return ( {t('elements.null')} {t('elements.wind')} {t('elements.fire')} {t('elements.water')} {t('elements.earth')} {t('elements.dark')} {t('elements.light')} ) } export default ElementToggle