feat(workflow): split job step from location, model back-and-forth between lab and clinic
Real prosthetic production isn't a one-way pipeline — the work moves
between lab and clinic multiple times. After substructure is produced
the lab hands it to the clinic for a fitting, the clinic approves it
back to the lab, the lab builds the superstructure, hands it back for
a second fitting, the clinic approves again, the lab does cila/bitim,
and finally delivers it to the clinic for handover to the patient.
Previously we only had a single 'advance step' action callable by the
lab, which collapsed all of that into a linear forward push and didn't
capture who physically had the work at any given moment.
DB
- New jobs.location enum (at_clinic | at_lab, default at_clinic).
- Existing jobs keep working via a 'location ?? at_lab' fallback in
code; no manual backfill required for the four test rows.
State machine
- acceptJobAction (lab): pending → in_progress, currentStep=alt_yapi_prova,
location=at_lab. Skips the implicit 'olcu' production step now that
accepting the job means the lab has the impression in hand.
- handToClinicAction (lab, NEW): at_lab → at_clinic, step stays the
same. If step is cila_bitim, status becomes 'sent' (final delivery)
and finance sync fires.
- approveAtClinicAction (clinic, NEW): at_clinic → at_lab, step
advances to the next stage so the lab knows what to produce next.
- markDeliveredAction unchanged — clinic confirms the final handoff.
- advanceStepAction removed; its single forward push doesn't fit the
new bidirectional flow.
UI
- JobActionsPanel now picks the right button from the role + status +
location matrix:
* Lab + pending → 'İşleme Al'
* Lab + in_progress + at_lab + cila_bitim → 'Cila Bitim — Nihai Teslime Gönder'
* Lab + in_progress + at_lab + other → '{stage} Provaya Gönder'
* Clinic + in_progress + at_clinic → '{stage} Provası Tamam'
* Clinic + sent → 'Teslim Aldım'
* Both + pending → 'İptal Et'
- Job detail surfaces a new 'Şu An' info row that resolves to a
human-readable location ('Klinikte', 'Laboratuvarda', 'Hasta'ya
teslim edildi', ...) so anyone glancing at the page can tell where
the work physically is.
This commit is contained in:
@@ -10,6 +10,7 @@ import { listJobHistory } from "@/lib/appwrite/job-history-queries";
|
||||
import { getPatient } from "@/lib/appwrite/patient-queries";
|
||||
import { toPlain } from "@/lib/appwrite/serialize";
|
||||
import {
|
||||
JOB_LOCATION_LABELS,
|
||||
JOB_STATUS_LABELS,
|
||||
JOB_STEP_LABELS,
|
||||
JOB_STEP_ORDER,
|
||||
@@ -141,6 +142,15 @@ export default async function JobDetailPage({
|
||||
<Info label="Mevcut Aşama">
|
||||
{job.currentStep ? JOB_STEP_LABELS[job.currentStep] : "—"}
|
||||
</Info>
|
||||
<Info label="Şu An">
|
||||
{job.status === "pending"
|
||||
? "Klinikte (lab teslim alacak)"
|
||||
: job.status === "delivered"
|
||||
? "Hasta'ya teslim edildi"
|
||||
: job.status === "cancelled"
|
||||
? "İptal"
|
||||
: JOB_LOCATION_LABELS[job.location ?? "at_lab"]}
|
||||
</Info>
|
||||
<div className="md:col-span-2">
|
||||
<p className="text-muted-foreground mb-1 text-xs font-medium uppercase tracking-wide">
|
||||
Dişler ({job.teeth?.length ?? job.memberCount})
|
||||
|
||||
Reference in New Issue
Block a user