diff options
| author | joonhoekim <26rote@gmail.com> | 2025-08-14 13:15:21 +0000 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-08-14 13:15:21 +0000 |
| commit | 49d236df3bd2bd976ebc424644f34f5affa1074f (patch) | |
| tree | 7b0f60c399e724847894061fae74876aa1bf5c7e /components/knox | |
| parent | 969c25b56f6d29d7ffa4bc2ce04c5fb4e5846b34 (diff) | |
(김준회) 결재 테스트 모듈 수정, 환경병수 eVCP 운영 대응, SGIPS JWT TOKEN 수정, SHI-API 기반 유저 관리 추가, 유저목록 테이블 변경
Diffstat (limited to 'components/knox')
| -rw-r--r-- | components/knox/approval/ApprovalManager.tsx | 11 | ||||
| -rw-r--r-- | components/knox/approval/ApprovalSubmit.tsx | 51 |
2 files changed, 34 insertions, 28 deletions
diff --git a/components/knox/approval/ApprovalManager.tsx b/components/knox/approval/ApprovalManager.tsx index 89450445..554e7680 100644 --- a/components/knox/approval/ApprovalManager.tsx +++ b/components/knox/approval/ApprovalManager.tsx @@ -15,10 +15,17 @@ import ApprovalList from './ApprovalList'; interface ApprovalManagerProps { defaultTab?: string; + currentUser?: { + id: number | string; + name: string | null; + email: string; + epId: string | null; + } | null; } export default function ApprovalManager({ - defaultTab = 'submit' + defaultTab = 'submit', + currentUser, }: ApprovalManagerProps) { const [currentTab, setCurrentTab] = useState(defaultTab); const [selectedApInfId, setSelectedApInfId] = useState<string>(''); @@ -95,7 +102,7 @@ export default function ApprovalManager({ {/* 결재 상신 탭 */} <TabsContent value="submit" className="space-y-6"> <div className="w-full"> - <ApprovalSubmit onSubmitSuccess={handleSubmitSuccess} /> + <ApprovalSubmit onSubmitSuccess={handleSubmitSuccess} currentUser={currentUser ?? undefined} /> </div> </TabsContent> diff --git a/components/knox/approval/ApprovalSubmit.tsx b/components/knox/approval/ApprovalSubmit.tsx index bfe66981..d9ccc785 100644 --- a/components/knox/approval/ApprovalSubmit.tsx +++ b/components/knox/approval/ApprovalSubmit.tsx @@ -104,7 +104,7 @@ import { UserSelector, type UserSelectItem, } from "@/components/common/user/user-selector"; -import { useSession } from "next-auth/react"; +// next-auth 세션 의존 제거 // UserSelector에서 반환되는 사용자에 epId가 포함될 수 있으므로 확장 타입 정의 interface ExtendedUserSelectItem extends UserSelectItem { @@ -531,8 +531,8 @@ function SortableApprovalGroup({ export default function ApprovalSubmit({ onSubmitSuccess, -}: ApprovalSubmitProps) { - const { data: session } = useSession(); + currentUser, +}: ApprovalSubmitProps & { currentUser?: { id: number | string; name: string | null | undefined; email: string; epId?: string | null } }) { const [isSubmitting, setIsSubmitting] = useState(false); const [submitResult, setSubmitResult] = useState<{ apInfId: string; @@ -687,29 +687,28 @@ export default function ApprovalSubmit({ }); }; - // 로그인 사용자를 첫 번째 결재자로 보장하는 effect + // 로그인 사용자를 첫 번째 결재자로 보장하는 effect (prop만 사용) useEffect(() => { - if (!session?.user) return; - - const currentEmail = session.user.email ?? ""; - const currentEpId = (session.user as { epId?: string }).epId; - const currentUserId = session.user.id ?? undefined; + if (!currentUser?.email) return; + const effectiveEmail = currentUser.email; + const effectiveEpId = currentUser.epId ?? undefined; + const effectiveUserId = currentUser.id as string | number | undefined; let currentAplns = form.getValues("aplns"); // 이미 포함되어 있는지 확인 (epId 또는 email 기준) const selfIndex = currentAplns.findIndex( - (a) => (currentEpId && a.epId === currentEpId) || a.emailAddress === currentEmail, + (a) => (effectiveEpId && a.epId === effectiveEpId) || a.emailAddress === effectiveEmail, ); if (selfIndex === -1) { // 맨 앞에 상신자 추가 const newSelf: FormData["aplns"][number] = { id: generateUniqueId(), - epId: currentEpId, - userId: currentUserId ? currentUserId.toString() : undefined, - emailAddress: currentEmail, - name: session.user.name ?? undefined, + epId: effectiveEpId, + userId: effectiveUserId ? effectiveUserId.toString() : undefined, + emailAddress: effectiveEmail, + name: currentUser?.name ?? undefined, role: "0", // 기안 seq: "0", opinion: "", @@ -722,7 +721,7 @@ export default function ApprovalSubmit({ currentAplns = currentAplns.map((apln, idx) => ({ ...apln, seq: idx.toString() })); form.setValue("aplns", currentAplns, { shouldValidate: false, shouldDirty: true }); - }, [session, form]); + }, [currentUser, form]); // dnd-kit sensors const sensors = useSensors( @@ -856,19 +855,19 @@ export default function ApprovalSubmit({ setSubmitResult(null); try { - // 세션 정보 확인 - if (!session?.user) { - toast.error("로그인이 필요합니다."); + // 사용자 정보 (prop 전용) + if (!currentUser) { + toast.error("사용자 정보를 불러올 수 없습니다."); return; } - const currentEmail = session.user.email ?? ""; - const currentEpId = (session.user as { epId?: string }).epId; - const currentUserId = session.user.id ?? ""; + const effectiveEmail = currentUser.email; + const effectiveEpId = currentUser.epId ?? undefined; + const effectiveUserId = String(currentUser.id ?? ""); - debugLog("Current User", session.user); + debugLog("Current User", { email: effectiveEmail, epId: effectiveEpId, userId: effectiveUserId }); - if (!currentEpId) { + if (!effectiveEpId) { toast.error("사용자 정보가 올바르지 않습니다."); return; } @@ -920,9 +919,9 @@ export default function ApprovalSubmit({ const response = isSecure ? await submitSecurityApproval(submitRequest) : await submitApproval(submitRequest, { - userId: currentUserId, - epId: currentEpId, - emailAddress: currentEmail, + userId: effectiveUserId, + epId: effectiveEpId, + emailAddress: effectiveEmail, }); debugLog("Submit Response", response); |
