[as] feat: 파일 양식 다운로드 API 수정

This commit is contained in:
2026-08-31 17:18:39 +09:00
parent fb12eadf65
commit 8fd1d59fe2
3 changed files with 32 additions and 48 deletions
@@ -4,14 +4,14 @@ import { useEffect, useRef, useState } from "react";
import { Controller, useFormContext } from "react-hook-form";
import { useQueryClient } from "@tanstack/react-query";
import { Paperclip, X } from "lucide-react";
import { Download, Paperclip, X } from "lucide-react";
import { ENDPOINT } from "@/shared/config";
import { useTus } from "@/shared/lib";
import type { AtflMngClientResponseDto, EsntlAtchFileMngTreeResponseDto } from "@/shared/model";
import { TextShimmer } from "@/shared/ui";
import { SectionCollapsible } from "@/shared/ui";
import { attachService, useDownloadAttachmentByAtflId } from "@/entities/attach";
import { attachService, useDownloadAttachmentByAtflCd } from "@/entities/attach";
import { useEsntlAtchFileMngTree } from "@/entities/esntl";
import {
Button,
@@ -212,7 +212,7 @@ function AttachmentsFormSection({
const { data: essentialFiles = [], isPending: isLoadingEssentialFiles } = useEsntlAtchFileMngTree(
{ docSeComCd },
);
const { mutate: downloadTemplate } = useDownloadAttachmentByAtflId();
const { mutate: downloadTemplate } = useDownloadAttachmentByAtflCd();
async function invalidateAttachmentQueries() {
await queryClient.invalidateQueries({
@@ -376,10 +376,9 @@ function AttachmentsFormSection({
<h3 className="mb-4 text-xl font-semibold">필수 첨부파일</h3>
<Table variant="secondary" className="table-fixed">
<colgroup>
<col width="30%" />
<col width="44%" />
<col width="12%" />
<col width="23%" />
<col width="35%" />
<col width="44%" />
</colgroup>
<TableHeader>
<TableRow>
@@ -387,7 +386,6 @@ function AttachmentsFormSection({
파일명
</TableHead>
<TableHead>파일 확장자</TableHead>
<TableHead align="left">파일 양식</TableHead>
<TableHead>파일첨부</TableHead>
</TableRow>
</TableHeader>
@@ -400,36 +398,30 @@ function AttachmentsFormSection({
</TableRow>
) : (
essentialFiles.map((file) => {
const templateFiles = file.templateAtchFileList ?? [];
const atflCd = file.atchFileGroupId ?? "";
return (
<TableRow key={file.esntlAtchFileId}>
<TableHead
className="break-keep font-medium"
className="group break-keep font-medium"
data-required={file.esntlAtchYn === "Y"}
align="left"
>
{file.esntlAtchFileNm}
<div className="inline-flex w-[calc(100%-1rem)] items-center justify-between gap-10">
{file.esntlAtchFileNm}
{atflCd ? (
<Button
size="sm"
color="white"
onClick={() => downloadTemplate(atflCd)}
>
<Download className="!size-5 shrink-0" />
양식내려받기
</Button>
) : null}
</div>
</TableHead>
<TableCell align="center">{file.esntlAtchFileRmrk}</TableCell>
<TableCell align="left">
{templateFiles.length === 0 ? (
<span className="text-muted-foreground">-</span>
) : (
<div className="space-y-1">
{templateFiles.map((templateFile) => (
<a
key={templateFile.atflId}
className="flex cursor-pointer items-center gap-1 text-blue-600 hover:underline"
onClick={() => downloadTemplate(templateFile.atflId)}
>
<Paperclip className="size-4 shrink-0" />
{templateFile.orgnlFileNm || "다운로드"}
</a>
))}
</div>
)}
</TableCell>
<TableCell className="space-y-2">
{uploadedFiles[file.esntlAtchFileId]?.length > 0 && (
<div className="flex flex-wrap gap-2">