Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web-domains): 자기소개 수정 초기 데이터 불러오기 #187

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
Comment on lines +44 to 46
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 그냥 null 리턴하고 있었구나 거의 깜빡임 못 느끼긴 해서... 문제 되면 스켈레톤이나 로더를 추가해봅시당


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