Skip to content

Commit

Permalink
fix: 누락된 meetingId 대응
Browse files Browse the repository at this point in the history
  • Loading branch information
semnil5202 committed Aug 24, 2024
1 parent 6809fb8 commit d1feaa8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const Questioner = ({ meetingId, meetingMemberId, imageUrl, name }: Quest
{ questionId, meetingMemberId },
{
onSuccess: () => {
router.push(`/share-group?question-id=${questionId}&questioner-name=${name}`);
router.push(`/${meetingId}/share-group?question-id=${questionId}&questioner-name=${name}`);
},
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
import { css } from '@emotion/react';
import { Button } from '@sambad/sds/components';
import { size } from '@sambad/sds/theme';
import { useRouter, useSearchParams } from 'next/navigation';
import { useParams, useRouter, useSearchParams } from 'next/navigation';
import { useState } from 'react';

import { findCurrentMeetingId } from '@/relay-question/utils/findCurrentMeetingId';

import { RelayRandomButtonDocumentIcon } from '../../../../assets/RelayRandomButtonIcon';
import { Modal } from '../../../../common/Modal';
import { FIRST_STEP } from '../../../../constants';
import { useMyMeetingsQuery } from '../../../start-relay-question/hooks/queries/useMyMeetingsQuery';
import { QuestionDetail } from '../../components/QuestionDetail/QuestionDetail';
import { QuestionerDetail } from '../../components/QuestionerDetail/QuestionerDetail';
import { ToolTip } from '../../components/ToolTip/ToolTip';
Expand All @@ -24,22 +21,26 @@ import { useToolTipShow } from '../../hooks/useToolTipShow';

import { wrapperCss } from './RandomPickContainer.styles';

interface Props {
meetingId: number;
}

export const RandomPickContainer = () => {
const { meetingId } = useParams<{ meetingId: string }>();
const { currentStep } = useQueryStringContext();

if (currentStep === FIRST_STEP) return <QuestionRandomPick />;
if (currentStep === FIRST_STEP) return <QuestionRandomPick meetingId={Number(meetingId)} />;

return <QuestionerRandomPick />;
return <QuestionerRandomPick meetingId={Number(meetingId)} />;
};

const QuestionRandomPick = () => {
const QuestionRandomPick = ({ meetingId }: Props) => {
const router = useRouter();

const [isOpen, setIsOpen] = useState<boolean>(false);
const { isShowToolTip } = useToolTipShow({ showTime: 5000 });

const { myMeetings } = useMyMeetingsQuery();
const { memberMe } = useMemberMeQuery(findCurrentMeetingId(myMeetings));
const { memberMe } = useMemberMeQuery(meetingId);
const { question, refetchQuestion } = useRandomQuestionQuery([memberMe?.meetingMemberId!]);

const handleOpenModal = () => {
Expand All @@ -52,7 +53,7 @@ const QuestionRandomPick = () => {
};

const handleConfirmModal = () => {
router.push(`/select-relay-question?current-step=2&question-id=${question?.questionId}`);
router.push(`/${meetingId}/select-relay-question?current-step=2&question-id=${question?.questionId}`);

handleCloseModal();
};
Expand All @@ -67,7 +68,7 @@ const QuestionRandomPick = () => {
</Button>
</section>
<Modal isOpen={isOpen} onClose={() => setIsOpen(false)}>
{question ? (
{question && (
<QuestionDetail
imageUrl={question.questionImageFileUrl}
title={question.title}
Expand All @@ -77,29 +78,26 @@ const QuestionRandomPick = () => {
onRefetch={refetchQuestion}
isRandom
/>
) : (
<div>loading...</div>
)}
</Modal>
</>
);
};

const QuestionerRandomPick = () => {
const QuestionerRandomPick = ({ meetingId }: Props) => {
const router = useRouter();
const searchParams = useSearchParams();

const [isOpen, setIsOpen] = useState<boolean>(false);
const { isShowToolTip } = useToolTipShow({ showTime: 5000 });

const { myMeetings } = useMyMeetingsQuery();
const { memberMe } = useMemberMeQuery(findCurrentMeetingId(myMeetings));
const { memberMe } = useMemberMeQuery(meetingId);
const { questioner, refetchQuestioner } = useRandomNextQuestionerQuery({
meetingId: findCurrentMeetingId(myMeetings),
meetingId,
excludeMemberIds: [memberMe?.meetingMemberId!],
});

const { postRelayQuestionInfo } = usePostRelayQuestionInfo(findCurrentMeetingId(myMeetings));
const { postRelayQuestionInfo } = usePostRelayQuestionInfo(meetingId);

const handleOpenModal = () => {
setIsOpen(true);
Expand All @@ -120,7 +118,7 @@ const QuestionerRandomPick = () => {
{ questionId, meetingMemberId },
{
onSuccess: () => {
router.push(`/share-group?question-id=${questionId}&questioner-name=${questioner.name}`);
router.push(`/${meetingId}/share-group?question-id=${questionId}&questioner-name=${questioner.name}`);
},
},
);
Expand All @@ -136,7 +134,7 @@ const QuestionerRandomPick = () => {
</Button>
</section>
<Modal isOpen={isOpen} onClose={handleCloseModal}>
{questioner ? (
{questioner && (
<QuestionerDetail
imageUrl={questioner.profileImageFileUrl}
name={questioner.name}
Expand All @@ -145,8 +143,6 @@ const QuestionerRandomPick = () => {
onRefetch={refetchQuestioner}
isRandom
/>
) : (
<div>loading...</div>
)}
</Modal>
</>
Expand Down

0 comments on commit d1feaa8

Please sign in to comment.