feat: Redesenho previews on the server: one at a time, counted, and the stage clock stops while one waits (Rodada 5, D2)

POST /api/operator/orders/{id}/redesign-preview (sent, approved,
rejected), redesign_previews table, previews on every board order, and
assign_late leaves out the time a preview waited for the customer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-30 11:59:24 -03:00
parent aeb43500a7
commit 45c5493a4c
5 changed files with 149 additions and 2 deletions

View File

@@ -0,0 +1,15 @@
-- Round 5, D2 (order from 2026-11-16): a redesign's preview, sent to the
-- customer, waiting for approval or rejection. One preview is open at a time.
CREATE TABLE IF NOT EXISTS dtf_local.redesign_previews (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
order_id uuid NOT NULL REFERENCES dtf_local.orders(id) ON DELETE CASCADE,
number int NOT NULL,
sent_at timestamptz NOT NULL DEFAULT now(),
sent_by text NOT NULL,
decided_at timestamptz,
result text CHECK (result IN ('approved','rejected')),
reason text NOT NULL DEFAULT '',
decided_by text,
UNIQUE (order_id, number)
);
CREATE UNIQUE INDEX IF NOT EXISTS redesign_previews_open ON dtf_local.redesign_previews(order_id) WHERE decided_at IS NULL;