Skip to content

Commit

Permalink
feat/#14-#11 pr 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmj12 committed Dec 16, 2024
2 parents d67c3d7 + 3959f1e commit 67caab2
Show file tree
Hide file tree
Showing 13 changed files with 227 additions and 29 deletions.
118 changes: 109 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@
"@emotion/styled": "^11.13.0",
"@reduxjs/toolkit": "^2.2.8",
"@uiw/react-md-editor": "^3.6.0",
"axios": "^1.7.7",
"next": "^14.2.14",
"next-remove-imports": "^1.0.12",
"polished": "^4.3.1",
"react": "^18",
"react-dom": "^18",
"react-icons": "^5.3.0",
"react-redux": "^9.1.2",
"react-spinners": "^0.14.1"
"react-spinners": "^0.14.1",
"zustand": "^5.0.1"
},
"devDependencies": {
"@types/node": "^20",
Expand Down
3 changes: 3 additions & 0 deletions public/icons/user.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions src/components/LoginModal/LoginModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import * as S from "./styles";
import close from "../../../public/icons/close.svg";
import chevron_left from "../../../public/icons/chevron_left.svg";
import Image from "next/image";
import { useAuthStore } from "@/stores/authStore";
import { login } from "@/services/auth";

interface ModalProps {
onClose: () => void;
Expand All @@ -17,11 +19,25 @@ interface ModalProps {

const Modal: React.FC<ModalProps> = ({ onClose, initialStep = "main" }) => {
const [modalStep, setModalStep] = useState(initialStep);
const { login: setLoginState } = useAuthStore();

useEffect(() => {
setModalStep(initialStep);
}, [initialStep]);

const handleLogin = async (e: React.FormEvent) => {
e.preventDefault();
try {
const user = await login("email", "password");
setLoginState(user);
console.log(user);
alert("로그인 성공!");
} catch (error) {
console.error(error);
alert("로그인 실패!");
}
};

const handleBackdropClick = (event: React.MouseEvent<HTMLDivElement>) => {
if (event.target === event.currentTarget) {
onClose();
Expand Down Expand Up @@ -78,6 +94,14 @@ const Modal: React.FC<ModalProps> = ({ onClose, initialStep = "main" }) => {
>
이메일로 로그인
</S.Button>
<S.Button
bgColor="#ff000014"
hoverColor="#6aff0024"
textColor="#000000"
onClick={handleLogin}
>
로그인 테스트
</S.Button>
</S.ButtonBox>
<S.CheckboxContainer>
<input type="checkbox" id="stayLoggedIn" />
Expand Down
51 changes: 47 additions & 4 deletions src/components/Navigation/Navigation.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useEffect, useState } from "react";
import {
LoginText,
SignUpButton,
Expand All @@ -13,11 +13,32 @@ import {
import LoginModal from "../LoginModal/LoginModel";
import hamburger from "../../../public/icons/hamburger.svg";
import Image from "next/image";
import { useAuthStore } from "@/stores/authStore";
import userIcon from "../../../public/icons/user.svg";
import { logout } from "@/services/auth";

const Navigation: React.FC = () => {
const [isModalOpen, setIsModalOpen] = useState(false);
const [isMenuOpen, setIsMenuOpen] = useState(false);
const [initialStep, setInitialStep] = useState<"main" | "signup">("main");
const { isLoggedIn, logout: clearAuthState } = useAuthStore();

useEffect(() => {
if (isLoggedIn) {
setIsModalOpen(false);
}
}, [isLoggedIn]);

const handleLogout = async () => {
try {
await logout();
clearAuthState();
alert("로그아웃 성공!");
} catch (error) {
console.error(error);
alert("로그아웃 실패!");
}
};

const handleOpenLoginModal = () => {
setInitialStep("main");
Expand Down Expand Up @@ -67,9 +88,31 @@ const Navigation: React.FC = () => {
</NavItems>
</div>
</div>
<div className="auth-buttons">
<LoginText onClick={handleOpenLoginModal}>로그인</LoginText>
<SignUpButton onClick={handleOpenSignupModal}>회원가입</SignUpButton>
<div className="">
{isLoggedIn ? (
<div
style={{
display: "flex",
alignItems: "center",
}}
>
<LoginText onClick={handleLogout}>로그아웃</LoginText>
<Image
style={{ cursor: "pointer" }}
src={userIcon}
width={38}
height={38}
alt="mypage"
/>
</div>
) : (
<>
<LoginText onClick={handleOpenLoginModal}>로그인</LoginText>
<SignUpButton onClick={handleOpenSignupModal}>
회원가입
</SignUpButton>
</>
)}
</div>
{isMenuOpen && (
<>
Expand Down
1 change: 1 addition & 0 deletions src/components/Navigation/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const NavContainer = styled.nav`
position: sticky;
top: 0;
width: 100%;
height: 80px;
z-index: 1000;
justify-content: space-between;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Newpost/Newpost.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Style from "./styles";
import SelectStackType from "../SelectStackType/SelectStackType";
import NewpostEditor from "./MDEditor/MDEditor";
import NewpostEditor from "./MDEditor/mdeditor";
import { useEffect, useRef, useState } from "react";
import NewpostImages from "./ImageUpload/ImageUpload";
import { useAppDispatch } from "@/stores";
Expand Down
2 changes: 1 addition & 1 deletion src/data/cardDummyDatas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const dummyData = Array.from({ length: 100 }, (_, index) => ({
"https://velog.velcdn.com/images/yena1025/post/295eb434-5b73-421f-bbe4-6bc13acd4c33/image.png",
title: `프로젝트 ${index + 1}`,
description: "외국인 유학생을 위한 앱",
likes: 123 + index,
likes: 124 + index,
author: "캡스톤 30조",
}));

Expand Down
Loading

0 comments on commit 67caab2

Please sign in to comment.