diff --git a/src/app/(dashboard)/jobs/[jobId]/components/job-actions-panel.tsx b/src/app/(dashboard)/jobs/[jobId]/components/job-actions-panel.tsx index b4c54ca..a5744a6 100644 --- a/src/app/(dashboard)/jobs/[jobId]/components/job-actions-panel.tsx +++ b/src/app/(dashboard)/jobs/[jobId]/components/job-actions-panel.tsx @@ -9,6 +9,7 @@ import { Loader2, PackageCheck, Play, + RotateCcw, Send, X, } from "lucide-react"; @@ -32,6 +33,7 @@ import { cancelJobAction, handToClinicAction, markDeliveredAction, + requestRevisionAction, } from "@/lib/appwrite/job-actions"; import { initialJobActionState } from "@/lib/appwrite/job-types"; import type { Job, TenantKind } from "@/lib/appwrite/schema"; @@ -67,7 +69,10 @@ export function JobActionsPanel({ {/* Clinic finished the prova — approve and send back to lab */} {isClinic && job.status === "in_progress" && isAtClinic && ( - + <> + + + )} {/* Final delivery — clinic took it from the lab */} @@ -236,6 +241,68 @@ function ApproveAtClinicButton({ job }: { job: Job }) { ); } +function RequestRevisionButton({ job }: { job: Job }) { + const router = useRouter(); + const [state, action, pending] = useActionState( + requestRevisionAction, + initialJobActionState, + ); + const [open, setOpen] = useState(false); + + useEffect(() => { + if (state.ok) { + toast.success("Düzeltme talebi gönderildi."); + setOpen(false); + router.refresh(); + } else if (state.error) { + toast.error(state.error); + } + }, [state, router]); + + return ( + + + + + Provayı reddet, lab'a geri gönder + + Bu aşamayı reddettiğinizde iş aynı adımda kalır ve laboratuvar + yeniden çalışır. Neyin düzeltilmesi gerektiğini lütfen yazın. + + +
+ +
+ +