Skip to content

Commit

Permalink
Merge pull request #51 from LikeLion-KNU/chore/resultLoading
Browse files Browse the repository at this point in the history
chore: resultLoading에서 api요청을 실패해도 넘어갈 수 있도록 수정
  • Loading branch information
toothlessdev authored Sep 11, 2024
2 parents d67bce9 + 8529df2 commit 713daa9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion serverless/dongbti/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const resultTypes = [
"matSportsman",
"fightSportsman",
"uniqueSportsman",
"10cm",
"tencm",
"tchaikovsky",
"stageMusician",
"mozart",
Expand Down
15 changes: 5 additions & 10 deletions src/hooks/useSubmitResult.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { useEffect, useState } from "react";
import { useEffect } from "react";
import { useNavigate, useSearchParams } from "react-router-dom";

import { api } from "@/config/axios";
import { useUserInfo } from "@/store/store";

export const useSubmitResult = () => {
const [isPending, setIsPending] = useState<boolean>(false);
const department = useUserInfo((state) => state.department);

const navigate = useNavigate();
Expand All @@ -15,14 +14,10 @@ export const useSubmitResult = () => {
const mbti = searchParams.get("type");
console.log(searchParams);

api.post("/stats", { department: department, mbti })
.then(() => {
navigate(`/result?type=${mbti}`);
})
.finally(() => {
setIsPending(false);
});
api.post("/stats", { department, mbti }).finally(() => {
navigate(`/result?type=${mbti}`);
});
}, []);

return { isPending };
return null;
};

0 comments on commit 713daa9

Please sign in to comment.