5f8f0c9159
Adds PageProfile.website (with migration). Codex runs without network, so the profile draft route fetches the site server-side (public hosts only, redirect-checked, size-capped, cached) and passes its text as <shop_website>. Other prompts receive the URL via the shop profile. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
45 lines
1.9 KiB
TypeScript
45 lines
1.9 KiB
TypeScript
import { prisma } from "@/lib/db";
|
|
import { getConsoleContext } from "@/lib/console";
|
|
import { roleAtLeast } from "@/lib/auth/roles";
|
|
import { EmptyState, PageTitle } from "@/components/ui";
|
|
import { PagePicker } from "@/components/PagePicker";
|
|
import { ProfileForm } from "@/components/ProfileForm";
|
|
|
|
const TITLE = "โปรไฟล์ร้าน";
|
|
|
|
export default async function ProfilePage() {
|
|
const ctx = await getConsoleContext();
|
|
const page = ctx.selected;
|
|
|
|
if (!page) {
|
|
return (
|
|
<>
|
|
<PageTitle title={TITLE} subtitle="ข้อมูลร้านที่ AI ใช้ตอนเขียน caption และวิเคราะห์เพจ" />
|
|
<section className="card">
|
|
<EmptyState icon="store" title="เลือกเพจที่จะตั้งโปรไฟล์" />
|
|
<PagePicker pages={ctx.pages.map(({ id, name, pictureUrl }) => ({ id, name, pictureUrl }))} />
|
|
</section>
|
|
</>
|
|
);
|
|
}
|
|
|
|
const profile = await prisma.pageProfile.findUnique({
|
|
where: { pageId: page.id },
|
|
select: { business: true, audience: true, tone: true, visualStyle: true, avoid: true, cta: true, website: true, updatedAt: true },
|
|
});
|
|
|
|
return (
|
|
<>
|
|
<PageTitle title={TITLE} subtitle={`${page.name} — กรอกครั้งเดียว AI จะเขียนด้วยข้อมูลและน้ำเสียงของร้านนี้`} />
|
|
<ProfileForm
|
|
key={page.id}
|
|
pageId={page.id}
|
|
canEdit={roleAtLeast(page.role, "APPROVER")}
|
|
canDraft={page.status === "ACTIVE"}
|
|
initial={profile ? { business: profile.business, audience: profile.audience, tone: profile.tone, visualStyle: profile.visualStyle, avoid: profile.avoid, cta: profile.cta, website: profile.website } : null}
|
|
updatedAt={profile?.updatedAt.toISOString() ?? null}
|
|
/>
|
|
</>
|
|
);
|
|
}
|