Skip to content

Commit

Permalink
feat :: 파일업로드 API 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
KANGYONGSU23 committed Dec 27, 2023
1 parent 5b490a5 commit 1d92cfc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 34 deletions.
29 changes: 1 addition & 28 deletions src/apis/file/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,10 @@ import { useMutation } from "@tanstack/react-query";
import { useToastStore } from "@team-return/design-system";
import axios, { AxiosError } from "axios";
import { instance } from "../axios";
import { PresignedURLResponse, UploadFileResponse } from "./type";
import { PresignedURLResponse } from "./type";

const router = "/files";

export const useFileUpload = () => {
const { append } = useToastStore();
return useMutation(
async (files: File[]) => {
const formData = new FormData();
files.map((file) => {
formData.append("file", file);
});
const { data }: { data: UploadFileResponse } = await instance.post(
`${router}?type=EXTENSION_FILE`,
formData
);
return data;
},
{
onError: (error: AxiosError) => {
if (error.response)
append({
title: "",
message: "파일 업로드에 실패했습니다.",
type: "RED",
});
},
}
);
};

export const useCreatePresignedURL = () => {
const { append } = useToastStore();
return useMutation(
Expand Down
4 changes: 0 additions & 4 deletions src/apis/file/type.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export interface UploadFileResponse {
urls: string[];
}

export interface PresignedURLResponse {
urls: ResignedURLResponseItem[];
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/recruitments/apply/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import { useApplyToCompany, useReapply } from "@/apis/applications";
import {
ApplyRequestItmeType,
AttachmentsType,
AttachmentsType
} from "@/apis/applications/type";
import { useCreatePresignedURL, useFileUpload } from "@/apis/file";
import { useCreatePresignedURL } from "@/apis/file";
import { useGetRecruitmentsDetail } from "@/apis/recruitments";
import GhostBtn from "@/components/common/Button/GhostBtn";
import Loading from "@/components/common/Loading";
Expand Down

0 comments on commit 1d92cfc

Please sign in to comment.