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:
@@ -0,0 +1,96 @@
|
||||
import Link from "next/link";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import {
|
||||
JOB_STATUS_LABELS,
|
||||
PROSTHETIC_TYPE_LABELS,
|
||||
} from "@/lib/appwrite/job-types";
|
||||
import type { JobWithCounterpart } from "@/lib/appwrite/job-queries";
|
||||
import type { JobStatus } from "@/lib/appwrite/schema";
|
||||
|
||||
const dateFormatter = new Intl.DateTimeFormat("tr-TR", {
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
year: "numeric",
|
||||
});
|
||||
|
||||
function statusVariant(status: JobStatus): "default" | "secondary" | "outline" | "destructive" {
|
||||
switch (status) {
|
||||
case "delivered":
|
||||
return "default";
|
||||
case "sent":
|
||||
return "secondary";
|
||||
case "in_progress":
|
||||
return "secondary";
|
||||
case "cancelled":
|
||||
return "destructive";
|
||||
default:
|
||||
return "outline";
|
||||
}
|
||||
}
|
||||
|
||||
export function JobsTable({
|
||||
rows,
|
||||
counterpartLabel,
|
||||
emptyMessage,
|
||||
}: {
|
||||
rows: JobWithCounterpart[];
|
||||
counterpartLabel: string;
|
||||
emptyMessage: string;
|
||||
}) {
|
||||
if (rows.length === 0) {
|
||||
return (
|
||||
<p className="text-muted-foreground py-6 text-center text-sm">{emptyMessage}</p>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>{counterpartLabel}</TableHead>
|
||||
<TableHead>Hasta Kodu</TableHead>
|
||||
<TableHead>Üye</TableHead>
|
||||
<TableHead>Renk</TableHead>
|
||||
<TableHead>Tür</TableHead>
|
||||
<TableHead>Durum</TableHead>
|
||||
<TableHead>Tarih</TableHead>
|
||||
<TableHead className="text-right">İşlem</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{rows.map((j) => (
|
||||
<TableRow key={j.$id}>
|
||||
<TableCell className="font-medium">{j.counterpart?.companyName ?? "—"}</TableCell>
|
||||
<TableCell className="font-mono text-xs">{j.patientCode}</TableCell>
|
||||
<TableCell className="tabular-nums">{j.memberCount}</TableCell>
|
||||
<TableCell className="text-muted-foreground">{j.color || "—"}</TableCell>
|
||||
<TableCell className="text-muted-foreground">
|
||||
{PROSTHETIC_TYPE_LABELS[j.prostheticType] ?? j.prostheticType}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Badge variant={statusVariant(j.status)}>{JOB_STATUS_LABELS[j.status]}</Badge>
|
||||
</TableCell>
|
||||
<TableCell className="text-muted-foreground text-xs">
|
||||
{dateFormatter.format(new Date(j.$createdAt))}
|
||||
</TableCell>
|
||||
<TableCell className="text-right">
|
||||
<Button asChild size="sm" variant="outline">
|
||||
<Link href={`/jobs/${j.$id}`}>Detay</Link>
|
||||
</Button>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user