Skip to content

Commit

Permalink
fix: 자청년 여부 받아오는 방법 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
seokkkkkk committed Aug 10, 2024
1 parent cfad725 commit d2bab44
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/pages/ChallengeDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import RejectModal from "../components/ChallengeDetail/RejectModal";
import CompleteModal from "../components/ChallengeDetail/CompleteModal";
import Modal from "../components/ChallengeDetail/Modal";
import Certification from "../components/ChallengeDetail/Certification";
import { getCanaryStatus } from "../apis/canary";

const ChallengeDetail = () => {
const { userData, accessToken } = useAuthStore();
Expand All @@ -37,12 +38,18 @@ const ChallengeDetail = () => {
queryKey: ["getChallengeDetail", challengeId, accessToken],
queryFn: () => getChallengeDetail(challengeId!, accessToken),
});
const { data: isCanary, isLoading: isCanaryLoading } = useQuery({
queryKey: ["getCanaryStatus", userData.id, accessToken],
queryFn: () => getCanaryStatus(userData.id!, accessToken!),
});

const handleModalOpen = useCallback(() => {
if (userData.role === "CANARY") {
setIsModalOpen(true);
} else {
setFailModalOpen(true);
if (!isCanaryLoading) {
if (isCanary.data === 2) {
setIsModalOpen(true);
} else {
setFailModalOpen(true);
}
}
}, [userData.role]);

Expand Down

0 comments on commit d2bab44

Please sign in to comment.