1- import { useState } from 'react' ;
1+ import { useState , useEffect } from 'react' ;
22import { Link } from 'react-router' ;
33
44import ConfirmModal from '@/components/ConfirmModal' ;
5+ import useMyPageStore from '@/stores/myPageStore' ;
56
67import { TEMPERATURE_RANGE } from './constants' ;
78
8- const DUMMY_TEMP = 48.5 ;
9- const DUMMY_ZIP_CODE = '235EA' ;
10-
119const MyPage = ( ) => {
10+ useEffect ( ( ) => {
11+ fetchMyPageInfo ( ) ;
12+ } , [ ] ) ;
13+
14+ const { data, fetchMyPageInfo } = useMyPageStore ( ) ;
1215 const [ isOpenModal , setIsOpenModal ] = useState ( false ) ;
1316
1417 const getDescriptionByTemperature = ( temp : number ) => {
1518 const range = TEMPERATURE_RANGE . find ( ( range ) => temp >= range . min && temp < range . max ) ;
1619 return range ?. description ;
1720 } ;
1821
19- const description = getDescriptionByTemperature ( DUMMY_TEMP ) ;
22+ const description = getDescriptionByTemperature ( Number ( data . temperature ) ) ;
2023
2124 return (
2225 < >
@@ -32,7 +35,7 @@ const MyPage = () => {
3235 ) }
3336 < main className = "flex grow flex-col gap-12 px-5 pt-20 pb-6" >
3437 < h1 className = "h2-b mx-auto flex gap-1.5" >
35- { DUMMY_ZIP_CODE . split ( '' ) . map ( ( code , index ) => (
38+ { data . zipCode . split ( '' ) . map ( ( code , index ) => (
3639 < div
3740 key = { index }
3841 className = "flex h-13.5 w-10 items-center justify-center rounded-sm bg-white inset-shadow-[0_4px_4px_0] inset-shadow-black/10"
@@ -44,12 +47,12 @@ const MyPage = () => {
4447 < section >
4548 < h2 className = "mb-2 flex justify-between" >
4649 < p className = "body-sb text-gray-60" > { description } </ p >
47- < p className = "body-sb text-accent-1" > { DUMMY_TEMP } 도</ p >
50+ < p className = "body-sb text-accent-1" > { data . temperature } 도</ p >
4851 </ h2 >
4952 < div className = "h-4 w-full rounded-full bg-white" >
5053 < div
5154 className = "h-full w-[calc(${degree}%)] rounded-full bg-[#FFB5AC]"
52- style = { { width : `calc(${ DUMMY_TEMP } %)` } }
55+ style = { { width : `calc(${ data . temperature } %)` } }
5356 />
5457 </ div >
5558 </ section >
@@ -69,8 +72,8 @@ const MyPage = () => {
6972 < div className = "flex justify-between" >
7073 < p className = "body-sb text-gray-100" > 로그인 정보</ p >
7174 < p className = "body-r text-gray-60" >
72- < span className = "mr-2" > 카카오 </ span >
73- 75+ < span className = "mr-2" > { data . social } </ span >
76+ < span > { data . email } </ span >
7477 </ p >
7578 </ div >
7679 < p className = "body-sb text-gray-100" > 로그아웃</ p >
0 commit comments