Add extras and options CRUD, add sidebar, add kanban board, udpate packages
This commit is contained in:
47
src/app/(admin)/commissions/kanban/page.tsx
Normal file
47
src/app/(admin)/commissions/kanban/page.tsx
Normal file
@ -0,0 +1,47 @@
|
||||
import CommissionsKanbanClient from "@/components/commissions/kanban/CommissionsKanbanClient";
|
||||
import { columnIdForStatus } from "@/lib/commissions/kanban";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
import type { BoardItem, ColumnsState } from "@/types/Board";
|
||||
|
||||
export default async function CommissionsBoardPage() {
|
||||
const requests = await prisma.commissionRequest.findMany({
|
||||
where: {
|
||||
status: { in: ["NEW", "REVIEWING", "ACCEPTED", "INPROGRESS", "COMPLETED"] },
|
||||
},
|
||||
orderBy: [{ createdAt: "desc" }],
|
||||
include: {
|
||||
type: true,
|
||||
option: true,
|
||||
extras: true,
|
||||
files: true,
|
||||
},
|
||||
});
|
||||
|
||||
const initial: ColumnsState = {
|
||||
intake: [],
|
||||
inProgress: [],
|
||||
completed: [],
|
||||
};
|
||||
|
||||
for (const r of requests) {
|
||||
const col = columnIdForStatus(r.status) ?? "intake";
|
||||
|
||||
const item: BoardItem = {
|
||||
id: r.id,
|
||||
createdAt: r.createdAt.toISOString(),
|
||||
status: r.status,
|
||||
customerName: r.customerName,
|
||||
customerEmail: r.customerEmail,
|
||||
message: r.message,
|
||||
typeName: r.type?.name ?? null,
|
||||
optionName: r.option?.name ?? null,
|
||||
extrasCount: r.extras.length,
|
||||
filesCount: r.files.length,
|
||||
};
|
||||
|
||||
initial[col].push(item);
|
||||
}
|
||||
|
||||
return <CommissionsKanbanClient initialColumns={initial} />;
|
||||
}
|
||||
@ -19,9 +19,9 @@ export default async function CommissionTypesEditPage({ params }: { params: { id
|
||||
const extras = await prisma.commissionExtra.findMany({
|
||||
orderBy: [{ sortIndex: "asc" }, { name: "asc" }],
|
||||
})
|
||||
const customInputs = await prisma.commissionCustomInput.findMany({
|
||||
orderBy: [{ sortIndex: "asc" }, { name: "asc" }],
|
||||
})
|
||||
// const customInputs = await prisma.commissionCustomInput.findMany({
|
||||
// orderBy: [{ sortIndex: "asc" }, { name: "asc" }],
|
||||
// })
|
||||
|
||||
if (!commissionType) {
|
||||
return <div>Type not found</div>
|
||||
@ -32,7 +32,7 @@ export default async function CommissionTypesEditPage({ params }: { params: { id
|
||||
<div className="flex gap-4 justify-between pb-8">
|
||||
<h1 className="text-2xl font-bold mb-4">Edit Commission Type</h1>
|
||||
</div>
|
||||
<EditTypeForm type={commissionType} allOptions={options} allExtras={extras} allCustomInputs={customInputs} />
|
||||
<EditTypeForm type={commissionType} allOptions={options} allExtras={extras} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
10
src/app/(admin)/commissions/types/extras/page.tsx
Normal file
10
src/app/(admin)/commissions/types/extras/page.tsx
Normal file
@ -0,0 +1,10 @@
|
||||
import { ExtraListClient } from "@/components/commissions/extras/ExtraListClient";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
export default async function CommissionTypesExtrasPage() {
|
||||
const extras = await prisma.commissionExtra.findMany({
|
||||
orderBy: [{ createdAt: "asc" }, { name: "asc" }],
|
||||
});
|
||||
|
||||
return <ExtraListClient extras={extras} />;
|
||||
}
|
||||
10
src/app/(admin)/commissions/types/options/page.tsx
Normal file
10
src/app/(admin)/commissions/types/options/page.tsx
Normal file
@ -0,0 +1,10 @@
|
||||
import { OptionsListClient } from "@/components/commissions/options/OptionsListClient";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
export default async function CommissionTypesOptionsPage() {
|
||||
const options = await prisma.commissionOption.findMany({
|
||||
orderBy: [{ createdAt: "asc" }, { name: "asc" }],
|
||||
});
|
||||
|
||||
return <OptionsListClient options={options} />;
|
||||
}
|
||||
@ -1,6 +1,8 @@
|
||||
import LogoutButton from "@/components/auth/LogoutButton";
|
||||
import Footer from "@/components/global/Footer";
|
||||
import Header from "@/components/global/Header";
|
||||
import { Toaster } from "@/components/ui/sonner";
|
||||
import MobileSidebar from "@/components/global/MobileSidebar";
|
||||
import ModeToggle from "@/components/global/ModeToggle";
|
||||
import Sidebar from "@/components/global/Sidebar";
|
||||
|
||||
export default function AdminLayout({
|
||||
children,
|
||||
@ -8,17 +10,48 @@ export default function AdminLayout({
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
return (
|
||||
<div className="flex flex-col min-h-screen min-w-screen">
|
||||
<header className="sticky top-0 z-50 h-14 w-full border-b bg-background/95 backdrop-blur supports-backdrop-filter:bg-background/60 px-4 py-2">
|
||||
<Header />
|
||||
</header>
|
||||
<main className="container mx-auto px-4 py-8">
|
||||
{children}
|
||||
</main>
|
||||
<footer className="mt-auto px-4 py-2 h-14 border-t bg-background/95 backdrop-blur supports-backdrop-filter:bg-background/60">
|
||||
<Footer />
|
||||
</footer>
|
||||
<Toaster />
|
||||
// <div className="flex flex-col min-h-screen min-w-screen">
|
||||
// <header className="sticky top-0 z-50 h-14 w-full border-b bg-background/95 backdrop-blur supports-backdrop-filter:bg-background/60 px-4 py-2">
|
||||
// <Header />
|
||||
// </header>
|
||||
// <main className="container mx-auto px-4 py-8">
|
||||
// {children}
|
||||
// </main>
|
||||
// <footer className="mt-auto px-4 py-2 h-14 border-t bg-background/95 backdrop-blur supports-backdrop-filter:bg-background/60">
|
||||
// <Footer />
|
||||
// </footer>
|
||||
// <Toaster />
|
||||
// </div>
|
||||
<div className="min-h-screen w-full">
|
||||
<div className="flex min-h-screen w-full">
|
||||
<aside className="hidden md:flex md:w-64 md:flex-col md:border-r md:bg-background">
|
||||
<Sidebar />
|
||||
</aside>
|
||||
<div className="flex min-h-screen flex-1 flex-col">
|
||||
<header className="sticky top-0 z-50 h-14 w-full border-b bg-background/95 backdrop-blur supports-backdrop-filter:bg-background/60">
|
||||
<div className="flex h-14 items-center gap-3 px-4">
|
||||
<div className="md:hidden">
|
||||
<MobileSidebar />
|
||||
</div>
|
||||
|
||||
<div className="flex-1">
|
||||
{/* Optional: put breadcrumbs or page title here later */}
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-3">
|
||||
<LogoutButton />
|
||||
<ModeToggle />
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<main className="flex-1">
|
||||
<div className="container mx-auto px-4 py-8">{children}</div>
|
||||
</main>
|
||||
<footer className="mt-auto h-14 border-t bg-background/95 px-4 py-2 backdrop-blur supports-backdrop-filter:bg-background/60">
|
||||
<Footer />
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user