## Summary
- Fixed translation key format compatibility with next-intl
- Fixed pluralization format from i18next to next-intl format
- Fixed dynamic translation key error handling
- Updated server components to match API response structure
- Fixed useSearchParams import location
## Changes
- Changed pluralization from `{{count}} items` to `{count} items` format
- Added proper error handling for missing translation keys
- Fixed import paths for next-intl hooks
- Fixed PartyPageClient trying to set non-existent appState.parties
## Test plan
- [x] Verified translations render correctly
- [x] Tested pluralization works with different counts
- [x] Confirmed no console errors about missing translations
- [x] Tested party page functionality
🤖 Generated with [Claude Code](https://claude.ai/code)
---------
Co-authored-by: Claude <noreply@anthropic.com>
75 lines
1.6 KiB
TypeScript
75 lines
1.6 KiB
TypeScript
'use client'
|
|
import React from 'react'
|
|
import { setCookie } from 'cookies-next'
|
|
import { add, format } from 'date-fns'
|
|
import classNames from 'classnames'
|
|
|
|
import Button from '~components/common/Button'
|
|
import Toast from '~components/common/Toast'
|
|
|
|
import styles from './index.module.scss'
|
|
import { useTranslations } from 'next-intl'
|
|
|
|
interface Props {
|
|
open: boolean
|
|
updateType: string
|
|
lastUpdated: string
|
|
onActionClicked: () => void
|
|
onCloseClicked: () => void
|
|
}
|
|
|
|
const UpdateToast = ({
|
|
open,
|
|
updateType,
|
|
lastUpdated,
|
|
onActionClicked,
|
|
onCloseClicked,
|
|
}: Props) => {
|
|
const t = useTranslations('common')
|
|
|
|
const classes = classNames({
|
|
Update: true,
|
|
})
|
|
|
|
function setToastCookie() {
|
|
const updatedAt = new Date(lastUpdated)
|
|
const expiresAt = add(updatedAt, { days: 7 })
|
|
setCookie(
|
|
`update-${format(updatedAt, 'yyyy-MM-dd')}`,
|
|
{ seen: true },
|
|
{ path: '/', expires: expiresAt }
|
|
)
|
|
}
|
|
|
|
function handleButtonClicked() {
|
|
window.open('/updates', '_blank')
|
|
setToastCookie()
|
|
onActionClicked()
|
|
}
|
|
|
|
function handleCloseClicked() {
|
|
setToastCookie()
|
|
onCloseClicked()
|
|
}
|
|
|
|
return (
|
|
<Toast
|
|
altText={t(`toasts.update.description.${updateType}`)}
|
|
className={classes}
|
|
title={t(`toasts.update.title`)}
|
|
content={t(`toasts.update.description.${updateType}`)}
|
|
open={open}
|
|
type="background"
|
|
onCloseClick={handleCloseClicked}
|
|
>
|
|
<Button
|
|
size="small"
|
|
bound={true}
|
|
onClick={handleButtonClicked}
|
|
text={t('toasts.update.button')}
|
|
/>
|
|
</Toast>
|
|
)
|
|
}
|
|
|
|
export default UpdateToast
|