65 lines
2.9 KiB
TypeScript
65 lines
2.9 KiB
TypeScript
import { User } from 'lucide-react'
|
|
import { generateSeoMetadata } from '@/lib/seo'
|
|
|
|
import DynamicPageRenderer from '@/components/dynamic/DynamicPageRenderer'
|
|
import ProfileClient from '@/components/ProfileClient'
|
|
import { getCategoriesResult, getCmsPageResult } from '@/lib/cms'
|
|
import { splitCmsLayoutSections } from '@/lib/cms-sections'
|
|
|
|
// lang is extracted from params
|
|
export async function generateMetadata({ params }: { params: Promise<{ lang: string }> }) {
|
|
const { lang } = await params;
|
|
return generateSeoMetadata({
|
|
title: 'โปรไฟล์สมาชิก',
|
|
description: 'จัดการโปรไฟล์สมาชิก ประวัติคำสั่งซื้อ คะแนนสะสม และสมุดที่อยู่จัดส่ง',
|
|
path: '/profile',
|
|
lang,
|
|
});
|
|
}
|
|
|
|
export default async function ProfilePage({ params }: { params: Promise<{ lang: string }> }) {
|
|
const { lang } = await params
|
|
const [categoriesResult, cmsLayoutResult] = await Promise.all([
|
|
getCategoriesResult(lang),
|
|
getCmsPageResult('profile-layout', lang),
|
|
])
|
|
const categories = categoriesResult.ok ? categoriesResult.data : []
|
|
const cmsSections = cmsLayoutResult.ok ? cmsLayoutResult.data.sections ?? [] : []
|
|
const { announcementSections, heroSections, bottomSections } = splitCmsLayoutSections(cmsSections)
|
|
|
|
if (!cmsLayoutResult.ok && cmsLayoutResult.status !== 404) {
|
|
console.error(`[website-cms] profile-layout unavailable: ${cmsLayoutResult.error}`)
|
|
}
|
|
|
|
return (
|
|
<main className="min-h-[70vh] bg-surface-page text-text-main">
|
|
{announcementSections.length > 0 && (
|
|
<DynamicPageRenderer sections={announcementSections} categories={categories} lang={lang} />
|
|
)}
|
|
|
|
{heroSections.length > 0 ? (
|
|
<DynamicPageRenderer sections={heroSections} categories={categories} lang={lang} />
|
|
) : (
|
|
<section className="mx-auto max-w-4xl px-6 pt-20 text-center md:pt-24">
|
|
<div className="mx-auto mb-5 flex h-16 w-16 items-center justify-center rounded-full bg-surface-card text-brand-primary shadow-card">
|
|
<User className="h-8 w-8" />
|
|
</div>
|
|
<p className="ui-eyebrow">Member Profile</p>
|
|
<h1 className="mt-4 text-4xl font-semibold text-text-main md:text-5xl">โปรไฟล์ของฉัน</h1>
|
|
<p className="mx-auto mt-4 max-w-2xl text-muted-text">
|
|
ตรวจสอบประวัติคำสั่งซื้อ คะแนนสะสม และจัดการที่อยู่จัดส่งสำหรับการสั่งซื้อครั้งถัดไป
|
|
</p>
|
|
</section>
|
|
)}
|
|
|
|
<section className="mx-auto max-w-5xl px-6 py-14 md:py-20">
|
|
<ProfileClient />
|
|
</section>
|
|
|
|
{bottomSections.length > 0 && (
|
|
<DynamicPageRenderer sections={bottomSections} categories={categories} lang={lang} />
|
|
)}
|
|
</main>
|
|
)
|
|
}
|