chore: initial project import
Some checks failed
CI - Production Readiness / Verify (push) Has been cancelled

This commit is contained in:
Wira Basalamah
2026-04-21 09:29:29 +07:00
commit adde003fba
222 changed files with 37657 additions and 0 deletions

View File

@ -0,0 +1,70 @@
import Link from "next/link";
import { redirect } from "next/navigation";
import { ShellPage } from "@/components/page-templates";
import { Button, SectionCard } from "@/components/ui";
import { getSession } from "@/lib/auth";
import { updateTemplate } from "@/lib/admin-crud";
import { prisma } from "@/lib/prisma";
export default async function EditTemplatePage({ params }: { params: Promise<{ templateId: string }> }) {
const { templateId } = await params;
const session = await getSession();
if (!session) {
redirect("/login");
}
const template = await prisma.messageTemplate.findFirst({
where: { id: templateId, tenantId: session.tenantId }
});
if (!template) {
redirect("/templates?error=template_not_found");
}
const channels = await prisma.channel.findMany({
where: { tenantId: session.tenantId },
orderBy: { channelName: "asc" }
});
return (
<ShellPage shell="admin" title="Edit Template" description="Resubmit template yang ditolak atau update draft.">
<SectionCard title="Template form">
<form action={updateTemplate} className="grid gap-4 md:max-w-3xl">
<input type="hidden" name="templateId" value={template.id} />
<input name="name" required defaultValue={template.name} className="rounded-xl border border-line px-4 py-3" />
<input name="category" required defaultValue={template.category} className="rounded-xl border border-line px-4 py-3" />
<input
name="languageCode"
required
defaultValue={template.languageCode}
className="rounded-xl border border-line px-4 py-3"
/>
<label className="md:col-span-2 block text-sm">
<span className="text-on-surface-variant">Channel</span>
<select name="channelId" defaultValue={template.channelId} className="mt-2 w-full rounded-xl border border-line px-4 py-3">
{channels.map((channel) => (
<option key={channel.id} value={channel.id}>
{channel.channelName}
</option>
))}
</select>
</label>
<textarea
required
name="bodyText"
className="min-h-32 rounded-xl border border-line px-4 py-3"
defaultValue={template.bodyText}
/>
<div className="md:col-span-2 flex gap-3">
<Button type="submit" className="rounded-xl">
Save template
</Button>
<Link href={`/templates/${template.id}`} className="text-on-surface-variant hover:underline">
Cancel
</Link>
</div>
</form>
</SectionCard>
</ShellPage>
);
}

View File

@ -0,0 +1,54 @@
import { ShellPage } from "@/components/page-templates";
import { SectionCard } from "@/components/ui";
import { getSession } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
import { redirect } from "next/navigation";
export default async function TemplateDetailPage({ params }: { params: Promise<{ templateId: string }> }) {
const { templateId } = await params;
const session = await getSession();
if (!session) {
redirect("/login");
}
const template = await prisma.messageTemplate.findFirst({
where: { id: templateId, tenantId: session.tenantId },
include: { channel: true }
});
if (!template) {
redirect("/templates?error=template_not_found");
}
return (
<ShellPage shell="admin" title="Template Detail" description="Preview content, provider metadata, dan approval state.">
<div className="grid gap-6 xl:grid-cols-2">
<SectionCard title="Template preview">
<p className="text-sm text-on-surface-variant">
<strong>Name:</strong> {template.name}
</p>
<p className="text-sm text-on-surface-variant">
<strong>Category:</strong> {template.category}
</p>
<p className="text-sm text-on-surface-variant">
<strong>Language:</strong> {template.languageCode}
</p>
<p className="mt-4 rounded-xl border border-line bg-surface-container p-3 text-sm text-on-surface-variant">{template.bodyText}</p>
</SectionCard>
<SectionCard title="Provider status">
<p className="text-sm text-on-surface-variant">
<strong>Approval:</strong> {template.approvalStatus}
</p>
<p className="text-sm text-on-surface-variant">
<strong>Channel:</strong> {template.channel.channelName}
</p>
<p className="text-sm text-on-surface-variant">
<strong>Provider id:</strong> {template.providerTemplateId || "-"}
</p>
<p className="text-sm text-on-surface-variant">
<strong>Rejected reason:</strong> {template.rejectedReason || "-"}
</p>
</SectionCard>
</div>
</ShellPage>
);
}