Commit 8c1c74f5 authored by Spark's avatar Spark
Browse files

cookies component

parent 7a11adee
import React from 'react'
import { Swal } from 'sweetalert2';
export function checkCookies() {
const acctoken_cookies = document.cookie.split('=')[1];
return acctoken_cookies;
}
export function deleteCookie (name) {
document.cookie = name + '=; expires=Thu, 01 Jan 1999 00:00:10 GMT;';
Swal.fire({
title: '로그아웃 성공!',
text: '🙏 안녕히 가세요 🙏',
icon: 'warning',
customClass: 'swal-wide',
confirmButtonText: '확인',
}).then((res) => {
if (res.isConfirmed) {
window.location.replace('/')
}
else {
window.location.replace('/')
}
})
}
\ No newline at end of file
......@@ -6,6 +6,8 @@ import UserInfo from './UserInfo';
import { kakaoLogout } from '../utils/Oauth';
import axios from 'axios';
import { Swal } from 'sweetalert2';
import { deleteCookie } from '../utils/Cookies';
import { checkCookies } from './../utils/Cookies';
function MainLayer() {
......@@ -34,8 +36,6 @@ function MainLayer() {
color: 'white'
}
const acctoken_cookies = document.cookie.split('=')[1];
// console.log(acctoken_cookies)
const logined = localStorage.getItem('nickname')
const [airUsing, setAirUsing] = useState(false)
......@@ -55,23 +55,7 @@ function MainLayer() {
}
});
var deleteCookie = function (name) {
document.cookie = name + '=; expires=Thu, 01 Jan 1999 00:00:10 GMT;';
Swal.fire({
title: '로그아웃 성공!',
text: '🙏 안녕히 가세요 🙏',
icon: 'warning',
customClass: 'swal-wide',
confirmButtonText: '확인',
}).then((res) => {
if (res.isConfirmed) {
window.location.replace('/')
}
else {
window.location.replace('/')
}
})
}
return (
......@@ -86,7 +70,7 @@ function MainLayer() {
<UserInfo />
</Row>
{acctoken_cookies &&
{checkCookies() &&
<Form
key='checkbox' className="d-flex justify-content-center w-100" style={{ flexDirection: 'row-reverse' }}>
<Form.Check
......@@ -101,7 +85,7 @@ function MainLayer() {
<Row className='d-flex justify-content-center align-items-center my-2 mx-auto w-100'>
<ButtonGroup vertical className='m-auto' style={{ width: '100%', flexDirection: 'column' }}>
{acctoken_cookies ?
{checkCookies() ?
//true
<Button variant='light' style={btnstyled} onClick={kakaoLogout || deleteCookie('acs_token')}>
로그아웃
......@@ -114,7 +98,7 @@ function MainLayer() {
</Link>
</Button>
}
{!acctoken_cookies &&
{!checkCookies() &&
<Button variant='light' style={btnstyled}>
<Link to='/signup' id='btnlink'>
회원가입
......
......@@ -47,20 +47,6 @@ function SignupComp() {
}
console.log('???', formValues)
// function CheckUserExist() {
// const signUser = localStorage.getItem('signup_username')
// const signEmail = localStorage.getItem('signup_email_Address').split('@')[1]
// if (signEmail && signUser) {
// setAlertShow(true)
// setUserExist(!userExist)
// }
// else
// if (!signEmail) {
// setAlertShow(false)
// }
// }
async function handleSubmit(event) {
event.preventDefault();
await axios.post("/api/signup", formValues)
......
......@@ -2,6 +2,7 @@ import React, { useState } from 'react'
import { Row, Card, Button, Col, Modal } from 'react-bootstrap';
import '../App.css'
import { Link } from 'react-router-dom';
import { checkCookies } from './../utils/Cookies';
function UserInfo() {
......@@ -44,7 +45,7 @@ function UserInfo() {
<Card style={cardstyled} id='localName'>
<Card.Title>
<strong>
{nickname ?
{checkCookies() ?
<h2>
{`${nickname}`}
</h2>
......@@ -76,7 +77,7 @@ function UserInfo() {
</p>
}
</Card.Subtitle>
{nickname &&
{checkCookies() &&
<Button variant='light' className='m-auto d-flex' style={btnstyled2}>
<Link to='/edit' className='w-100' style={{ textDecoration: 'none', color: 'rgb(110, 189, 142)' }}>
변경
......@@ -84,7 +85,7 @@ function UserInfo() {
</Button>
}
</Row>
{nickname &&
{checkCookies() &&
<p className='w-100 justify-content-center m-auto'>
<hr />
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment