mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-04 16:02:08 +00:00
27 lines
846 B
TypeScript
27 lines
846 B
TypeScript
|
|
import type { MediaCategory, MediaFile } from "@/domain/work-orders/types/work-order-media";
|
||
|
|
|
||
|
|
/** First Extra Docs file defaults to Aveta when the WO is flagged and none is Aveta yet.
|
||
|
|
* Board media purpose stays Extra (API enum Before/After/Extra/Completion). */
|
||
|
|
export function resolveExtraDocCategory(
|
||
|
|
file: MediaFile,
|
||
|
|
index: number,
|
||
|
|
avetaRequired: boolean,
|
||
|
|
files: MediaFile[],
|
||
|
|
): MediaCategory {
|
||
|
|
if (file.category === "Aveta") {
|
||
|
|
return "Aveta";
|
||
|
|
}
|
||
|
|
const hasExplicitAveta = files.some((item) => item.category === "Aveta");
|
||
|
|
if (avetaRequired && index === 0 && !hasExplicitAveta) {
|
||
|
|
return "Aveta";
|
||
|
|
}
|
||
|
|
return file.category;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function shouldDefaultFirstExtraToAveta(
|
||
|
|
avetaRequired: boolean,
|
||
|
|
existing: MediaFile[],
|
||
|
|
): boolean {
|
||
|
|
return avetaRequired && !existing.some((item) => item.category === "Aveta");
|
||
|
|
}
|