Skip to content

Commit

Permalink
fix(web-domains): 자기소개 수정 초기 데이터 로직 추가 (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeJeongHooo authored Aug 30, 2024
1 parent 475bf1e commit a78e1b8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface MeetingMemberResponse {
job: string;
location: string;
hobbies?: Array<string>;
hobbyDetails?: Array<{ hobbyId: number; content: string }>;
mbti?: string;
introduction?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export const IntroInfoForm = () => {
placeholder="저는 이런 사람이에요"
{...register('introduction', {
maxLength: MAX_LENGTH,
validate: (value) => (value.trim().length >= 1 ? true : false),
})}
/>
<Txt as="p" typography="body4" color={colors.grey600}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export const ModifyIntroForm = () => {
maxLength={MAX_LENGTH}
{...register('introduction', {
maxLength: MAX_LENGTH,
validate: (value) => (value.trim().length >= 1 ? true : false),
})}
/>
<Txt as="p" typography="body4" color={colors.grey600}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
'use client';

import { notFound, redirect, useSearchParams } from 'next/navigation';
import { useParams, useSearchParams, useRouter } from 'next/navigation';
import { useEffect } from 'react';

import { useGetMemberMe } from '@/about-me/common/apis/queries/useGetMemberMe';
import { STEPS } from '@/user/common/constants/step';

import { GetUserBasicInfoContainer } from '../../get-user-info/containers/GetUserBasicInfoContainer';
Expand All @@ -12,11 +14,35 @@ import { GetUserMbtiContainer } from '../../get-user-info/containers/GetUserMbti
import { ModifyUserIntroContainer } from './ModifyUserIntroContainer';

export const ModifyUserInfoContainer = () => {
const { meetingId } = useParams();
const searchParams = useSearchParams();
const router = useRouter();
const step = searchParams.get('step');

if (!step) {
redirect(`?step=${STEPS.BASIC_INFO}`);
const { data: memberMe, isLoading } = useGetMemberMe({ meetingId: Number(meetingId) });

useEffect(() => {
if (memberMe && !step) {
const params = new URLSearchParams();
params.append('step', STEPS.BASIC_INFO);
params.append('userName', memberMe?.name);
params.append('birth', memberMe?.birth.replaceAll('-', ''));
params.append('gender', memberMe.gender);
params.append('job', memberMe.job);
params.append('location', memberMe.location);
if (memberMe.mbti) {
params.append('mbti', memberMe.mbti);
}
if (memberMe.hobbyDetails && memberMe.hobbyDetails.length > 0) {
const hobbyIds = memberMe.hobbyDetails.map((hobby) => hobby.hobbyId).toString();
params.append('hobbyIds', hobbyIds);
}
router.replace(`?${params.toString()}`);
}
}, [memberMe, step]);

if (!step || isLoading) {
return null;
}

switch (step) {
Expand All @@ -31,6 +57,6 @@ export const ModifyUserInfoContainer = () => {
case STEPS.INTRO_INFO:
return <ModifyUserIntroContainer />;
default:
notFound();
return <GetUserBasicInfoContainer />;
}
};

0 comments on commit a78e1b8

Please sign in to comment.