- Add next-intl routing configuration using defineRouting
- Update navigation and middleware to use new routing config
- Fix all TypeScript errors in components
- Add Node.js 20 configuration for Railway (.nvmrc and .mise.toml)
- Add patch script for next-intl ESM compatibility
- Fix nullable types and missing props across components
- Update package.json engines to specify Node.js 20.x
This fixes the deployment failure on Railway by:
1. Resolving all TypeScript compilation errors
2. Working around Node.js ESM module resolution issues with next-intl
3. Specifying Node.js 20 for consistent builds
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
85 lines
2.1 KiB
TypeScript
85 lines
2.1 KiB
TypeScript
'use client'
|
|
import { PropsWithChildren, useEffect, useState } from 'react'
|
|
import { usePathname } from 'next/navigation'
|
|
import { add, format } from 'date-fns'
|
|
import { getCookie } from 'cookies-next'
|
|
|
|
import { appState } from '~utils/appState'
|
|
|
|
import TopHeader from '~components/Header'
|
|
import UpdateToast from '~components/toasts/UpdateToast'
|
|
|
|
interface Props {}
|
|
|
|
const Layout = ({ children }: PropsWithChildren<Props>) => {
|
|
const pathname = usePathname()
|
|
const [updateToastOpen, setUpdateToastOpen] = useState(false)
|
|
|
|
useEffect(() => {
|
|
if (appState.version) {
|
|
const cookie = getToastCookie()
|
|
const now = new Date()
|
|
const updatedAt = new Date(appState.version.updated_at)
|
|
const validUntil = add(updatedAt, { days: 7 })
|
|
|
|
if (now < validUntil && !cookie.seen) setUpdateToastOpen(true)
|
|
}
|
|
}, [])
|
|
|
|
function getToastCookie() {
|
|
if (appState.version && appState.version.updated_at !== '') {
|
|
const updatedAt = new Date(appState.version.updated_at)
|
|
const cookieValues = getCookie(
|
|
`update-${format(updatedAt, 'yyyy-MM-dd')}`
|
|
)
|
|
return cookieValues
|
|
? (JSON.parse(cookieValues as string) as { seen: true })
|
|
: { seen: false }
|
|
} else {
|
|
return { seen: false }
|
|
}
|
|
}
|
|
|
|
function handleToastActionClicked() {
|
|
setUpdateToastOpen(false)
|
|
}
|
|
|
|
function handleToastClosed() {
|
|
setUpdateToastOpen(false)
|
|
}
|
|
|
|
const updateToast = () => {
|
|
const path = pathname?.replaceAll('/', '') || ''
|
|
|
|
return (
|
|
!['about', 'updates', 'roadmap'].includes(path) &&
|
|
appState.version && (
|
|
<UpdateToast
|
|
open={updateToastOpen}
|
|
updateType={appState.version.update_type}
|
|
onActionClicked={handleToastActionClicked}
|
|
onCloseClicked={handleToastClosed}
|
|
lastUpdated={appState.version.updated_at}
|
|
/>
|
|
)
|
|
)
|
|
}
|
|
|
|
const ServerAvailable = () => {
|
|
return (
|
|
<>
|
|
<TopHeader />
|
|
{updateToast()}
|
|
</>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<>
|
|
{appState.version ? ServerAvailable() : ''}
|
|
<main>{children}</main>
|
|
</>
|
|
)
|
|
}
|
|
|
|
export default Layout
|