"use client"; import {useEffect, useState} from "react"; import {Download, FileUp} from "lucide-react"; import {Button} from "@/components/ui/button"; import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; import {ExcelUploadResult} from "@/types/common"; import {downloadBase64File} from "@/lib/utils"; export function ExcelRegisterDialog({ open, onOpenChange, title, notice, onDownloadTemplate, onUpload, isUploading, }: Readonly<{ open: boolean; onOpenChange: (open: boolean) => void; title: string; notice?: string; onDownloadTemplate: () => void; onUpload: (file: File) => Promise; isUploading?: boolean; }>) { const [file, setFile] = useState(null); const [uploadResult, setUploadResult] = useState(null); useEffect(() => { if (!open) { setFile(null); setUploadResult(null); } }, [open]); const upload = async () => { if (!file) return; const result = await onUpload(file); setUploadResult(result); }; const downloadErrorFile = () => { if (!uploadResult?.errorFileBase64) return; downloadBase64File(uploadResult.errorFileBase64, uploadResult.errorFileName || "excel_upload_error.xlsx"); }; return ( {title}
{notice &&

* {notice}

} {uploadResult && (
전체: {uploadResult.totalCount}
성공: {uploadResult.successCount}
실패: {uploadResult.failCount}
{uploadResult.hasErrorFile && ( )}
)}
); }