Skip to content

Commit

Permalink
Merge branch 'feat/hint-qa-finish' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
lgrin-byte committed Nov 21, 2024
2 parents 07ea38f + 91b4903 commit 80acf34
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions app/queries/getPreSignedUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { apiClient } from "@/lib/reactQueryProvider";
import { useToastInfo } from "@/components/atoms/toast.atom";
import { QUERY_KEY } from "@/queries/getHintList";
import extractFilename from "@/utils/helper";
import { getStatus } from "@/utils/localStorage";

interface PreSignedUrlRequest {
themeId: number;
Expand Down Expand Up @@ -76,13 +77,22 @@ const postHint = (data: HintData) => apiClient.post("/v1/hint", data);
const useHintUpload = () => {
const [, setToast] = useToastInfo();
const queryClient = useQueryClient();

const status = getStatus();
const presignedMutation = useMutation<
PreSignedUrlResponse,
AxiosError<AxiosSameCodeError>,
PreSignedUrlRequest
>({
mutationFn: getPreSignedUrl,
mutationFn: async (params) => {
if (status?.includes("SUBSCRIPTION")) {
return getPreSignedUrl(params);
}
return {
code: 200,
message: "No operation",
data: { hintImageUrlList: [], answerImageUrlList: [] },
};
},
onError: (error) => {
setToast({
isOpen: true,
Expand All @@ -109,14 +119,11 @@ const useHintUpload = () => {
HintData
>({
mutationFn: (data) => (data.id > 0 ? putHint(data) : postHint(data)),
onSuccess: (data) => {
onSuccess: () => {
queryClient.invalidateQueries(QUERY_KEY);
setToast({
isOpen: true,
title:
data.config.method === "put"
? "힌트를 수정했습니다."
: "힌트를 추가했습니다.",
title: "힌트가 성공적으로 등록되었습니다.",
text: "",
});
},
Expand Down

0 comments on commit 80acf34

Please sign in to comment.