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,50 @@
import { ShellPage } from "@/components/page-templates";
import { Button, SectionCard } from "@/components/ui";
import { getSession } from "@/lib/auth";
import { changePassword } from "@/lib/admin-crud";
import { redirect } from "next/navigation";
export default async function ChangePasswordPage({
searchParams
}: {
searchParams?: Promise<{ error?: string; success?: string }>;
}) {
const session = await getSession();
if (!session) {
redirect("/login");
}
const params = await (searchParams ?? Promise.resolve({ error: undefined, success: undefined }));
const shell = session.role === "agent" ? "agent" : session.role === "super_admin" ? "super-admin" : "admin";
const infoMessage =
params.success === "updated"
? "Password berhasil diperbarui."
: params.error === "missing_fields"
? "Lengkapi semua field password."
: params.error === "password_mismatch"
? "Password baru dan konfirmasi tidak sama."
: params.error === "wrong_current_password"
? "Password lama tidak sesuai."
: null;
return (
<ShellPage shell={shell} title="Change Password" description="Ubah password akun Anda.">
<SectionCard title="Password form">
<form action={changePassword} className="grid gap-4 md:max-w-xl">
{infoMessage ? <p className="rounded-xl border border-success/30 bg-success/10 p-3 text-sm text-success">{infoMessage}</p> : null}
<input type="password" name="currentPassword" className="rounded-xl border border-line px-4 py-3" placeholder="Current password" />
<input type="password" name="newPassword" className="rounded-xl border border-line px-4 py-3" placeholder="New password" />
<input
type="password"
name="confirmPassword"
className="rounded-xl border border-line px-4 py-3"
placeholder="Confirm new password"
/>
<div>
<Button type="submit">Update password</Button>
</div>
</form>
</SectionCard>
</ShellPage>
);
}

43
app/profile/edit/page.tsx Normal file
View File

@ -0,0 +1,43 @@
import { ShellPage } from "@/components/page-templates";
import { Button, SectionCard } from "@/components/ui";
import { redirect } from "next/navigation";
import { getSession } from "@/lib/auth";
import { updateMyProfile } from "@/lib/admin-crud";
export default async function EditProfilePage({
searchParams
}: {
searchParams?: Promise<{ error?: string }>;
}) {
const session = await getSession();
if (!session) {
redirect("/login");
}
const params = await (searchParams ?? Promise.resolve({ error: undefined }));
const message = params.error === "missing_fullname" ? "Nama lengkap wajib diisi." : null;
const shell = session.role === "agent" ? "agent" : session.role === "super_admin" ? "super-admin" : "admin";
return (
<ShellPage shell={shell} title="Edit Profile" description="Edit identitas dasar pengguna.">
<SectionCard title="Profile form">
<form action={updateMyProfile} className="grid gap-4 md:max-w-xl">
{message ? <p className="rounded-xl border border-warning/30 bg-warning/10 p-3 text-sm text-warning">{message}</p> : null}
<input
className="rounded-xl border border-line px-4 py-3"
defaultValue={session?.fullName ?? ""}
placeholder="Full name"
name="fullName"
required
/>
<input className="rounded-xl border border-line px-4 py-3" placeholder="Avatar URL" name="avatarUrl" />
<div>
<Button type="submit">Save changes</Button>
</div>
</form>
</SectionCard>
</ShellPage>
);
}

43
app/profile/page.tsx Normal file
View File

@ -0,0 +1,43 @@
import { redirect } from "next/navigation";
import { getSession } from "@/lib/auth";
import { ShellPage } from "@/components/page-templates";
import { SectionCard } from "@/components/ui";
function roleLabel(role: string) {
if (role === "admin_client") {
return "Admin Client";
}
if (role === "agent") {
return "Agent";
}
return "Super Admin";
}
export default async function ProfilePage() {
const session = await getSession();
if (!session) {
redirect("/login");
}
const shell = session.role === "agent" ? "agent" : session.role === "super_admin" ? "super-admin" : "admin";
return (
<ShellPage
shell={shell}
title="My Profile"
description="Informasi akun dasar yang nantinya terhubung ke session dan role."
>
<SectionCard title="Profile summary">
<div className="grid gap-3 text-sm text-on-surface-variant md:grid-cols-2">
<p>Full name: {session.fullName}</p>
<p>Email: {session.email}</p>
<p>Role: {roleLabel(session.role)}</p>
<p>Tenant: {session.tenantName}</p>
</div>
</SectionCard>
</ShellPage>
);
}