260714_01_ENH: 테스트 서버에서 기동 후 중간 테스트를 위한 커밋
This commit is contained in:
@@ -1,27 +1,20 @@
|
||||
'use client'
|
||||
|
||||
import { useState, useEffect } from 'react'
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog'
|
||||
import { KriDialog } from '@/components/common/KriDialog'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import { Label } from '@/components/ui/label'
|
||||
import { useDialog } from '@/hooks/useDialog'
|
||||
import type { DialogId } from '@/store/jotai/dialog'
|
||||
import { UserInfoSaveRequest } from '@/types/user'
|
||||
import KriPassword from "@/components/common/KriPassword";
|
||||
import KriPassword, { KRI_PW_REGEX } from "@/components/common/KriPassword";
|
||||
import {KriSelect, KriSelectItem} from "@/components/common/KriSelect";
|
||||
import {DataVerification} from "@/types/common";
|
||||
import type { DataVerification } from "@kri/common";
|
||||
import {apiError} from "@kri/common/http";
|
||||
import {KriSingleSelect} from "@/components/common/KriAutoComplete";
|
||||
import {FW_TEAM, USER_NAME_REGEX} from "@/const/userConst";
|
||||
import {CONTACT_INTERVIEWER_ROLE, FW_TEAM, USER_NAME_REGEX} from "@/const/userConst";
|
||||
import {NONE_HTTP_ERROR, UNKNOWN_HTTP_ERROR} from "@kri/common/http";
|
||||
import type { CmpnInfo } from "@/types/cmpn";
|
||||
|
||||
export type UserUpsertDialogProps = {
|
||||
/** Jotai로 관리할 다이얼로그 ID */
|
||||
@@ -35,7 +28,7 @@ export type UserUpsertDialogProps = {
|
||||
initialData?: Partial<UserInfoSaveRequest>
|
||||
isInternal: boolean
|
||||
userCmpn: string
|
||||
userCmpnArray: string[]
|
||||
userCmpnArray: CmpnInfo[]
|
||||
userRoleArray: KriSelectItem[]
|
||||
onSubmit: (data: UserInfoSaveRequest) => void | Promise<void>
|
||||
onCheckDuplicate?: (userId: string) => DataVerification | Promise<DataVerification>
|
||||
@@ -47,7 +40,6 @@ const UserUpsertDialog = ({
|
||||
onOpenChange,
|
||||
mode = 'create',
|
||||
initialData,
|
||||
isInternal,
|
||||
userCmpn,
|
||||
userCmpnArray,
|
||||
userRoleArray,
|
||||
@@ -60,7 +52,7 @@ const UserUpsertDialog = ({
|
||||
userName: '',
|
||||
userCmpn: userCmpn,
|
||||
userTeam: '',
|
||||
userRole: 9002,
|
||||
userRole: CONTACT_INTERVIEWER_ROLE,
|
||||
memo: '',
|
||||
}
|
||||
|
||||
@@ -102,7 +94,7 @@ const UserUpsertDialog = ({
|
||||
}
|
||||
}, [initialData, mode, resolvedOpen])
|
||||
|
||||
const handleInputChange = (field: keyof UserInfoSaveRequest, value: any) => {
|
||||
const handleInputChange = <K extends keyof UserInfoSaveRequest>(field: K, value: UserInfoSaveRequest[K]) => {
|
||||
setFormData(prev => ({
|
||||
...prev,
|
||||
[field]: value,
|
||||
@@ -146,6 +138,10 @@ const UserUpsertDialog = ({
|
||||
alert("비밀번호를 입력해주세요.");
|
||||
return;
|
||||
}
|
||||
if (!KRI_PW_REGEX.test(formData.userPw)) {
|
||||
alert("비밀번호는 영문과 숫자를 포함한 8~20자로 입력해주세요.");
|
||||
return;
|
||||
}
|
||||
if (!formData.userName.trim()) {
|
||||
alert("이름을 입력해주세요.");
|
||||
return;
|
||||
@@ -179,15 +175,32 @@ const UserUpsertDialog = ({
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={resolvedOpen} onOpenChange={handleOpenChange}>
|
||||
<DialogContent className="sm:max-w-[500px] text-sm">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="text-xl">
|
||||
{mode === 'create' ? '계정 등록' : '계정 수정'}
|
||||
</DialogTitle>
|
||||
<DialogDescription>면접원 계정 정보를 입력해주세요.</DialogDescription>
|
||||
</DialogHeader>
|
||||
<div className="grid gap-4 py-4">
|
||||
<KriDialog
|
||||
open={resolvedOpen}
|
||||
onOpenChange={handleOpenChange}
|
||||
title={<span className="text-xl">{mode === 'create' ? '계정 등록' : '계정 수정'}</span>}
|
||||
description="면접원 계정 정보를 입력해주세요."
|
||||
contentClassName="sm:max-w-[500px] text-sm"
|
||||
bodyClassName="grid gap-4 py-4"
|
||||
footer={
|
||||
<>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={() => handleOpenChange(false)}
|
||||
>
|
||||
취소
|
||||
</Button>
|
||||
<Button
|
||||
type="submit"
|
||||
onClick={handleSubmit}
|
||||
disabled={isSubmitting}
|
||||
>
|
||||
{mode === 'create' ? "등록" : "수정"}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="userId">
|
||||
ID<span className="text-red-500 ml-1">*</span>
|
||||
@@ -217,6 +230,7 @@ const UserUpsertDialog = ({
|
||||
</Label>
|
||||
<KriPassword
|
||||
id="password"
|
||||
label=""
|
||||
value={formData.userPw}
|
||||
onChange={(v) => handleInputChange('userPw', v)}
|
||||
placeholder="Enter password"
|
||||
@@ -235,45 +249,35 @@ const UserUpsertDialog = ({
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label>계정 권한</Label>
|
||||
<KriSingleSelect
|
||||
<KriSelect
|
||||
items={userRoleArray}
|
||||
value={String(formData.userRole)}
|
||||
getLabel={(item) => item.label}
|
||||
getValue={(item) => String(item.value)}
|
||||
onChange={(e) => {
|
||||
if(mode !== 'create'){
|
||||
alert("권한이 변경되면 해당 계정에 배정된 리스트 정보가 초기화됩니다.");
|
||||
}
|
||||
|
||||
handleInputChange('userRole', Number(e));
|
||||
}}
|
||||
getLabel={(item) => item.label}
|
||||
getValue={(item) => String(item.value)}
|
||||
placeholder="사용자 권한"
|
||||
widthClassName="w-full"
|
||||
heightClassName="h-9"
|
||||
useAll={false}
|
||||
className="w-full min-w-0 overflow-hidden [&>span]:truncate"
|
||||
heightClassName="h-8"
|
||||
/>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label>소속 회사</Label>
|
||||
{
|
||||
isInternal && formData.userRole > 9000 ?
|
||||
<KriSingleSelect
|
||||
items={userCmpnArray}
|
||||
value={formData.userCmpn}
|
||||
onChange={(e) => handleInputChange('userCmpn', e)}
|
||||
placeholder="소속 회사"
|
||||
widthClassName="w-full"
|
||||
heightClassName="h-9"
|
||||
/>
|
||||
:
|
||||
<Input
|
||||
id="userCmpn"
|
||||
placeholder="Enter company"
|
||||
value={formData.userCmpn}
|
||||
disabled={!isInternal}
|
||||
onChange={(e) => handleInputChange('userCmpn', e.target.value)}
|
||||
/>
|
||||
}
|
||||
|
||||
<KriSelect
|
||||
items={userCmpnArray}
|
||||
value={formData.userCmpn}
|
||||
getValue={(item) => item.cmpnId}
|
||||
getLabel={(item) => item.cmpnAlias || item.cmpnId}
|
||||
onChange={(e) => handleInputChange('userCmpn', e)}
|
||||
useAll={false}
|
||||
disabled={mode !== 'create'}
|
||||
className="w-full min-w-0 overflow-hidden [&>span]:truncate"
|
||||
heightClassName="h-9"
|
||||
/>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="memo">메모</Label>
|
||||
@@ -284,25 +288,7 @@ const UserUpsertDialog = ({
|
||||
onChange={(e) => handleInputChange('memo', e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={() => handleOpenChange(false)}
|
||||
>
|
||||
취소
|
||||
</Button>
|
||||
<Button
|
||||
type="submit"
|
||||
onClick={handleSubmit}
|
||||
disabled={isSubmitting}
|
||||
>
|
||||
{mode === 'create' ? "등록" : "수정"}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</KriDialog>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user