Skip to content

Commit

Permalink
✨ Feat: 로그인 api 연결 (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
GraceKim527 committed Feb 7, 2025
1 parent 25f0434 commit 2781b2f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { GoormLoader } from '@goorm-dev/gds-components';
import { Suspense, lazy } from 'react';
import { RouterProvider, createBrowserRouter } from 'react-router-dom';
import Layout from './components/layout/Layout';
import SignUp from './pages/updatePW/UpdatePW';

const About = lazy(() => import('./pages/about/About'));
const Project = lazy(() => import('./pages/project/Project'));
const Recruit = lazy(() => import('./pages/recruit/Recruit'));
Expand All @@ -13,6 +11,7 @@ const Information = lazy(() => import('./pages/information/Information'));
const MyPage = lazy(() => import('./pages/myPage/MyPage'));
const UpdatePW = lazy(() => import('./pages/updatePW/UpdatePW'));
const IdeaList = lazy(() => import('./pages/hackathon/IdeaList/IdeaList'));
const SignUp = lazy(() => import('./pages/signUp/SignUp'));

const IdeaCreate = lazy(() => import('./pages/hackathon/IdeaCreate/IdeaCreate'));

Expand Down
2 changes: 1 addition & 1 deletion src/api/instance.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios';

const instance = axios.create({
baseURL: process.env.REACT_APP_BASE_URL,
baseURL: import.meta.env.VITE_APP_BASE_URL,
headers: { 'Content-Type': 'application/json' },
withCredentials: true,
});
Expand Down
17 changes: 15 additions & 2 deletions src/components/signUp/SignUpCard.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import styles from './signUpCard.module.scss';
import { WarningIcon } from '@goorm-dev/gds-icons';
import { WarningIcon } from '@goorm-dev/vapor-icons';
import { Text, Input, Button, Alert } from '@goorm-dev/vapor-components';
import { ChangeEvent, useState } from 'react';
import Logo from '../../assets/images/goormthon_univ_BI-Bk.png';
import { loginAPI } from '../../api/auth';
import { useNavigate } from 'react-router-dom';

export default function SignUpCard() {
const navigate = useNavigate();

const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [errorMessage, setErrorMessage] = useState<string | null>(null);
Expand All @@ -23,6 +27,15 @@ export default function SignUpCard() {
};

const handleLogin = async () => {
try {
const response = await loginAPI(email, password);
console.log(response);

navigate('/');
} catch (error) {
console.error('로그인 실패', error);
}

if (!email && !password) {
setErrorMessage('이메일을 입력해주세요');
return;
Expand Down Expand Up @@ -53,7 +66,7 @@ export default function SignUpCard() {
로그인
</Button>
{errorMessage && (
<Alert color="danger" leftIcon={WarningIcon}>
<Alert color="danger" leftIcon={WarningIcon} className={styles.alignCenter}>
{errorMessage}
</Alert>
)}
Expand Down
4 changes: 4 additions & 0 deletions src/components/signUp/signUpCard.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@
width: 16rem;
margin-bottom: var(--space-600);
}

.alignCenter {
text-align: left;
}
File renamed without changes.
File renamed without changes.

0 comments on commit 2781b2f

Please sign in to comment.