Fix: 이미지 업로드 완료 후 x 버튼 클릭 시 refetch 안되는 현상 수정, refetch 시점 변경 - S11P21S002-243

This commit is contained in:
홍창기 2024-09-30 12:41:58 +09:00
parent c91ccf42c0
commit 9979bb26f6
5 changed files with 21 additions and 6 deletions

View File

@ -7,11 +7,13 @@ import useUploadImageFileQuery from '@/queries/projects/useUploadImageFileQuery'
export default function ImageUploadFileForm({ export default function ImageUploadFileForm({
onClose, onClose,
onRefetch,
onFileCount, onFileCount,
projectId, projectId,
folderId, folderId,
}: { }: {
onClose: () => void; onClose: () => void;
onRefetch: () => void;
onFileCount: (fileCount: number) => void; onFileCount: (fileCount: number) => void;
projectId: number; projectId: number;
folderId: number; folderId: number;
@ -80,6 +82,7 @@ export default function ImageUploadFileForm({
}, },
{ {
onSuccess: () => { onSuccess: () => {
onRefetch();
setIsUploaded(true); setIsUploaded(true);
}, },
onError: () => { onError: () => {

View File

@ -7,10 +7,12 @@ import useUploadImageFolderQuery from '@/queries/projects/useUploadImageFolderQu
export default function ImageUploadFolderForm({ export default function ImageUploadFolderForm({
onClose, onClose,
onRefetch,
projectId, projectId,
folderId, folderId,
}: { }: {
onClose: () => void; onClose: () => void;
onRefetch: () => void;
projectId: number; projectId: number;
folderId: number; folderId: number;
}) { }) {
@ -73,6 +75,7 @@ export default function ImageUploadFolderForm({
}, },
{ {
onSuccess: () => { onSuccess: () => {
onRefetch;
setIsUploaded(true); setIsUploaded(true);
}, },
onError: () => { onError: () => {

View File

@ -7,10 +7,12 @@ import useUploadImageZipQuery from '@/queries/projects/useUploadImageZipQuery';
export default function ImageUploadZipForm({ export default function ImageUploadZipForm({
onClose, onClose,
onRefetch,
projectId, projectId,
folderId, folderId,
}: { }: {
onClose: () => void; onClose: () => void;
onRefetch: () => void;
projectId: number; projectId: number;
folderId: number; folderId: number;
}) { }) {
@ -74,6 +76,7 @@ export default function ImageUploadZipForm({
}, },
{ {
onSuccess: () => { onSuccess: () => {
onRefetch();
setIsUploaded(true); setIsUploaded(true);
}, },
onError: () => { onError: () => {

View File

@ -15,11 +15,11 @@ import ImageUploadZipForm from '../ImageUploadZipModal/ImageUploadZipForm';
export default function WorkspaceDropdownMenu({ export default function WorkspaceDropdownMenu({
projectId, projectId,
folderId, folderId,
refetch, onRefetch,
}: { }: {
projectId: number; projectId: number;
folderId: number; folderId: number;
refetch: () => void; onRefetch: () => void;
}) { }) {
const [isOpenUploadFile, setIsOpenUploadFile] = React.useState<boolean>(false); const [isOpenUploadFile, setIsOpenUploadFile] = React.useState<boolean>(false);
const [fileCount, setFileCount] = React.useState<number>(0); const [fileCount, setFileCount] = React.useState<number>(0);
@ -27,20 +27,23 @@ export default function WorkspaceDropdownMenu({
const [isOpenUploadZip, setIsOpenUploadZip] = React.useState<boolean>(false); const [isOpenUploadZip, setIsOpenUploadZip] = React.useState<boolean>(false);
const handleOpenUploadFile = () => setIsOpenUploadFile(true); const handleOpenUploadFile = () => setIsOpenUploadFile(true);
const handleCloseUploadFile = () => { const handleCloseUploadFile = () => {
refetch();
setIsOpenUploadFile(false); setIsOpenUploadFile(false);
}; };
const handleOpenUploadFolder = () => setIsOpenUploadFolder(true); const handleOpenUploadFolder = () => setIsOpenUploadFolder(true);
const handleCloseUploadFolder = () => { const handleCloseUploadFolder = () => {
refetch();
setIsOpenUploadFolder(false); setIsOpenUploadFolder(false);
}; };
const handleOpenUploadZip = () => setIsOpenUploadZip(true); const handleOpenUploadZip = () => setIsOpenUploadZip(true);
const handleCloseUploadZip = () => { const handleCloseUploadZip = () => {
refetch();
setIsOpenUploadZip(false); setIsOpenUploadZip(false);
}; };
const handleFileCount = (fileCount: number) => { const handleFileCount = (fileCount: number) => {
console.log(fileCount); console.log(fileCount);
setFileCount(fileCount); setFileCount(fileCount);
@ -79,6 +82,7 @@ export default function WorkspaceDropdownMenu({
<DialogHeader title={fileCount > 0 ? `파일 업로드 (${fileCount})` : '파일 업로드'} /> <DialogHeader title={fileCount > 0 ? `파일 업로드 (${fileCount})` : '파일 업로드'} />
<ImageUploadFileForm <ImageUploadFileForm
onClose={handleCloseUploadFile} onClose={handleCloseUploadFile}
onRefetch={onRefetch}
onFileCount={handleFileCount} onFileCount={handleFileCount}
projectId={projectId} projectId={projectId}
folderId={folderId} folderId={folderId}
@ -95,6 +99,7 @@ export default function WorkspaceDropdownMenu({
<DialogHeader title="폴더 업로드 (임시)" /> <DialogHeader title="폴더 업로드 (임시)" />
<ImageUploadFolderForm <ImageUploadFolderForm
onClose={handleCloseUploadFolder} onClose={handleCloseUploadFolder}
onRefetch={onRefetch}
projectId={projectId} projectId={projectId}
folderId={folderId} folderId={folderId}
/> />
@ -110,6 +115,7 @@ export default function WorkspaceDropdownMenu({
<DialogHeader title="폴더 압축파일 업로드" /> <DialogHeader title="폴더 압축파일 업로드" />
<ImageUploadZipForm <ImageUploadZipForm
onClose={handleCloseUploadZip} onClose={handleCloseUploadZip}
onRefetch={onRefetch}
projectId={projectId} projectId={projectId}
folderId={folderId} folderId={folderId}
/> />

View File

@ -40,7 +40,7 @@ export default function ProjectStructure({ project }: { project: Project }) {
<WorkspaceDropdownMenu <WorkspaceDropdownMenu
projectId={project.id} projectId={project.id}
folderId={0} folderId={0}
refetch={refetch} onRefetch={refetch}
/> />
</header> </header>
{folderData.children.length === 0 && folderData.images.length === 0 ? ( {folderData.children.length === 0 && folderData.images.length === 0 ? (