Skip to content

Commit

Permalink
fix: 유형 검사 결과 띄워주는 화면에서 type 없을 경우 접근 불가하도록 지정
Browse files Browse the repository at this point in the history
  • Loading branch information
nim-od committed Aug 19, 2024
1 parent 5dcf11a commit 66d1a32
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PendingStep from 'src/components/shared/modal/PendingStep.tsx';
import useSubmitTeamTypeQuizAnswers, {
type SubmitQuizAnswersRequest,
} from 'src/hooks/query/useSubmitTeamTypeQuizAnswers.ts';
import useAuth from 'src/hooks/useAuth.ts';
import useFunnel from 'src/hooks/useFunnel.ts';
import CustomError from 'src/utils/error.ts';
import ErrorStep from './ErrorStep.tsx';
Expand All @@ -15,6 +16,8 @@ interface TeamSelectModalContentProps {
export default function TeamSelectModalContent({
initialStep = 'quiz',
}: TeamSelectModalContentProps) {
const { user } = useAuth();

const [Funnel, setStep] = useFunnel(
['quiz', 'pending', 'success', 'error', 'already-done'] as NonEmptyArray<string>,
{ initialStep },
Expand Down Expand Up @@ -48,15 +51,15 @@ export default function TeamSelectModalContent({
<Funnel.Step name="pending">
<PendingStep>내 유형 불러오는 중 ...</PendingStep>
</Funnel.Step>
<Funnel.Step name="success">
<ResultStep />
</Funnel.Step>
<Funnel.Step name="success">{user?.type && <ResultStep />}</Funnel.Step>
<Funnel.Step name="already-done">
<ResultStep>
<p className="text-detail-1">
이미 유형 검사를 완료하셨군요! 이전 검사 결과를 보여드릴게요
</p>
</ResultStep>
{user?.type && (
<ResultStep>
<p className="text-detail-1">
이미 유형 검사를 완료하셨군요! 이전 검사 결과를 보여드릴게요
</p>
</ResultStep>
)}
</Funnel.Step>
<Funnel.Step name="error">
<ErrorStep setQuizStep={() => setStep('quiz')}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@ import useAuth from 'src/hooks/useAuth.ts';
export default function ResultStep({ children }: PropsWithChildren) {
const { user } = useAuth();

const type = useMemo(() => user?.type as Category, [user]);
const type = useMemo(() => {
if (user?.type) {
return user.type;
}
}, [user?.type]);

if (!type) {
return null;
}

const { title, shortTitle, details } = TEAM_DESCRIPTIONS[type];
const displayTitle = shortTitle ?? title;
Expand Down

0 comments on commit 66d1a32

Please sign in to comment.