From 3036d83dd5a2af763ba1baa0ff390b003519ea1a Mon Sep 17 00:00:00 2001 From: kim jihwan Date: Fri, 16 Aug 2024 16:37:28 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20login=20=EB=AA=A8=EB=93=88=ED=99=94=20/?= =?UTF-8?q?=20homepage=20add=20login=20btn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/HomePage/HomePage.tsx | 14 ++++++++++---- src/pages/LoginPage/LoginPage.tsx | 26 +++++--------------------- 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/src/pages/HomePage/HomePage.tsx b/src/pages/HomePage/HomePage.tsx index 22c1cf9..b7ac8d2 100644 --- a/src/pages/HomePage/HomePage.tsx +++ b/src/pages/HomePage/HomePage.tsx @@ -1,12 +1,14 @@ +import { SetStateAction, useState } from "react"; +import { Link, useNavigate } from "react-router-dom"; + +import alarm from "@/assets/icon_alarm.svg"; import setting from "@/assets/icon_setting.svg"; import logoSpace from "@/assets/logo_space.svg"; -import alarm from "@/assets/icon_alarm.svg"; +import { BottomBtn } from "@/components/BottomBtn"; import bannerImage from "@/pages/HomePage/bannerImage.svg"; import bannerImageCover from "@/pages/HomePage/bannerImageCover.svg"; -import next from "@/pages/HomePage/icon_next.svg"; import * as sty from "@/pages/HomePage/HomePage.styled"; -import { SetStateAction, useState } from "react"; -import { useNavigate } from "react-router-dom"; +import next from "@/pages/HomePage/icon_next.svg"; const HomePage = () => { const navigate = useNavigate(); @@ -44,6 +46,10 @@ const HomePage = () => {
스페이서 20
+ + 로그인 + +
diff --git a/src/pages/LoginPage/LoginPage.tsx b/src/pages/LoginPage/LoginPage.tsx index aaa4693..22d61b7 100644 --- a/src/pages/LoginPage/LoginPage.tsx +++ b/src/pages/LoginPage/LoginPage.tsx @@ -1,10 +1,11 @@ import React, { useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; +import axios from "axios"; + import { loginApi } from "@/apis"; import google from "@/assets/Login/icon_google.svg"; import kakao from "@/assets/Login/icon_kakao.svg"; import naver from "@/assets/Login/icon_naver.svg"; -import axios from "axios"; import logoSpace from "@/assets/logo_space.svg"; import { BtContainer, @@ -40,26 +41,9 @@ const LoginPage = () => { const handleLogin = async () => { if (!isButtonActive) return; - try { - const response = await axios.post("/api/user/login", { - email: email, - password: password, - }); - - if (response.status === 200) { - const token = response.headers.authorization; - localStorage.setItem("jwt", token); - navigate("/dashboard"); - } else { - console.error("로그인 실패:", response.data.message); - } - } catch (error) { - if (error instanceof Error) { - console.error("로그인 실패:", error.message); - } else { - console.error("로그인 실패:", error); - } - } + loginApi(email, password).then((res) => + res.status === "OK" ? navigate("/") : alert("login error: " + res.message), + ); }; return (