diff --git a/packages/web-domains/src/answer/features/progressing-question/containers/ProgressingQuestionContainer.tsx b/packages/web-domains/src/answer/features/progressing-question/containers/ProgressingQuestionContainer.tsx index afc6d51b..ed46b684 100644 --- a/packages/web-domains/src/answer/features/progressing-question/containers/ProgressingQuestionContainer.tsx +++ b/packages/web-domains/src/answer/features/progressing-question/containers/ProgressingQuestionContainer.tsx @@ -1,7 +1,10 @@ 'use client'; -import { Txt } from '@sambad/sds/components'; +import { Button, Txt } from '@sambad/sds/components'; import { colors } from '@sambad/sds/theme'; +import Link from 'next/link'; + +import { EmptyView } from '@/common/components'; import { AnswerCountDown } from '../../../common/components/Countdown/AnswerCountdown'; import { StartButton } from '../../floating-button/components/StartButton'; @@ -11,12 +14,44 @@ import { useProgressingQuestionService } from '../services/useProgressingQuestio export const ProgressingQuestionContainer = () => { const { progressingQuestion, meetingId } = useProgressingQuestionService(); + const isNowAnswered = !progressingQuestion?.isAnswered; if (!progressingQuestion) { return null; } + if (!progressingQuestion.isQuestionRegistered) { + return ( +
+ + + + +
+ ); + } + return (
diff --git a/packages/web-domains/src/answer/features/progressing-question/services/useProgressingQuestionService.tsx b/packages/web-domains/src/answer/features/progressing-question/services/useProgressingQuestionService.tsx index bd003fd1..1bfa5771 100644 --- a/packages/web-domains/src/answer/features/progressing-question/services/useProgressingQuestionService.tsx +++ b/packages/web-domains/src/answer/features/progressing-question/services/useProgressingQuestionService.tsx @@ -1,14 +1,31 @@ +import { useQueryClient } from '@tanstack/react-query'; import dayjs from 'dayjs'; import { useSetAtom } from 'jotai'; import { useParams } from 'next/navigation'; +import { useEffect } from 'react'; import { answerAtoms } from '@/answer/common/atoms/answer.atom'; +import { useUpdateLastMeeting } from '@/home/common/apis/mutations/useUpdateLastMeeting'; +import { MEETING_INFO_QUERY_KEY } from '@/home/common/apis/queries/useGetMeetingName'; +import { PROGRESSING_QUESTION_QUERY_KEY } from '@/home/common/apis/queries/useGetProgressingQuestion'; import { useGetProgressingQuestion } from '../../../common/apis/queries/useGetProgressingQuestion'; export const useProgressingQuestionService = () => { + const queryClient = useQueryClient(); const { meetingId } = useParams<{ meetingId: string }>(); const setAnswerGlobalTime = useSetAtom(answerAtoms.answerGlobalTime); + const { mutateAsync } = useUpdateLastMeeting({ + options: { + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: [MEETING_INFO_QUERY_KEY] }); + queryClient.invalidateQueries({ queryKey: [PROGRESSING_QUESTION_QUERY_KEY] }); + }, + onError: (error) => { + console.log(error); + }, + }, + }); const { data: progressingQuestion } = useGetProgressingQuestion({ params: { meetingId: parseInt(meetingId) }, @@ -23,6 +40,10 @@ export const useProgressingQuestionService = () => { }, }); + useEffect(() => { + mutateAsync({ meetingId: parseInt(meetingId) }); + }, []); + return { meetingId, gatherName: '삼봤드의 모험', diff --git a/packages/web-domains/src/answer/features/top-bar/containers/TopBarContainer.tsx b/packages/web-domains/src/answer/features/top-bar/containers/TopBarContainer.tsx index f82c3c1e..85e65614 100644 --- a/packages/web-domains/src/answer/features/top-bar/containers/TopBarContainer.tsx +++ b/packages/web-domains/src/answer/features/top-bar/containers/TopBarContainer.tsx @@ -3,5 +3,5 @@ import { ActionBar } from '../../../../common/components/ActionBar/ActionBar'; export const TobBarContainer = () => { - return ; + return ; }; diff --git a/packages/web-domains/src/common/components/ActionBar/ActionBar.tsx b/packages/web-domains/src/common/components/ActionBar/ActionBar.tsx index d8a6954f..fa7b65ba 100644 --- a/packages/web-domains/src/common/components/ActionBar/ActionBar.tsx +++ b/packages/web-domains/src/common/components/ActionBar/ActionBar.tsx @@ -10,16 +10,21 @@ import { actionBarWrapperStyles, addOnStyles, buttonStyles } from './ActionBar.s interface ActionBarProps extends HTMLAttributes { disableBack?: boolean; + pushLink?: string; title?: string; rightDecor?: ReactNode; onBack?: () => void; } -export const ActionBar = ({ disableBack = false, title, rightDecor, onBack, ...rest }: ActionBarProps) => { - const { back } = useRouter(); +export const ActionBar = ({ disableBack = false, pushLink, title, rightDecor, onBack, ...rest }: ActionBarProps) => { + const { back, push } = useRouter(); const handleBack = () => { - back(); + if (pushLink) { + push(pushLink); + } else { + back(); + } onBack?.(); }; diff --git a/packages/web-domains/src/home/common/apis/mutations/useUpdateLastMeeting.ts b/packages/web-domains/src/home/common/apis/mutations/useUpdateLastMeeting.ts index 95fdeb2e..c471241f 100644 --- a/packages/web-domains/src/home/common/apis/mutations/useUpdateLastMeeting.ts +++ b/packages/web-domains/src/home/common/apis/mutations/useUpdateLastMeeting.ts @@ -1,5 +1,4 @@ import { UseMutationOptions, useMutation } from '@tanstack/react-query'; -import { isAxiosError } from 'axios'; import { Http } from '@/common/apis/base.api'; @@ -12,14 +11,8 @@ interface Args { export const useUpdateLastMeeting = ({ options }: Args = {}) => { return useMutation({ mutationFn: async (params: Params) => { - try { - const data = await updateLastMeeting(params); - return data; - } catch (error) { - if (isAxiosError(error)) { - console.error(error); - } - } + const data = await updateLastMeeting(params); + return data; }, ...options, });