import React from 'react' import { useTranslation } from 'next-i18next' import ChangelogUnit from '~components/ChangelogUnit' import './index.scss' interface UpdateObject { character?: string[] summon?: string[] weapon?: string[] } interface Props { version: string dateString: string event: string newItems?: UpdateObject uncappedItems?: UpdateObject numNotes: number } const ContentUpdate = ({ version, dateString, event, newItems, uncappedItems, numNotes, }: Props) => { const { t: updates } = useTranslation('updates') const date = new Date(dateString) function newItemElements(key: 'character' | 'weapon' | 'summon') { let elements: React.ReactNode[] = [] if (newItems && newItems[key]) { const items = newItems[key] elements = items ? items.map((id, i) => { return }) : [] } return elements } function newItemSection(key: 'character' | 'weapon' | 'summon') { let section: React.ReactNode = '' if (newItems && newItems[key]) { const items = newItems[key] section = items && items.length > 0 ? (

{updates(`labels.${key}s`)}

{newItemElements(key)}
) : ( '' ) } return section } function uncapItemElements(key: 'character' | 'weapon' | 'summon') { let elements: React.ReactNode[] = [] if (uncappedItems && uncappedItems[key]) { const items = uncappedItems[key] elements = items ? items.map((id) => { return key === 'character' ? ( ) : ( ) }) : [] } return elements } function uncapItemSection(key: 'character' | 'weapon' | 'summon') { let section: React.ReactNode = '' if (uncappedItems && uncappedItems[key]) { const items = uncappedItems[key] section = items && items.length > 0 ? (

{updates(`labels.uncaps.${key}s`)}

{uncapItemElements(key)}
) : ( '' ) } return section } return (

{`${updates('events.date', { year: date.getFullYear(), month: `${date.getMonth() + 1}`.padStart(2, '0'), })} ${updates(event)}`}

{newItemSection('character')} {uncapItemSection('character')} {newItemSection('weapon')} {uncapItemSection('weapon')} {newItemSection('summon')} {uncapItemSection('summon')}
{numNotes > 0 ? (

{updates('labels.updates')}

    {[...Array(numNotes)].map((e, i) => (
  • {updates(`versions.${version}.features.${i}`)}
  • ))}
) : ( '' )}
) } ContentUpdate.defaultProps = { numNotes: 0, } export default ContentUpdate