chore: attachment 인터페이스 수정
This commit is contained in:
@@ -26,10 +26,6 @@ export class AttachmentApiService implements AttachmentService {
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async deleteAttachment(atflId: string): Promise<void> {
|
||||
await client.delete(`${ENDPOINT.ATTACH_SERVICE.ATTACHMENTS}/${atflId}`);
|
||||
}
|
||||
|
||||
public async deleteAttachmentByAtflId(atflId: string): Promise<void> {
|
||||
await client.delete(`${ENDPOINT.ATTACH_SERVICE.ATTACHMENTS}/${atflId}`);
|
||||
}
|
||||
@@ -40,7 +36,7 @@ export class AttachmentApiService implements AttachmentService {
|
||||
);
|
||||
}
|
||||
|
||||
public async getImageUrl(atflId: string): Promise<string> {
|
||||
public async getImageUrlByAtflId(atflId: string): Promise<string> {
|
||||
if (!atflId) return "";
|
||||
const response = await fetch(`${ENDPOINT.ATTACH_SERVICE.IMAGES}/${atflId}`);
|
||||
const blob = await response.blob();
|
||||
|
||||
@@ -36,10 +36,9 @@ export type AttachmentList = PageableList<Attachment>;
|
||||
export interface AttachmentService {
|
||||
getAttachmentsList: (params: AttachmentParams) => Promise<AttachmentList>;
|
||||
getAttachmentsInfo: (atflCd: string) => Promise<Attachment[]>;
|
||||
deleteAttachment: (atflId: string) => Promise<void>;
|
||||
deleteAttachmentByAtflId: (atflId: string) => Promise<void>;
|
||||
deleteAttachmentByAtflCd: (atflCd: string) => Promise<void>;
|
||||
getImageUrl: (atflId: string) => Promise<string>;
|
||||
getImageUrlByAtflId: (atflId: string) => Promise<string>;
|
||||
getImageUrlByAtflCd: (atflCd: string) => Promise<string>;
|
||||
getMovieThumbnailUrl: (atflId: string) => Promise<string>;
|
||||
downloadAttachmentByAtflCd: (atflCd: string) => Promise<AxiosResponse>;
|
||||
|
||||
@@ -59,7 +59,7 @@ function BannerForm({ form, bnrSn, ...props }: BannerFormProps) {
|
||||
|
||||
const { atflCd, atflId } = JSON.parse(fileInfo) ?? {};
|
||||
if (atflCd) form.setValue("atflCd", atflCd);
|
||||
if (atflId) setImageUrl(await AttachmentApi.getImageUrl(atflId));
|
||||
if (atflId) setImageUrl(await AttachmentApi.getImageUrlByAtflId(atflId));
|
||||
if (attachmentData)
|
||||
await AttachmentApi.deleteAttachmentByAtflCd(attachmentData.atflCd);
|
||||
};
|
||||
@@ -68,7 +68,9 @@ function BannerForm({ form, bnrSn, ...props }: BannerFormProps) {
|
||||
if (!attachmentData) return;
|
||||
|
||||
(async () => {
|
||||
setImageUrl(await AttachmentApi.getImageUrl(attachmentData.atflId));
|
||||
setImageUrl(
|
||||
await AttachmentApi.getImageUrlByAtflId(attachmentData.atflId),
|
||||
);
|
||||
})();
|
||||
}, [attachmentData]);
|
||||
|
||||
|
||||
@@ -39,7 +39,8 @@ function FilePage() {
|
||||
});
|
||||
|
||||
const { mutate: deleteAttachment } = useMutation({
|
||||
mutationFn: (atflId: string) => AttachmentApi.deleteAttachment(atflId),
|
||||
mutationFn: (atflId: string) =>
|
||||
AttachmentApi.deleteAttachmentByAtflId(atflId),
|
||||
onSuccess: () => {
|
||||
refetch();
|
||||
alert("삭제되었습니다.");
|
||||
|
||||
@@ -60,7 +60,7 @@ function ImageForm({ form, imgSn, ...props }: ImageFormProps) {
|
||||
|
||||
const { atflCd, atflId } = JSON.parse(fileInfo) ?? {};
|
||||
if (atflCd) form.setValue("atflCd", atflCd);
|
||||
if (atflId) setImageUrl(await AttachmentApi.getImageUrl(atflId));
|
||||
if (atflId) setImageUrl(await AttachmentApi.getImageUrlByAtflId(atflId));
|
||||
if (attachmentData)
|
||||
await AttachmentApi.deleteAttachmentByAtflCd(attachmentData.atflCd);
|
||||
};
|
||||
|
||||
@@ -48,22 +48,17 @@ export const createColumns = (
|
||||
{
|
||||
id: "atflCd",
|
||||
cell: ({ row }) => {
|
||||
const atflCd = row.original.atflCd;
|
||||
return (
|
||||
<ThumbImage
|
||||
atflCd={atflCd}
|
||||
pstNo={row.original.pstNo}
|
||||
thumbRefs={thumbRefs}
|
||||
/>
|
||||
);
|
||||
const { atflCd, pstNo } = row.original;
|
||||
return <ThumbImage atflCd={atflCd} pstNo={pstNo} thumbRefs={thumbRefs} />;
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "rgtrNm",
|
||||
cell: ({ row }) => {
|
||||
const { rgtrNm } = row.original;
|
||||
return (
|
||||
<span className="text-[1.4rem] font-bold text-label">{rgtrNm}</span>
|
||||
<span className="text-[1.4rem] font-bold text-label">
|
||||
{row.original.rgtrNm}
|
||||
</span>
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -47,7 +47,7 @@ function WithPreviewFileUploader<T extends PostFormData | PostUpdateFormData>({
|
||||
if (atflId) {
|
||||
let imageUrl = "";
|
||||
if (bbsInfo?.bbsTypeCd === "BBSIMAGE") {
|
||||
imageUrl = await AttachmentApi.getImageUrl(atflId);
|
||||
imageUrl = await AttachmentApi.getImageUrlByAtflId(atflId);
|
||||
}
|
||||
if (bbsInfo?.bbsTypeCd === "BBSMOVIE") {
|
||||
imageUrl = await AttachmentApi.getMovieThumbnailUrl(atflId);
|
||||
@@ -85,7 +85,7 @@ function WithPreviewFileUploader<T extends PostFormData | PostUpdateFormData>({
|
||||
useEffect(() => {
|
||||
if (!attachmentData || attachmentData.length === 0) return;
|
||||
(async () => {
|
||||
const imageUrl = await AttachmentApi.getImageUrl(
|
||||
const imageUrl = await AttachmentApi.getImageUrlByAtflId(
|
||||
attachmentData[0]?.atflId as string,
|
||||
);
|
||||
setThumbnailUrl(imageUrl);
|
||||
@@ -95,7 +95,7 @@ function WithPreviewFileUploader<T extends PostFormData | PostUpdateFormData>({
|
||||
return (
|
||||
<FileUploader
|
||||
id="atflCd"
|
||||
className="!h-auto !max-w-none flex-col !items-start gap-4"
|
||||
className="!h-auto !max-w-none flex-col !items-start gap-4 [&_.file-uploader-label]:h-[3.2rem]"
|
||||
accept={fileAccept(bbsInfo?.bbsTypeCd as BbsType)}
|
||||
onUpload={onUpload}
|
||||
customPreview={
|
||||
|
||||
Reference in New Issue
Block a user