[st] - 입력-반려/일괄반려, 관리-통계일정관리,검토이력조회, 버튼 권한체크

This commit is contained in:
2026-05-14 15:39:17 +09:00
parent 25320d43c4
commit 49e31134b6
19 changed files with 687 additions and 154 deletions
+4
View File
@@ -5,5 +5,9 @@ export { useDataTable } from "./use-data-table";
export { useGlobalProgressStore } from "./use-global-progress-store";
export { useMenuStore } from "./use-menu-store";
export { useUserStore } from "./use-user-store";
export {
useStatisticsInputStatusConfirmGroupGate,
useStatisticsInputToolbarGroupGate,
} from "./use-statistics-input-toolbar-group-gate";
export { usePrompt } from "./use-prompt";
export { useSelectPrompt } from "./use-select-prompt";
@@ -0,0 +1,68 @@
"use client";
import { useEffect, useState } from "react";
import {
checkStatisticsInputStatusConfirmGroupMembership,
checkStatisticsInputToolbarGroupMembership,
} from "@/entities/group-user/lib/check-statistics-input-toolbar-group-membership";
import { useUserStore } from "./use-user-store";
/** 통계 입력 상단 툴바(저장·제출·검증결과 등) — 그룹 멤버십 만족 시에만 true */
export function useStatisticsInputToolbarGroupGate(): boolean {
const userInfo = useUserStore((s) => s.userInfo);
const [allowed, setAllowed] = useState(false);
useEffect(() => {
let cancelled = false;
const name = userInfo?.userName?.trim() ?? "";
const uid = userInfo?.userUnqId?.trim() ?? "";
if (!name || !uid) {
setAllowed(false);
return;
}
void (async () => {
try {
const ok = await checkStatisticsInputToolbarGroupMembership(name, uid);
if (!cancelled) setAllowed(ok);
} catch {
if (!cancelled) setAllowed(false);
}
})();
return () => {
cancelled = true;
};
}, [userInfo?.userName, userInfo?.userUnqId]);
return allowed;
}
/** 통계 입력 현황 — `GRP_ST_CONFIRM` / `GRP_ADMIN` 멤버일 때만 true */
export function useStatisticsInputStatusConfirmGroupGate(): boolean {
const userInfo = useUserStore((s) => s.userInfo);
const [allowed, setAllowed] = useState(false);
useEffect(() => {
let cancelled = false;
const name = userInfo?.userName?.trim() ?? "";
const uid = userInfo?.userUnqId?.trim() ?? "";
if (!name || !uid) {
setAllowed(false);
return;
}
void (async () => {
try {
const ok = await checkStatisticsInputStatusConfirmGroupMembership(name, uid);
if (!cancelled) setAllowed(ok);
} catch {
if (!cancelled) setAllowed(false);
}
})();
return () => {
cancelled = true;
};
}, [userInfo?.userName, userInfo?.userUnqId]);
return allowed;
}