260702_01_ENH: 리스트 작업 도중 공용 ui를 적용하기 위한 중간 커밋

This commit is contained in:
2026-07-02 17:02:17 +09:00
parent 6944064377
commit a8ce35f5bf
111 changed files with 2833 additions and 2557 deletions

View File

@@ -1,4 +1,4 @@
'use client'
'use client'
import { useState, useEffect } from 'react'
import {
@@ -18,16 +18,16 @@ import { UserInfoSaveRequest } from '@/types/user'
import KriPassword from "@/components/common/KriPassword";
import {KriSelect, KriSelectItem} from "@/components/common/KriSelect";
import {DataVerification} from "@/types/common";
import {apiError} from "@/lib/http-util";
import {apiError} from "@kri/common/http";
import {KriSingleSelect} from "@/components/common/KriAutoComplete";
import {FW_TEAM, USER_NAME_REGEX} from "@/const/userConst";
import {NONE_HTTP_ERROR, UNKNOWN_HTTP_ERROR} from "@/const/commonConst";
import {NONE_HTTP_ERROR, UNKNOWN_HTTP_ERROR} from "@kri/common/http";
export type UserUpsertDialogProps = {
/** Jotai로 관리할 다이얼로그 ID (기본값: 'userUpsertDialog') */
/** Jotai로 관리할 다이얼로그 ID */
dialogId?: DialogId
/** 필요하면 여전히 외부에서 open 제어도 가능하게 */
/** 필요한 경우 부모에서 직접 open 제어 */
open?: boolean
onOpenChange?: (open: boolean) => void
@@ -71,15 +71,13 @@ const UserUpsertDialog = ({
const [isCheckedDuplicate, setIsCheckedDuplicate] = useState(false);
const [isSubmitting, setIsSubmitting] = useState(false);
// 🔹 실제로 Dialog에 넘길 open 값 (외부 open 있으면 우선)
// 실제 Dialog에 전달할 open 값
const resolvedOpen = open ?? isDialogOpen(dialogId);
// 🔹 실제 onOpenChange 핸들러 (외부 콜백 + jotai 둘 다 처리)
// 부모 콜백과 jotai 상태를 함께 처리
const handleOpenChange = (nextOpen: boolean) => {
// 1) 외부에서 넘겨준 onOpenChange 먼저 호출
onOpenChange?.(nextOpen);
// 2) jotai 전역 상태도 함께 업데이트
if (nextOpen) {
showDialog(dialogId);
} else {
@@ -117,7 +115,7 @@ const UserUpsertDialog = ({
const handleCheckDuplicate = async () => {
if (!formData.userId.trim()) {
alert('아이디를 입력해주세요.');
alert("아이디를 입력해주세요.");
return
}
@@ -127,7 +125,7 @@ const UserUpsertDialog = ({
alert(isDuplicate.errMessage);
setIsCheckedDuplicate(false);
} else {
alert('사용 가능한 아이디입니다.');
alert("사용 가능한 아이디입니다.");
setIsCheckedDuplicate(true);
}
} else {
@@ -137,23 +135,23 @@ const UserUpsertDialog = ({
const handleSubmit = async () => {
if (!formData.userId.trim()) {
alert('아이디를 입력해주세요.');
alert("아이디를 입력해주세요.");
return;
}
if (mode === 'create' && !isCheckedDuplicate) {
alert('아이디 중복체크를 해주세요.');
alert("아이디 중복체크를 해주세요.");
return;
}
if (!formData.userPw.trim()) {
alert('비밀번호를 입력해주세요.');
alert("비밀번호를 입력해주세요.");
return;
}
if (!formData.userName.trim()) {
alert('이름을 입력해주세요.');
alert("이름을 입력해주세요.");
return;
}
if(!USER_NAME_REGEX.test(formData.userName)){
alert('올바르지 않은 이름입니다.');
alert("올바르지 않은 이름입니다.");
return;
}
@@ -165,13 +163,15 @@ const UserUpsertDialog = ({
await onSubmit(formData as UserInfoSaveRequest);
handleOpenChange(false);
} catch (e) {
const err = apiError(e);
const err = apiError(e, {
fallbackMessage: "Save failed.",
});
console.error(err.status, err.code, err.message);
if(err.code !== NONE_HTTP_ERROR && err.code !== UNKNOWN_HTTP_ERROR){
alert(err.message);
}
else{
alert('저장에 실패했습니다.');
alert("저장에 실패했습니다.");
}
} finally {
setIsSubmitting(false);
@@ -180,9 +180,9 @@ const UserUpsertDialog = ({
return (
<Dialog open={resolvedOpen} onOpenChange={handleOpenChange}>
<DialogContent className="sm:max-w-[500px] content-text-sm">
<DialogContent className="sm:max-w-[500px] text-sm">
<DialogHeader>
<DialogTitle className="content-text-sxl">
<DialogTitle className="text-xl">
{mode === 'create' ? '계정 등록' : '계정 수정'}
</DialogTitle>
<DialogDescription>면접원 계정 정보를 입력해주세요.</DialogDescription>
@@ -195,7 +195,7 @@ const UserUpsertDialog = ({
<div className="flex gap-2">
<Input
id="userId"
placeholder="아이디를 입력하세요"
placeholder="Enter ID"
value={formData.userId}
onChange={(e) => handleInputChange('userId', e.target.value)}
disabled={mode === 'edit'}
@@ -206,7 +206,7 @@ const UserUpsertDialog = ({
onClick={handleCheckDuplicate}
disabled={!formData.userId.trim() || isCheckedDuplicate}
>
{isCheckedDuplicate ? '확인완료' : '중복체크'}
{isCheckedDuplicate ? "확인완료" : "중복체크"}
</Button>
)}
</div>
@@ -219,7 +219,7 @@ const UserUpsertDialog = ({
id="password"
value={formData.userPw}
onChange={(v) => handleInputChange('userPw', v)}
placeholder="비밀번호를 입력하세요"
placeholder="Enter password"
/>
</div>
<div className="grid gap-2">
@@ -228,7 +228,7 @@ const UserUpsertDialog = ({
</Label>
<Input
id="userName"
placeholder="이름을 입력하세요"
placeholder="Enter name"
value={formData.userName}
onChange={(e) => handleInputChange('userName', e.target.value)}
/>
@@ -240,7 +240,7 @@ const UserUpsertDialog = ({
value={String(formData.userRole)}
onChange={(e) => {
if(mode !== 'create'){
alert("권한이 변경되면 해당 계정에 배정된 리스트 정보가 초기화 됩니다.");
alert("권한이 변경되면 해당 계정에 배정된 리스트 정보가 초기화됩니다.");
}
handleInputChange('userRole', Number(e));
@@ -267,7 +267,7 @@ const UserUpsertDialog = ({
:
<Input
id="userCmpn"
placeholder="소속 회사를 입력하세요"
placeholder="Enter company"
value={formData.userCmpn}
disabled={!isInternal}
onChange={(e) => handleInputChange('userCmpn', e.target.value)}
@@ -279,7 +279,7 @@ const UserUpsertDialog = ({
<Label htmlFor="memo">메모</Label>
<textarea id="memo" className="flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
rows={3}
placeholder="메모를 입력하세요"
placeholder="Enter memo"
value={formData.memo}
onChange={(e) => handleInputChange('memo', e.target.value)}
/>
@@ -298,7 +298,7 @@ const UserUpsertDialog = ({
onClick={handleSubmit}
disabled={isSubmitting}
>
{mode === 'create' ? '등록' : '수정'}
{mode === 'create' ? "등록" : "수정"}
</Button>
</DialogFooter>
</DialogContent>
@@ -306,4 +306,4 @@ const UserUpsertDialog = ({
)
}
export default UserUpsertDialog
export default UserUpsertDialog