mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-01 13:13:11 +00:00
Keep Extra uploads uncategorized until the dispatcher picks Aveta. Drive the shield from hasAvetaDocument after reopen.
23 lines
766 B
TypeScript
23 lines
766 B
TypeScript
import type { MediaCategory, MediaFile } from "@/domain/work-orders/types/work-order-media";
|
|
|
|
/**
|
|
* Extra Docs Aveta is an explicit API media category (value 5).
|
|
* Upload stays Extra; only an explicit Aveta category counts as attached.
|
|
*/
|
|
export function resolveExtraDocCategory(file: MediaFile): MediaCategory {
|
|
if (file.purpose === "Aveta" || file.category === "Aveta") {
|
|
return "Aveta";
|
|
}
|
|
return file.category;
|
|
}
|
|
|
|
export function hasExplicitAvetaFile(files: MediaFile[]): boolean {
|
|
return files.some((item) => resolveExtraDocCategory(item) === "Aveta");
|
|
}
|
|
|
|
export function isAvetaDocumentAttached(
|
|
hasAvetaDocument: boolean | undefined,
|
|
files: MediaFile[] = [],
|
|
): boolean {
|
|
return Boolean(hasAvetaDocument) || hasExplicitAvetaFile(files);
|
|
}
|