- Fixed nullable searchParams with optional chaining and fallbacks - Fixed recency type handling (string from URL, number internally) - Removed duplicate Party/User interface definitions, use global types - Fixed error handling in API routes with proper type checking - Fixed props access in UI components (placeholder, content types) - Added missing required props to components - Fixed type mismatches with next-intl rich text interpolation
92 lines
2.1 KiB
TypeScript
92 lines
2.1 KiB
TypeScript
'use client'
|
|
|
|
import React, { useEffect, useState } from 'react'
|
|
import { useTranslations } from 'next-intl'
|
|
import { useRouter } from '~/i18n/navigation'
|
|
|
|
// Utils
|
|
import { appState } from '~/utils/appState'
|
|
import { GridType } from '~/utils/enums'
|
|
|
|
// Components
|
|
import Party from '~/components/party/Party'
|
|
import PartyFooter from '~/components/party/PartyFooter'
|
|
import ErrorSection from '~/components/ErrorSection'
|
|
|
|
interface Props {
|
|
party: any; // Replace with proper Party type
|
|
raidGroups: any[]; // Replace with proper RaidGroup type
|
|
}
|
|
|
|
const PartyPageClient: React.FC<Props> = ({ party, raidGroups }) => {
|
|
const router = useRouter()
|
|
const t = useTranslations('common')
|
|
|
|
// State for tab management
|
|
const [selectedTab, setSelectedTab] = useState<GridType>(GridType.Weapon)
|
|
|
|
// Initialize raid groups
|
|
useEffect(() => {
|
|
if (raidGroups) {
|
|
appState.raidGroups = raidGroups
|
|
}
|
|
}, [raidGroups])
|
|
|
|
// Handle tab change
|
|
const handleTabChanged = (value: string) => {
|
|
let tabType: GridType
|
|
switch (value) {
|
|
case 'characters':
|
|
tabType = GridType.Character
|
|
break
|
|
case 'summons':
|
|
tabType = GridType.Summon
|
|
break
|
|
case 'weapons':
|
|
default:
|
|
tabType = GridType.Weapon
|
|
break
|
|
}
|
|
setSelectedTab(tabType)
|
|
}
|
|
|
|
// Navigation helper (not used for existing parties but required by interface)
|
|
const pushHistory = (path: string) => {
|
|
router.push(path)
|
|
}
|
|
|
|
|
|
// Error case
|
|
if (!party) {
|
|
return (
|
|
<ErrorSection
|
|
status={{
|
|
code: 404,
|
|
text: 'not_found'
|
|
}}
|
|
/>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<Party
|
|
team={party}
|
|
selectedTab={selectedTab}
|
|
raidGroups={raidGroups}
|
|
handleTabChanged={handleTabChanged}
|
|
pushHistory={pushHistory}
|
|
/>
|
|
<PartyFooter
|
|
party={party}
|
|
new={false}
|
|
editable={false}
|
|
raidGroups={raidGroups}
|
|
remixCallback={() => {}}
|
|
updateCallback={async () => ({})}
|
|
/>
|
|
</>
|
|
)
|
|
}
|
|
|
|
export default PartyPageClient
|