diff --git a/components/ProfileCard/index.tsx b/components/ProfileCard/index.tsx index 58361ea..eba9a25 100644 --- a/components/ProfileCard/index.tsx +++ b/components/ProfileCard/index.tsx @@ -11,7 +11,8 @@ import Vector from '@/public/icons/Vector 115.svg'; import { useRouter } from 'next/router'; import useModal from '@/hooks/useModal.ts'; import { signOut } from 'next-auth/react'; -import { Profile } from '@/public/types/user'; +import { UserInfoProps } from '@/context/UserInfoProvider.tsx'; +// import { Profile } from '@/public/types/user'; import { formatAge } from '@/utils/transform'; interface ListItemProps { @@ -23,7 +24,7 @@ interface ListItemProps { } interface ProfileCard { - userInfo: Profile; + userInfo: UserInfoProps; imageSrc: string; } @@ -31,7 +32,7 @@ export default function ProfileCard({ imageSrc, userInfo }: ProfileCard) { const { register } = useForm({ mode: 'onChange' }); const [showModal, setShowModal] = useState(false); const [hoveredIndex, setHoveredIndex] = useState(null); - const age = formatAge(userInfo.birthDate); + const age = formatAge(userInfo?.birthDate || ''); const router = useRouter(); const { openModal } = useModal(); diff --git a/context/UserInfoProvider.tsx b/context/UserInfoProvider.tsx index a3f4a9e..5b6206c 100644 --- a/context/UserInfoProvider.tsx +++ b/context/UserInfoProvider.tsx @@ -6,6 +6,7 @@ interface ComponentProps { export interface UserInfoProps { id?: number; + profileId?: number; email?: string; firstName?: string; lastName?: string; diff --git a/pages/userInfo/editProfile.tsx b/pages/userInfo/editProfile.tsx index 057684b..cd1cbc2 100644 --- a/pages/userInfo/editProfile.tsx +++ b/pages/userInfo/editProfile.tsx @@ -10,10 +10,11 @@ import { Textarea, Button, Upload, Input, Calendar } from '@/components/index.ts import ProfileCamera from '@/public/icons/profileCamera.svg'; import { User, Profile } from '@/public/types/user'; import { modifyProfile } from '@/api/userInfo'; +import { UserInfoProps } from '@/context/UserInfoProvider.tsx'; interface ProfileProps { _imageSrc: string; - userInfo: Profile; + userInfo: UserInfoProps; } interface ImageComponentClickProps { @@ -21,11 +22,6 @@ interface ImageComponentClickProps { } export default function EditProfile({ _imageSrc, userInfo }: ProfileProps) { - useEffect(() => { - console.log('_imageSrc', _imageSrc); - console.log('userInfo in editprofile', userInfo); - debugger; - }, []); const [imageSrc, setImageSrc] = useState(_imageSrc); const subHeader = 'font-pretendard font-semibold text-[16px]'; const { @@ -39,7 +35,7 @@ export default function EditProfile({ _imageSrc, userInfo }: ProfileProps) { return (str || '').charAt(0).toUpperCase() + (str || '').slice(1).toLowerCase(); }; - const [buttonState, setButtonState] = useState(capitalizeFirstLetter(userInfo?.gender)); + const [buttonState, setButtonState] = useState(capitalizeFirstLetter(userInfo?.gender || '')); const onSubmit: SubmitHandler = async (data) => { try { diff --git a/pages/userInfo/index.tsx b/pages/userInfo/index.tsx index 183b5bf..1dd6f2a 100644 --- a/pages/userInfo/index.tsx +++ b/pages/userInfo/index.tsx @@ -1,6 +1,5 @@ import React, { useState, useEffect } from 'react'; import { Nav, ProfileCard } from '@/components/index.tsx'; -import { useRouter } from 'next/router'; import { getProfile } from '@/api/userInfo'; import { UserInfoProps } from '@/context/UserInfoProvider.tsx';