summaryrefslogtreecommitdiff
path: root/lib/compliance/table/red-flag-managers-dialog.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compliance/table/red-flag-managers-dialog.tsx')
-rw-r--r--lib/compliance/table/red-flag-managers-dialog.tsx149
1 files changed, 104 insertions, 45 deletions
diff --git a/lib/compliance/table/red-flag-managers-dialog.tsx b/lib/compliance/table/red-flag-managers-dialog.tsx
index 08244f9e..79076989 100644
--- a/lib/compliance/table/red-flag-managers-dialog.tsx
+++ b/lib/compliance/table/red-flag-managers-dialog.tsx
@@ -21,7 +21,13 @@ import {
updateRedFlagManagers
} from "@/lib/compliance/services";
-export function RedFlagManagersDialog() {
+type ManagerDialogMode = "redflag" | "hse";
+
+interface RedFlagManagersDialogProps {
+ mode?: ManagerDialogMode;
+}
+
+export function RedFlagManagersDialog({ mode = "redflag" }: RedFlagManagersDialogProps) {
const [open, setOpen] = React.useState(false);
const [isLoading, setIsLoading] = React.useState(false);
const [isFetching, setIsFetching] = React.useState(false);
@@ -31,6 +37,7 @@ export function RedFlagManagersDialog() {
const [managerId, setManagerId] = React.useState<number | null>(null);
const [purchasingManager, setPurchasingManager] = React.useState<UserSelectItem[]>([]);
const [complianceManager, setComplianceManager] = React.useState<UserSelectItem[]>([]);
+ const [hseManager, setHseManager] = React.useState<UserSelectItem[]>([]);
// 다이얼로그 열릴 때 현재 담당자 정보 가져오기
React.useEffect(() => {
@@ -79,6 +86,22 @@ export function RedFlagManagersDialog() {
domain: cm.domain,
}]);
}
+
+ // 안전(HSE) 담당자 설정
+ if (managers.hseManager) {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ const hm: any = managers.hseManager;
+ setHseManager([{
+ id: hm.id,
+ name: hm.name,
+ email: hm.email,
+ epId: hm.epId,
+ deptCode: hm.deptCode,
+ deptName: hm.deptName,
+ imageUrl: hm.imageUrl,
+ domain: hm.domain,
+ }]);
+ }
}
} catch (error) {
console.error("Error loading red flag managers:", error);
@@ -96,12 +119,22 @@ export function RedFlagManagersDialog() {
setIsLoading(true);
try {
- await updateRedFlagManagers(managerId, {
- purchasingManagerId: purchasingManager[0]?.id || null,
- complianceManagerId: complianceManager[0]?.id || null,
- });
+ const payload: {
+ purchasingManagerId?: number | null;
+ complianceManagerId?: number | null;
+ hseManagerId?: number | null;
+ } = {};
- toast.success("레드플래그 담당자가 저장되었습니다.");
+ if (mode === "redflag") {
+ payload.purchasingManagerId = purchasingManager[0]?.id || null;
+ payload.complianceManagerId = complianceManager[0]?.id || null;
+ } else if (mode === "hse") {
+ payload.hseManagerId = hseManager[0]?.id || null;
+ }
+
+ await updateRedFlagManagers(managerId, payload);
+
+ toast.success("담당자 설정이 저장되었습니다.");
setOpen(false);
router.refresh();
} catch (error) {
@@ -117,17 +150,19 @@ export function RedFlagManagersDialog() {
<DialogTrigger asChild>
<Button variant="outline" size="sm">
<AlertCircle className="mr-2 h-4 w-4 text-red-600" />
- 레드플래그 담당자
+ {mode === "hse" ? "안전(HSE) 담당자" : "레드플래그 담당자"}
</Button>
</DialogTrigger>
<DialogContent className="sm:max-w-[600px]">
<DialogHeader>
<DialogTitle className="flex items-center gap-2">
<AlertCircle className="h-5 w-5 text-red-600" />
- 레드플래그 담당자 관리
+ {mode === "hse" ? "안전(HSE) 담당자 관리" : "레드플래그 담당자 관리"}
</DialogTitle>
<DialogDescription>
- 레드플래그 발생 시 알림을 받을 담당자를 지정합니다.
+ {mode === "hse"
+ ? "PQ 제출 및 안전 관련 알림을 받을 담당자를 지정합니다."
+ : "레드플래그 발생 시 알림을 받을 담당자를 지정합니다."}
</DialogDescription>
</DialogHeader>
@@ -139,43 +174,67 @@ export function RedFlagManagersDialog() {
</div>
) : (
<div className="space-y-6 py-4">
- {/* 구매기획 담당자 */}
- <div className="space-y-2">
- <Label htmlFor="purchasing-manager" className="flex items-center gap-2">
- <Users className="h-4 w-4" />
- 구매기획 담당자
- </Label>
- <UserSelector
- selectedUsers={purchasingManager}
- onUsersChange={setPurchasingManager}
- singleSelect={true}
- placeholder="구매기획 담당자를 검색하세요..."
- domainFilter={{ type: "exclude", domains: ["partners"] }}
- closeOnSelect={true}
- />
- <p className="text-xs text-muted-foreground">
- 레드플래그 발생 시 알림을 받을 구매기획 담당자를 지정합니다.
- </p>
- </div>
+ {mode === "redflag" && (
+ <>
+ {/* 구매기획 담당자 */}
+ <div className="space-y-2">
+ <Label htmlFor="purchasing-manager" className="flex items-center gap-2">
+ <Users className="h-4 w-4" />
+ 구매기획 담당자
+ </Label>
+ <UserSelector
+ selectedUsers={purchasingManager}
+ onUsersChange={setPurchasingManager}
+ singleSelect={true}
+ placeholder="구매기획 담당자를 검색하세요..."
+ domainFilter={{ type: "exclude", domains: ["partners"] }}
+ closeOnSelect={true}
+ />
+ <p className="text-xs text-muted-foreground">
+ 레드플래그 발생 시 알림을 받을 구매기획 담당자를 지정합니다.
+ </p>
+ </div>
- {/* 준법 담당자 */}
- <div className="space-y-2">
- <Label htmlFor="compliance-manager" className="flex items-center gap-2">
- <Users className="h-4 w-4" />
- 준법 담당자
- </Label>
- <UserSelector
- selectedUsers={complianceManager}
- onUsersChange={setComplianceManager}
- singleSelect={true}
- placeholder="준법 담당자를 검색하세요..."
- domainFilter={{ type: "exclude", domains: ["partners"] }}
- closeOnSelect={true}
- />
- <p className="text-xs text-muted-foreground">
- 레드플래그 발생 시 알림을 받을 준법 담당자를 지정합니다.
- </p>
- </div>
+ {/* 준법 담당자 */}
+ <div className="space-y-2">
+ <Label htmlFor="compliance-manager" className="flex items-center gap-2">
+ <Users className="h-4 w-4" />
+ 준법 담당자
+ </Label>
+ <UserSelector
+ selectedUsers={complianceManager}
+ onUsersChange={setComplianceManager}
+ singleSelect={true}
+ placeholder="준법 담당자를 검색하세요..."
+ domainFilter={{ type: "exclude", domains: ["partners"] }}
+ closeOnSelect={true}
+ />
+ <p className="text-xs text-muted-foreground">
+ 레드플래그 발생 시 알림을 받을 준법 담당자를 지정합니다.
+ </p>
+ </div>
+ </>
+ )}
+
+ {mode === "hse" && (
+ <div className="space-y-2">
+ <Label htmlFor="hse-manager" className="flex items-center gap-2">
+ <Users className="h-4 w-4" />
+ 안전(HSE) 담당자
+ </Label>
+ <UserSelector
+ selectedUsers={hseManager}
+ onUsersChange={setHseManager}
+ singleSelect={true}
+ placeholder="안전(HSE) 담당자를 검색하세요..."
+ domainFilter={{ type: "exclude", domains: ["partners"] }}
+ closeOnSelect={true}
+ />
+ <p className="text-xs text-muted-foreground">
+ PQ 제출 및 안전 관련 알림을 받을 담당자를 지정합니다.
+ </p>
+ </div>
+ )}
</div>
)}