From c63e4444355d98ee00c77e345bc1083381c6fc37 Mon Sep 17 00:00:00 2001 From: kwonjeong Date: Sun, 24 Nov 2024 04:57:24 +0900 Subject: [PATCH] =?UTF-8?q?#29=20feat:=20=ED=99=88=20=ED=99=94=EB=A9=B4=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/page/main/home/Home.tsx | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/page/main/home/Home.tsx b/src/page/main/home/Home.tsx index 8774c99..8ac25f0 100644 --- a/src/page/main/home/Home.tsx +++ b/src/page/main/home/Home.tsx @@ -2,10 +2,12 @@ import { useState, useEffect } from 'react'; import styled from 'styled-components'; import Navigation from '@/page/component/navi/Navigation'; -import bannerImg from '@image/home/banner_mentor.png'; +import bannerMentorImg from '@image/home/banner_mentor.png'; +import bannerMenteeImg from '@image/home/banner_mentee.png'; import mentoringProcessImg from '@image/home/mentoring-explain.png'; import UserProfile from '@/page/main/home/component/UserProfile'; import { getMentors } from '@/shared/api/home'; +import { getUserInfo } from '@/shared/api/user'; interface UserList { name: string; @@ -14,6 +16,11 @@ interface UserList { const Home = () => { const [userList, setUserList] = useState([]); + const [isMentor, setIsMentor] = useState(true); + const [profileText, setProfileText] = useState( + '멘토링 신청을 할 수 있는 멘토들이에요' + ); + const handleHome = async () => { try { const response = await getMentors(); @@ -27,8 +34,24 @@ const Home = () => { } }; + const handleUserInfo = async () => { + try { + const response = await getUserInfo(); + setIsMentor(response.data.role === 'MENTOR'); + if (isMentor == true) { + setProfileText('멘토링 신청을 할 수 있는 멘토들이에요'); + } else { + setProfileText('멘토링은 어떻게 진행되나요?'); + } + console.log(isMentor); + } catch (error) { + console.log(error); + } + }; + const iRunOnlyOnce = () => { handleHome(); + handleUserInfo(); }; useEffect(iRunOnlyOnce, []); @@ -37,11 +60,14 @@ const Home = () => { - profile + {isMentor ? ( + profile + ) : ( + profile + )} - - {'멘토링 신청을 할 수 있는 멘토들이에요'} - + + {profileText} {userList.map((data) => (