Skip to content

Commit

Permalink
#29 feat: 홈 화면 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
kj9470 committed Nov 23, 2024
1 parent ffae4ba commit c63e444
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions src/page/main/home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -14,6 +16,11 @@ interface UserList {

const Home = () => {
const [userList, setUserList] = useState<UserList[]>([]);
const [isMentor, setIsMentor] = useState<boolean>(true);
const [profileText, setProfileText] = useState<string>(
'멘토링 신청을 할 수 있는 멘토들이에요'
);

const handleHome = async () => {
try {
const response = await getMentors();
Expand All @@ -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, []);

Expand All @@ -37,11 +60,14 @@ const Home = () => {
<St.HomeWrapper>
<Navigation showLogo={true} />
<St.BannerWrapper>
<img src={bannerImg} alt='profile' />
{isMentor ? (
<img src={bannerMentorImg} alt='profile' />
) : (
<img src={bannerMenteeImg} alt='profile' />
)}
</St.BannerWrapper>
<St.ProfileText>
{'멘토링 신청을 할 수 있는 멘토들이에요'}
</St.ProfileText>

<St.ProfileText>{profileText}</St.ProfileText>
<St.ProfileListWrapper>
{userList.map((data) => (
<UserProfile name={data.name} keyword={data.keyword} />
Expand Down

0 comments on commit c63e444

Please sign in to comment.