|
| 1 | +"use client"; |
| 2 | + |
| 3 | +import { useEffect, useState } from "react"; |
| 4 | +import { UserInfo } from "@/lib/types"; |
| 5 | +import { fetchUser } from "@/lib/apis/usersApi"; |
| 6 | +import { TOKEN_1 } from "@/lib/constants/tokens"; |
| 7 | +import Button from "@/components/common/button/Button"; |
| 8 | +import ImageInput from "@/components/common/input/ImageInput"; |
| 9 | +import Input from "@/components/common/input/Input"; |
| 10 | + |
| 11 | +export default function ProfileSection() { |
| 12 | + const [data, setData] = useState<UserInfo | null>(null); |
| 13 | + |
| 14 | + useEffect(() => { |
| 15 | + const getData = async () => { |
| 16 | + const res = await fetchUser({ |
| 17 | + token: TOKEN_1, |
| 18 | + }); |
| 19 | + setData(res); |
| 20 | + }; |
| 21 | + |
| 22 | + getData(); |
| 23 | + }, []); |
| 24 | + |
| 25 | + if (!data) return; |
| 26 | + |
| 27 | + const { email, nickname, profileImageUrl } = data; |
| 28 | + |
| 29 | + // 이 밑으로 formData(닉네임, 이미지) state 생성하시고, 기본값으로 각각 위의 nickname, profileImageUrl 넣어주시면 될 거예요 |
| 30 | + // 아래는 vercel 배포를 위해 위 값들을 임시로 사용한 테스트 코드라 나중에 삭제해주시면 됩니다 |
| 31 | + console.log(nickname); |
| 32 | + console.log(profileImageUrl); |
| 33 | + |
| 34 | + return ( |
| 35 | + <div className="w-full p-4 rounded-lg bg-white tablet:p-6"> |
| 36 | + <div className="flex flex-col gap-10 tablet:gap-6"> |
| 37 | + <div className="font-bold text-2lg text-gray-800 tablet:text-2xl"> |
| 38 | + 프로필 |
| 39 | + </div> |
| 40 | + <div className="flex flex-col gap-10 tablet:flex-row tablet:gap-[42px]"> |
| 41 | + <div> |
| 42 | + <ImageInput variant="profile" /> |
| 43 | + </div> |
| 44 | + <div className="flex flex-col gap-6 grow"> |
| 45 | + <div className="flex flex-col gap-4"> |
| 46 | + {/* 이메일 인풋에는 나중에 disabled 속성 들어가야 합니다 */} |
| 47 | + <Input label="이메일" value={email} /> |
| 48 | + <Input label="닉네임" /> |
| 49 | + </div> |
| 50 | + <Button variant="purple">저장</Button> |
| 51 | + </div> |
| 52 | + </div> |
| 53 | + </div> |
| 54 | + </div> |
| 55 | + ); |
| 56 | +} |
0 commit comments