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 {
Dialog,
@@ -12,13 +12,13 @@ import { useState, useRef } from 'react'
import {Download, Upload, X} from 'lucide-react'
import { useDialog } from '@/hooks/useDialog'
import type { DialogId } from '@/store/jotai/dialog'
import {apiError} from "@/lib/http-util";
import {apiError} from "@kri/common/http";
export type UserUploadDialogProps = {
/** jotai로 관리할 dialog id (기본값: 'userUploadDialog') */
/** jotai로 관리할 dialog id */
dialogId?: DialogId
/** 필요하면 부모에서 직접 제어도 가능 */
/** 필요한 경우 부모에서 직접 제어 */
open?: boolean
onOpenChange?: (open: boolean) => void
@@ -39,15 +39,13 @@ const UserUploadDialog = ({
const [selectedFile, setSelectedFile] = useState<File | null>(null);
const fileInputRef = useRef<HTMLInputElement>(null);
//실제 Dialog에 넘길 open값 (props 우선, 없으면 jotai 사용)
// 실제 Dialog에 전달할 open 값
const resolvedOpen = open ?? isDialogOpen(dialogId);
// open change 공통 처리 (부모 콜백 + jotai 동시 반영)
// 부모 콜백과 jotai 상태를 함께 처리
const handleOpenChange = (nextOpen: boolean) => {
// 1) 부모 콜백 먼저
onOpenChange?.(nextOpen)
// 2) jotai 상태 업데이트
if (nextOpen) {
showDialog(dialogId)
} else {
@@ -72,7 +70,7 @@ const UserUploadDialog = ({
) {
setSelectedFile(file)
} else {
alert('엑셀 파일만 업로드 가능합니다. (.xlsx, .xls, .csv)')
alert("엑셀 파일만 업로드 가능합니다. (.xlsx, .xls, .csv)")
}
}
}
@@ -100,7 +98,9 @@ const UserUploadDialog = ({
handleRemoveFile();
handleOpenChange(false);
} catch (e) {
const err = apiError(e);
const err = apiError(e, {
fallbackMessage: "File upload failed.",
});
console.error(err.status, err.code, err.message);
alert("업로드에 실패했습니다.");
} finally {
@@ -108,7 +108,7 @@ const UserUploadDialog = ({
}
};
// ✅ Dialog에서 닫힐 때: 파일도 초기화 + 상태 닫기
// Dialog가 닫힐 때 파일 선택 상태 초기화
const handleDialogOpenChange = (nextOpen: boolean) => {
if (!nextOpen) {
handleRemoveFile()
@@ -120,7 +120,7 @@ const UserUploadDialog = ({
<Dialog open={resolvedOpen} onOpenChange={handleDialogOpenChange}>
<DialogContent className="sm:max-w-[600px]">
<DialogHeader>
<DialogTitle className=" content-text-2xl font-bold">엑셀 업로드</DialogTitle>
<DialogTitle className=" text-2xl font-bold">User upload</DialogTitle>
</DialogHeader>
<div className="space-y-6 py-4">
@@ -129,7 +129,7 @@ const UserUploadDialog = ({
<Button
type="button"
variant="default"
className="content-text-lg bg-excel"
className="text-lg bg-excel"
onClick={onDownloadTemplate}
>
<Download className="w-4 h-4 mr-2" />
@@ -138,11 +138,11 @@ const UserUploadDialog = ({
<Button
type="button"
variant="outline"
className="flex-1 content-text-lg w-full"
className="flex-1 text-lg w-full"
onClick={handleUploadClick}
>
<Upload className="w-4 h-4 mr-2" />
{selectedFile ? selectedFile.name : '선택된 파일 없음'}
{selectedFile ? selectedFile.name : "선택된 파일 없음"}
</Button>
<div className="w-9 h-8">
{selectedFile && (