/
opt
/
canhelp
/
apps
/
web
/
src
/
app
/
tasks
/
[id]
/
/opt/canhelp/apps/web/src/app/tasks/[id]
mkdir
upload
Name
Size
Mode
Actions
offer/
-
0755
rm
page.tsx
1753
0644
edit
dl
rm
TaskDetailClient.tsx
49677
0644
edit
dl
rm
Edit:
/opt/canhelp/apps/web/src/app/tasks/[id]/page.tsx
(1753B)
import { getTask, getCategories, getLocations } from '@/lib/api' import { notFound } from 'next/navigation' import { cookies } from 'next/headers' import type { Metadata } from 'next' import TaskDetailClient from './TaskDetailClient' interface Props { params: Promise<{ id: string }> } export async function generateMetadata({ params }: Props): Promise<Metadata> { const { id } = await params try { const { task } = await getTask(id) return { title: `${task.title} — CanHelp`, description: task.description.slice(0, 160) } } catch { return { title: 'Εργασία — CanHelp' } } } export default async function TaskDetailPage({ params }: Props) { const { id } = await params let taskData: any try { taskData = await getTask(id) } catch { notFound() } const cookieStore = await cookies() const locale = (cookieStore.get('canhelp_locale')?.value ?? 'el') as 'el' | 'en' | 'uk' | 'ru' const [cats, locs] = await Promise.all([ getCategories().catch(() => []), getLocations().catch(() => []), ]) const catMap: Record<string, string> = {} for (const cat of cats) { catMap[(cat as any).slug] = (cat as any).names[locale] ?? (cat as any).names.el for (const sub of (cat as any).children ?? []) { catMap[sub.slug] = sub.names[locale] ?? sub.names.el } } const locMap: Record<string, string> = {} for (const city of locs) { locMap[(city as any).slug] = (city as any).names[locale] ?? (city as any).names.el for (const d of (city as any).children ?? []) { locMap[d.slug] = d.names[locale] ?? d.names.el } } return <TaskDetailClient taskId={id} initialTask={taskData.task} initialCustomer={taskData.customer} catMap={catMap} locMap={locMap} /> }
Save
cmd:
run