Skip to content

Commit

Permalink
Merge pull request #54 from LikeLionHGU/#43/ConnectSignInAPI-최예라
Browse files Browse the repository at this point in the history
#43/connect sign in api 최예라
  • Loading branch information
YearaChoi authored Aug 3, 2024
2 parents 5de9dd2 + e9eee26 commit fd584ec
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/components/Common/CourseCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from "react";
import styled from "styled-components";
import StarRating from "./StarRating";
import heartIcon from "../../assets/img/heart.svg";
import defaultImg from "../../assets/img/defaultImg.jpg";

function CourseCard({ course }) {
const possibleDisabilityTypes = course.possibleDisabilityType?.map(
Expand All @@ -13,7 +12,7 @@ function CourseCard({ course }) {
return (
<Card>
<CourseImg>
<img src={defaultImg} alt="기본 강좌 이미지" />
<img src={course.imageURL} alt="기본 강좌 이미지" />
</CourseImg>
<InfoSection>
<Top>
Expand Down
25 changes: 23 additions & 2 deletions src/components/Common/HeaderLightVer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import LoginModal from "../MainPage/LoginModal";
function HeaderLightVer() {
const [isLoginModalOpen, setLoginModalOpen] = useState(false);
const navigate = useNavigate();
const token = localStorage.getItem("jwtToken");

const handleMenuClick = (url) => {
navigate(url);
Expand All @@ -29,6 +30,12 @@ function HeaderLightVer() {
navigate("/sign");
};

const handleSignOutBtnClick = () => {
localStorage.removeItem("jwtToken");
window.location.reload();
navigate("/");
};

return (
<Wrapper>
<Menus>
Expand All @@ -44,8 +51,14 @@ function HeaderLightVer() {
</Logo>
</Menus>
<SignInSection>
<SignIn onClick={toggleLoginModal}>로그인</SignIn>
<SignIn onClick={handleSignInClick}>회원가입</SignIn>
{!token ? (
<>
<SignIn onClick={toggleLoginModal}>로그인</SignIn>
<SignIn onClick={handleSignInClick}>회원가입</SignIn>
</>
) : (
<SignOut onClick={handleSignOutBtnClick}>로그아웃</SignOut>
)}
</SignInSection>
{isLoginModalOpen && <LoginModal toggleModal={toggleLoginModal} />}
<SearchSection>
Expand Down Expand Up @@ -138,3 +151,11 @@ const SignIn = styled.div`
font-size: 14px;
cursor: pointer;
`;

const SignOut = styled.div`
color: #1997fc;
font-size: 14px;
cursor: pointer;
/* border: 1px solid red; */
margin-left: 70px;
`;
2 changes: 1 addition & 1 deletion src/components/LectureListPage/LectureDetailContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function LectureDetailContent() {
<Wrapper>
<CourseCard>
<CourseImg>
<img src={defaultImg} alt="기본 강좌 이미지" />
<img src={data.imageURL} alt="기본 강좌 이미지" />
</CourseImg>
<CourseDetail>
<Top>
Expand Down
2 changes: 1 addition & 1 deletion src/components/LectureListPage/TeacherProfileModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function TeacherProfileModal({ toggleModal }) {
<DetailContent>{data.teacher.reviewCount}</DetailContent>
</CourseReview>
<CourseRate>
<DetailCategory>강의평점</DetailCategory>
<DetailCategory>강좌평점</DetailCategory>
<div style={{ display: "flex" }}>
<img src={star} alt="별 이미지"></img>
<DetailContent>{data.teacher.score}</DetailContent>
Expand Down
25 changes: 23 additions & 2 deletions src/components/MainPage/HeaderMain.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import LoginModal from "./LoginModal";
function HeaderMain() {
const [isLoginModalOpen, setLoginModalOpen] = useState(false);
const navigate = useNavigate();
const token = localStorage.getItem("jwtToken");

const toggleLoginModal = () => {
setLoginModalOpen((prevState) => !prevState);
Expand All @@ -17,6 +18,11 @@ function HeaderMain() {
navigate("/sign");
};

const handleSignOutBtnClick = () => {
localStorage.removeItem("jwtToken");
window.location.reload();
};

useEffect(() => {
document.body.style.overflow = isLoginModalOpen ? "hidden" : "auto";
}, [isLoginModalOpen]);
Expand Down Expand Up @@ -44,8 +50,14 @@ function HeaderMain() {
</Logo>
</Menus>
<SignInSection>
<SignIn onClick={toggleLoginModal}>로그인</SignIn>
<SignIn onClick={handleSignInClick}>회원가입</SignIn>
{!token ? (
<>
<SignIn onClick={toggleLoginModal}>로그인</SignIn>
<SignIn onClick={handleSignInClick}>회원가입</SignIn>
</>
) : (
<SignOut onClick={handleSignOutBtnClick}>로그아웃</SignOut>
)}
</SignInSection>
{isLoginModalOpen && <LoginModal toggleModal={toggleLoginModal} />}
<SearchSection>
Expand Down Expand Up @@ -131,10 +143,19 @@ const SignInSection = styled.div`
top: 30%;
transform: translateX(-50%);
z-index: 1;
/* border: 1px solid red; */
`;

const SignIn = styled.div`
color: #1997fc;
font-size: 14px;
cursor: pointer;
`;

const SignOut = styled.div`
color: #1997fc;
font-size: 14px;
cursor: pointer;
/* border: 1px solid red; */
margin-left: 70px;
`;
4 changes: 2 additions & 2 deletions src/components/UserPage/SideBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ function SideBar() {
</Menu>
<Menu onClick={() => handleMenuClick("/user/saved")}>
<Section>
<img src={likedCourseIcon} alt="찜한 강의 아이콘"></img>
<Text>찜한 강의</Text>
<img src={likedCourseIcon} alt="찜한 강좌 아이콘"></img>
<Text>찜한 강좌</Text>
</Section>
</Menu>
<Menu onClick={() => handleMenuClick("/user/learning")}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/UserPage/UserCompleteLetureContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function UserCompleteLetureContent() {
return (
<Wrapper>
<Content>
<Title>최예라 님! 지금까지 수강했던 강의들이에요</Title>
<Title>최예라 님! 지금까지 수강했던 강좌들이에요</Title>
<Count>총 10개를 수강했습니다</Count>
<CourseContainer>
{data.map((course, index) => (
Expand Down
2 changes: 1 addition & 1 deletion src/components/UserPage/UserLearningContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function UserLearningContent() {
return (
<Wrapper>
<Content>
<Title>최예라 님! 현재 수강 중인 강의에요</Title>
<Title>최예라 님! 현재 수강 중인 강좌에요</Title>
<CourseContainer>
{data.map((course, index) => (
<React.Fragment key={course.courseId}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/UserPage/UserSavedLectureContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function UserSavedLectureContent() {
return (
<Wrapper>
<Content>
<Title>최예라 님! 찜한 강의들이에요</Title>
<Title>최예라 님! 찜한 강좌들이에요</Title>
<CourseContainer>
{data?.map((data, index) => (
<React.Fragment key={data.courseId}>
Expand Down

0 comments on commit fd584ec

Please sign in to comment.