Files
frontend/apps/as/entities/instl-sncn/lib/validation.ts
T

74 lines
1.6 KiB
TypeScript

import type { FnrscVO } from "../model";
export interface VldtnErr {
field: string;
message: string;
}
export function vldtInstlSncnForm(data: FnrscVO): VldtnErr[] {
const errors: VldtnErr[] = [];
if (!data.jobSe) {
errors.push({
field: "jobSe",
message: "업무구분을 선택해주세요.",
});
}
if (!data.bplcNm || data.bplcNm.trim() === "") {
errors.push({
field: "bplcNm",
message: "사업장명을 입력해주세요.",
});
}
if (!data.fcltNm || data.fcltNm.trim() === "") {
errors.push({
field: "fcltNm",
message: "시설명을 입력해주세요.",
});
}
return errors;
}
export function canAply(data: FnrscVO): boolean {
const errors = vldtInstlSncnForm(data);
return errors.length === 0;
}
export function canDel(
prgrsStts: string | undefined,
regId: string | undefined,
currentUsrId: string
): boolean {
return prgrsStts === "SV" && regId === currentUsrId;
}
export function canMdfy(
prgrsStts: string | undefined,
regId: string | undefined,
currentUsrId: string
): boolean {
return (
(prgrsStts === "SV" || prgrsStts === "SL") && regId === currentUsrId
);
}
export function canRqstSplmnt(
prgrsStts: string | undefined,
usrRole: string
): boolean {
return (
(prgrsStts === "ER" || prgrsStts === "PR") &&
(usrRole === "REVIEWER" || usrRole === "APPROVER")
);
}
export function canAprv(
prgrsStts: string | undefined,
usrRole: string
): boolean {
return prgrsStts === "PE" && usrRole === "APPROVER";
}