fix(queue): persist clear plate state across page refresh (#410)

After clicking "Clear Plate & Start Next", refreshing the page showed
the button again because the frontend determined the state purely from
the printer's FINISH/FAILED status. The backend already tracked a
plate_cleared flag in memory but never exposed it to the frontend.

- Add plate_cleared field to PrinterStatus schema and API response
- Pass plateCleared prop to PrinterQueueWidget
- Skip clear plate UI when plate is already acknowledged
- Add 2 tests for plateCleared=true behavior
This commit is contained in:
maziggy
2026-02-17 12:14:47 +01:00
parent 20e06bcf0c
commit a0abeba394
9 changed files with 35 additions and 6 deletions
@@ -10,6 +10,7 @@ import { parseUTCDate } from '../utils/date';
interface PrinterQueueWidgetProps {
printerId: number;
printerState?: string | null;
plateCleared?: boolean;
}
function formatRelativeTime(dateString: string | null): string {
@@ -26,7 +27,7 @@ function formatRelativeTime(dateString: string | null): string {
return date.toLocaleDateString();
}
export function PrinterQueueWidget({ printerId, printerState }: PrinterQueueWidgetProps) {
export function PrinterQueueWidget({ printerId, printerState, plateCleared }: PrinterQueueWidgetProps) {
const { t } = useTranslation();
const queryClient = useQueryClient();
const { showToast } = useToast();
@@ -56,7 +57,7 @@ export function PrinterQueueWidget({ printerId, printerState }: PrinterQueueWidg
return null;
}
const needsClearPlate = printerState === 'FINISH' || printerState === 'FAILED';
const needsClearPlate = (printerState === 'FINISH' || printerState === 'FAILED') && !plateCleared;
if (needsClearPlate) {
return (