33 lines
975 B
TypeScript
33 lines
975 B
TypeScript
import { getDefaultFileKey } from "@/shared/lib";
|
|
|
|
export type FieldPrefix = "fnrsCnsltnMng" | "instlSncnMng" | "designCnstnMng";
|
|
|
|
export const ETC_FILE_KEY_PREFIX = "etc::";
|
|
|
|
export function atchFileGroupIdPath(fieldPrefix: FieldPrefix): string {
|
|
return `${fieldPrefix}.atchFileGroupId`;
|
|
}
|
|
|
|
export function createUploadKey(esntlAtchFileId: string, file: File): string {
|
|
return `${esntlAtchFileId}::${getDefaultFileKey(file)}`;
|
|
}
|
|
|
|
export function createEtcUploadKey(file: File): string {
|
|
return `${ETC_FILE_KEY_PREFIX}${getDefaultFileKey(file)}`;
|
|
}
|
|
|
|
export function isEtcFileKey(fileKey: string): boolean {
|
|
return fileKey.startsWith(ETC_FILE_KEY_PREFIX);
|
|
}
|
|
|
|
export function toFileAccept(rmrk: string | null | undefined): string {
|
|
if (!rmrk?.trim()) return "";
|
|
|
|
return rmrk
|
|
.split(",")
|
|
.map((ext) => ext.trim().toLowerCase())
|
|
.filter(Boolean)
|
|
.map((ext) => (ext.startsWith(".") ? ext : `.${ext}`))
|
|
.join(",");
|
|
}
|