feat(modules): connections, products, jobs (list/form/detail-placeholder)

Connections (clinic ↔ lab)
  - request via member number, approve/reject (counterparty), cancel pending,
    delete approved
  - permission rows opened to both teams; audit log for every mutation
  - /connections page: own code card, request form, pending inbound/outbound
    tables, approved connections table with delete confirm

Products (lab catalog)
  - createProstheticAction + update + archive/restore + delete (lab-only)
  - zod validation, dev-mode error surfacing
  - /products page: catalog table + add form + edit dialog. Hidden from
    clinic accounts via requireTenantKind.

Jobs (work orders)
  - createJobAction (clinic-only) — checks approved connection before write,
    permissions opened to both clinic and lab teams
  - listInboundJobs (lab perspective), listOutboundJobs (clinic perspective),
    listApprovedLabsForClinic for the new-job form
  - /jobs/inbound + /jobs/outbound tables with role-aware copy
  - /jobs/new full form (lab select, patient code, prosthetic type, member
    count, color, due date, price/currency, description)
  - /jobs/[jobId] placeholder detail page with stepper visualisation;
    status/step updates and file upload come next session

All new mutations follow the memory rules: schema-checked row payloads,
admin client behind requireTenant + requireRole/requireTenantKind, audit
log calls best-effort, no empty-string Radix Select values.
This commit is contained in:
kovakmedya
2026-05-21 19:59:23 +03:00
parent 7fb8288f79
commit 76e02754b8
26 changed files with 2765 additions and 42 deletions
+39 -9
View File
@@ -1,7 +1,15 @@
import Link from "next/link";
import { redirect } from "next/navigation";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { listApprovedLabsForClinic } from "@/lib/appwrite/job-queries";
import { requireTenant, requireTenantKind } from "@/lib/appwrite/tenant-guard";
import { NewJobForm } from "./components/new-job-form";
export const metadata = {
title: "DLS — Yeni İş Yayınla",
};
export default async function NewJobPage() {
let ctx;
@@ -12,6 +20,9 @@ export default async function NewJobPage() {
redirect("/dashboard");
}
const labs = await listApprovedLabsForClinic(ctx.tenantId);
const defaultCurrency = ctx.settings?.defaultCurrency ?? "TRY";
return (
<div className="flex-1 space-y-6 px-6">
<div className="flex flex-col gap-1">
@@ -20,15 +31,34 @@ export default async function NewJobPage() {
Bağlı laboratuvarınıza yeni bir protez işi gönderin.
</p>
</div>
<Card>
<CardHeader>
<CardTitle>Yapım aşamasında</CardTitle>
<CardDescription>
Form (lab seçimi, hasta kodu, protez türü, renk, dosya yükleme) sonraki sürümde eklenecek.
</CardDescription>
</CardHeader>
<CardContent />
</Card>
{labs.length === 0 ? (
<Card>
<CardHeader>
<CardTitle>Önce bir laboratuvarla bağlantı kurun</CardTitle>
<CardDescription>
İş gönderebilmeniz için onaylanmış bir laboratuvar bağlantınız olmalı.
</CardDescription>
</CardHeader>
<CardContent>
<Button asChild>
<Link href="/connections">Bağlantı Kur</Link>
</Button>
</CardContent>
</Card>
) : (
<Card>
<CardHeader>
<CardTitle>İş Bilgileri</CardTitle>
<CardDescription>
Hasta kodu, protez türü ve diğer detayları girin. Dosya yüklemesi sonraki sürümde.
</CardDescription>
</CardHeader>
<CardContent>
<NewJobForm labs={labs} defaultCurrency={defaultCurrency} />
</CardContent>
</Card>
)}
</div>
);
}