import React from 'react' import { useRouter } from 'next/router' import { useTranslation } from 'next-i18next' import Button from '~components/common/Button' import { Hovercard, HovercardContent, HovercardTrigger, } from '~components/common/Hovercard' import HovercardHeader from '~components/HovercardHeader' import { overMastery, aetherialMastery, permanentMastery, } from '~data/overMastery' import { ExtendedMastery } from '~types' import styles from './index.module.scss' interface Props { gridCharacter: GridCharacter children: React.ReactNode onTriggerClick: () => void } const CharacterHovercard = (props: Props) => { const router = useRouter() const { t } = useTranslation('common') const locale = router.locale && ['en', 'ja'].includes(router.locale) ? router.locale : 'en' const tintElement = props.gridCharacter.object.element.slug function goTo() { const urlSafeName = props.gridCharacter.object.name.en.replaceAll(' ', '_') const url = `https://gbf.wiki/${urlSafeName}` window.open(url, '_blank') } function masteryElement(dictionary: ItemSkill[], mastery: ExtendedMastery) { const canonicalMastery = dictionary.find( (item) => item.id === mastery.modifier ) if (canonicalMastery) { return (
  • {canonicalMastery.name[locale]} {canonicalMastery.name[locale]}  {`+${mastery.strength}${canonicalMastery.suffix}`}
  • ) } } const overMasterySection = () => { if (props.gridCharacter && props.gridCharacter.mastery.overMastery) { return (
    {t('modals.characters.subtitles.ring')}
    ) } } const aetherialMasterySection = () => { if ( props.gridCharacter && props.gridCharacter.mastery.aetherialMastery && props.gridCharacter.mastery.aetherialMastery.modifier > 0 ) { return (
    {t('modals.characters.subtitles.earring')}
    ) } } const permanentMasterySection = () => { if (props.gridCharacter && props.gridCharacter.mastery.perpetuity) { return (
    {t('modals.characters.subtitles.permanent')}
    ) } } const awakeningSection = () => { const gridAwakening = props.gridCharacter.mastery.awakening if (gridAwakening) { return (
    {t('modals.characters.subtitles.awakening')}
    {gridAwakening.type.slug !== 'character-balanced' && ( {gridAwakening.type.name[locale]} )} {`${gridAwakening.type.name[locale]}`}  {`Lv${gridAwakening.level}`}
    ) } } const wikiButton = (