mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-04 17:12:06 +00:00
28 lines
900 B
TypeScript
28 lines
900 B
TypeScript
|
|
/** Backend RequestSizeLimit for media and completion-doc uploads. */
|
||
|
|
export const MAX_WORK_ORDER_MEDIA_BYTES = 30 * 1024 * 1024;
|
||
|
|
|
||
|
|
export function isWorkOrderFileTooLarge(
|
||
|
|
file: File,
|
||
|
|
maxBytes = MAX_WORK_ORDER_MEDIA_BYTES,
|
||
|
|
): boolean {
|
||
|
|
return file.size > maxBytes;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function formatMediaSizeLimit(maxBytes = MAX_WORK_ORDER_MEDIA_BYTES): string {
|
||
|
|
return `${Math.round(maxBytes / (1024 * 1024))} MB`;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** Backend IsReadOnly: Canceled or Completed. */
|
||
|
|
export function isWorkOrderDocumentsReadOnly(status: string | null | undefined): boolean {
|
||
|
|
return status === "Canceled" || status === "Completed";
|
||
|
|
}
|
||
|
|
|
||
|
|
export function canDeleteWorkOrderMedia(media: {
|
||
|
|
id: string | number;
|
||
|
|
isLegacy?: boolean;
|
||
|
|
}): boolean {
|
||
|
|
if (media.isLegacy) return false;
|
||
|
|
const numericId = typeof media.id === "number" ? media.id : Number(media.id);
|
||
|
|
return Number.isFinite(numericId) && numericId > 0;
|
||
|
|
}
|