Skip to content

Commit

Permalink
Merge pull request #18 from SIAT-Python-Project/feature/cookie/#14
Browse files Browse the repository at this point in the history
cookie진행중 login페이지동작 제대로 안될것으로 예상
  • Loading branch information
bbmini96 authored Jun 21, 2024
2 parents de87898 + cabb1db commit beabcb0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/pages/SignInPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { createTheme, ThemeProvider } from '@mui/material/styles';
import { useNavigate } from 'react-router-dom';
import { useEffect, useState } from 'react';
import { fetchUserLogin } from '../api/FectUser';
import { useCookies } from "react-cookie";



Expand All @@ -37,6 +38,7 @@ function Copyright(props) {

export default function SingInPage({ data }) {
const [userLogin, setUserLogin] = useState({ email: "", password: "" });
const [cookies, setCookie, removeCookie] = useCookies(['name']);
const navigate = useNavigate();

const handleInputChange = (e) => {
Expand All @@ -48,8 +50,10 @@ export default function SingInPage({ data }) {
event.preventDefault();
data = new FormData(event.currentTarget);
fetchUserLogin(userLogin.email, userLogin.password)
.then(() => {
navigate('/');
.then((name) => {
console.log(name)
// setCookie('name', name, { path: '#' });
// navigate('#');
})
.catch(error => {
alert("아이디 또는 패스워드가 맞지 않습니다");
Expand All @@ -72,7 +76,7 @@ export default function SingInPage({ data }) {
<LockOutlinedIcon />
</Avatar>
<Typography component="h1" variant="h5">
Sign in
로그인
</Typography>
<Box component="form" onSubmit={handleSubmit} noValidate sx={{ mt: 1 }}>
<TextField
Expand Down

0 comments on commit beabcb0

Please sign in to comment.