[as] feat: 행정지원 문서 상세페이지 게이트 구현
This commit is contained in:
@@ -11,6 +11,7 @@ export {
|
||||
recalculateBizCstTotals,
|
||||
} from "./lib/business-cost-form-utils";
|
||||
export { buildCnstpScaleItems, recalculateBzScaleTotals } from "./lib/business-scale-form-utils";
|
||||
export { canEditPbadmsDoc, type CanEditPbadmsDocParams } from "./lib/can-edit-pbadms-doc";
|
||||
export {
|
||||
buildChecklistTabs,
|
||||
isFormChecklistComplete,
|
||||
@@ -34,6 +35,7 @@ export { BusinessScaleFormSection } from "./ui/business-scale-form-section";
|
||||
export { ChecklistFormSection } from "./ui/checklist-form-section";
|
||||
export { ContactInfoFormSection } from "./ui/contact-info-form-section";
|
||||
export { FnrsSharFormSection } from "./ui/fnrs-shar-form-section";
|
||||
export { PbadmsDetailGate, type PbadmsDetailGateProps } from "./ui/pbadms-detail-gate";
|
||||
export {
|
||||
PbadmsTaskApplyDialog,
|
||||
type PbadmsTaskApplySelection,
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
interface CanEditPbadmsDocParams {
|
||||
docSeComCd: string;
|
||||
prgrsSttsComCd: string | undefined;
|
||||
rgtr: string | undefined;
|
||||
loggedInUserUnqId: string | undefined;
|
||||
}
|
||||
|
||||
function canEditPbadmsDoc({
|
||||
docSeComCd,
|
||||
prgrsSttsComCd,
|
||||
rgtr,
|
||||
loggedInUserUnqId,
|
||||
}: CanEditPbadmsDocParams): boolean {
|
||||
if (!loggedInUserUnqId || !rgtr || rgtr !== loggedInUserUnqId) return false;
|
||||
|
||||
if (docSeComCd === "CNFM") return prgrsSttsComCd === "CV";
|
||||
|
||||
if (docSeComCd === "INSTL" || docSeComCd === "FNRS" || docSeComCd === "SEWER")
|
||||
return prgrsSttsComCd === "SV" || prgrsSttsComCd === "SL";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export { canEditPbadmsDoc };
|
||||
export type { CanEditPbadmsDocParams };
|
||||
@@ -0,0 +1,59 @@
|
||||
"use client";
|
||||
|
||||
import { type ReactNode, useEffect } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
import { Skeleton } from "@common/components";
|
||||
|
||||
interface PbadmsDetailGateProps {
|
||||
isPending: boolean;
|
||||
isError: boolean;
|
||||
shouldRedirectToEdit: boolean;
|
||||
editHref: string;
|
||||
children: ReactNode;
|
||||
errorMessage?: string;
|
||||
}
|
||||
|
||||
function DetailSkeleton() {
|
||||
return (
|
||||
<div className="mt-6 flex flex-col gap-4 px-6">
|
||||
<div className="flex flex-col gap-2">
|
||||
<Skeleton className="h-[4rem] rounded-xl" />
|
||||
<Skeleton className="h-[16rem] rounded-xl" />
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
<Skeleton className="h-[4rem] rounded-xl" />
|
||||
<Skeleton className="h-[16rem] rounded-xl" />
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
<Skeleton className="h-[4rem] rounded-xl" />
|
||||
<Skeleton className="h-[32rem] rounded-xl" />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function PbadmsDetailGate({
|
||||
isPending,
|
||||
isError,
|
||||
shouldRedirectToEdit,
|
||||
editHref,
|
||||
children,
|
||||
errorMessage = "상세 정보를 찾을 수 없습니다.",
|
||||
}: PbadmsDetailGateProps) {
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
if (!shouldRedirectToEdit) return;
|
||||
router.replace(editHref);
|
||||
}, [editHref, router, shouldRedirectToEdit]);
|
||||
|
||||
if (isPending || shouldRedirectToEdit) return <DetailSkeleton />;
|
||||
|
||||
if (isError) return <div className="mt-6 text-[1.4rem]">{errorMessage}</div>;
|
||||
|
||||
return children;
|
||||
}
|
||||
|
||||
export { PbadmsDetailGate };
|
||||
export type { PbadmsDetailGateProps };
|
||||
Reference in New Issue
Block a user