Skip to content

Commit

Permalink
Merge pull request #15 from HaruDamda/feature/#7-포토북-UI-작업
Browse files Browse the repository at this point in the history
feat: 로그아웃 및 로컬스토리지 구성
  • Loading branch information
haesol822 authored Nov 21, 2023
2 parents 88da1e0 + 19e61ea commit 2faa247
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 58 deletions.
3 changes: 3 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import {
} from "react-device-detect";
import FrameList from "./component/AllFrameCpn/FrameList";
import PhotoSelect from "./pages/Photobook/PhotoSelect";
// import { useAtom } from "jotai";
// import axios from "axios";
// import { accessTokenAtom, setAccessToken } from "./store/jotaiAtoms";

function App() {
function setScreenSize() {
Expand Down
3 changes: 2 additions & 1 deletion src/apis/emailCheck.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import axios from "axios";

export const emailCheck = (formData, setFormData) => {

axios
.post("api/users/idcheck", { email: formData.email })
.post(`http://ec2-3-35-208-177.ap-northeast-2.compute.amazonaws.com:8080/v2/api-docs/user/${formData.email}`)
.then(() => {
alert("사용할 수 있는 이메일입니다.");
})
Expand Down
27 changes: 3 additions & 24 deletions src/pages/Join/Join.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"use client";

import { useNavigate, Link } from "react-router-dom";
import { useState } from "react";
import styles from "./Join.module.scss";
Expand All @@ -11,7 +9,6 @@ export default function SignUp() {
const initialState = {
email: "",
nickname: "",
birth: "",
password: "",
passwordConfirm: "",
};
Expand All @@ -23,7 +20,6 @@ export default function SignUp() {
const [errorMessages, setErrorMessages] = useState({
email: "",
nickname: "",
birth: "",
password: "",
passwordConfirm: "",
});
Expand All @@ -32,7 +28,6 @@ export default function SignUp() {
const [isValid, setIsValid] = useState({
email: false,
nickname: false,
birth: false,
password: false,
passwordConfirm: false,
});
Expand Down Expand Up @@ -193,7 +188,7 @@ export default function SignUp() {
<span className={`message error`}>{errorMessages.email}</span>
)}
</div>
<div>
<div className={styles.boxWrapper}>
<h5>닉네임</h5>
<input
className={
Expand All @@ -209,7 +204,7 @@ export default function SignUp() {
<span className={`message error`}>{errorMessages.nickname}</span>
)}
</div>
<div>
<div className={styles.boxWrapper}>
<h5>비밀번호</h5>
<input
name="password"
Expand Down Expand Up @@ -240,23 +235,7 @@ export default function SignUp() {
</span>
)}
</div>
<div>
<h5>나이</h5>
<select
className={styles.ageScroll}
value={formData.birth || ""}
onChange={(e) =>
setFormData({ ...formData, birth: Number(e.target.value) })
}
>
<option value="">출생년도 입력(선택)</option>
{[...Array(87)].map((_, index) => (
<option key={index} value={2004 - index}>
{2004 - index}
</option>
))}
</select>
</div>

<div className={styles.agreeForm1}>
<div className={styles.allWrapper}>
<input
Expand Down
62 changes: 34 additions & 28 deletions src/pages/Join/Join.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@
display: flex;
align-items: center;
justify-content: center;
overflow-y: scroll;
}

.signUpBox {
Expand All @@ -213,11 +214,10 @@
// overflow: auto;
flex-direction: column;
// max-height: calc(100vh - 80px);
background-color: aliceblue;
.header {
width: 100vw;
height: 10vh;
background-color: #eaeaea;
background-color: white;
display: flex;
align-items: center;
justify-content: space-around;
Expand Down Expand Up @@ -246,60 +246,73 @@
}
}
.body {
width: 86vw;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;

span {
margin: 10px auto;
}
h5 {
width: 100vw;
width: 86vw;
text-align: left;
margin: 10px auto 0 11vw;
margin-top: 10px;
margin-bottom: 0;
font-weight: 600;
font-size: 14px;
color: #888;
}
.emailWrapper {
margin: 0;
width: 100vw;
background-color: #6ab5ff;
width: 86vw;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
}
.emailInputBox,
.emailInputBox1 {
width: 40vw;
width: 57vw;
height: 50px;
min-height: 50px;
padding: 0px 12px;
padding: 0px 3vw;
outline: none;
background-color: transparent;
border: 1px solid #e1e2e3;
border-radius: 5px;
// margin: 8px auto;
margin: 8px 0;
font-size: 16px;
color: #333;
}
.emailCheck {
cursor: pointer;
display: inline-block;
// margin: 0 0 8px 12px;
margin: 0;
outline: none;
border: 1px solid #e1e2e3;
font-size: 12px;
border-radius: 5px;
color: #333;
padding: 0px 12px;
background-color: #eaeaea;
// padding: 0px 3vw;
height: 50px;
bottom: 2px;
width: 20vw;
}
.inputBox,
.inputBox1,
.ageScroll {
width: 330px;
.boxWrapper {
margin: 0;
width: 86vw;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.inputBox, .inputBox1 {
width: 79.5vw;
height: 50px;
min-height: 50px;
padding: 0px 12px;
padding: 0px 3vw;
outline: none;
background-color: transparent;
border: 1px solid #e1e2e3;
Expand All @@ -312,9 +325,8 @@
.inputBox1 {
border: 1px solid #fe415c;
}
.emailCheck + span,
.inputBox1 + span {
width: 348px;
.emailWrapper + span, .inputBox1 + span {
width: 86vw;
color: #fe415c;
display: block;
text-align: left;
Expand All @@ -323,16 +335,10 @@
margin-bottom: 8px;
margin-top: 0px;
}
.ageScroll {
width: 356px;
padding: 0 8px;
color: #666;
margin-bottom: 20px;
}
}
.agreeForm1 {
margin: 4px auto;
width: 430px;
width: 86vw;
.allWrapper {
width: 100%;
display: flex;
Expand All @@ -359,7 +365,7 @@
}
.agreeForm2 {
margin: 4px auto;
width: 430px;
width: 86vw;
display: flex;
justify-content: flex-start;
align-items: center;
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Login/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useAtom } from "jotai";
import { accessTokenAtom } from "../../store/jotaiAtoms";
import axios from "axios";

export default function Login() {
export default function Main() {
return (
<>
<LoginForm />
Expand Down Expand Up @@ -69,6 +69,7 @@ function LoginForm() {
.then((res) => {
const accessToken = res.data;
setAct(accessToken); // 액세스 토큰을 Jotai 상태에 업데이트
localStorage.setItem("accessToken", `${accessToken}`);
router('/framelist');
})
.catch((err) => {
Expand Down
37 changes: 34 additions & 3 deletions src/pages/Main/Main.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,46 @@
import styles from "./Main.module.scss";
import { Link } from "react-router-dom";
import { Link, useNavigate } from "react-router-dom";
import main_logo from "../../assets/main-logo.png";
import { useAtom } from "jotai";
import { accessTokenAtom } from "../../store/jotaiAtoms";

export default function Login() {
const [accessToken, setAccessToken] = useAtom(accessTokenAtom);
const router = useNavigate();

const logout = () => {
if (confirm("정말 로그아웃 하시겠습니까?")) {
localStorage.removeItem("accessToken");
setAccessToken("");
router("/");
}
}

return (
<>
<div className={styles.root}>
<Link to="/login" className={styles.linkBtn_container}>
<button className={styles.linkBtn}>
<img src={main_logo} alt="main-logo" />
</button>
</Link>
</>
<button
className={styles.loginBtn}
onClick={() => router("/login")}
>
로그인
</button>
<button
className={styles.logoutBtn}
onClick={() => logout()}
>
로그아웃
</button>
<button
className={styles.frameBtn}
onClick={() => router("/framelist")}
>
프레임 만들기
</button>
</div>
);
}
21 changes: 21 additions & 0 deletions src/pages/Main/Main.module.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.root {
display: flex;
flex-direction: column;
align-items: center;
justify-items: center;
gap: 20px;
}
.linkBtn {
width: 100%;
height: 100%;
Expand All @@ -10,3 +17,17 @@
display: inline-flex;
}
}
button {
width: 50vw;
height: 46px;
background-color: #009EFF;
border: none;
border-radius: 50px;
color: white;
font-size: 14px;
}
.frameBtn {
background-color: #C4CAD4;
color: black;
font-weight: 500;
}
7 changes: 6 additions & 1 deletion src/store/jotaiAtoms.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import { atom } from 'jotai';

export const accessTokenAtom = atom("");
export const accessTokenAtom = atom(localStorage.getItem('accessToken') || '');

export const updateToken = (newToken) => {
localStorage.setItem('accessToken', newToken);
accessTokenAtom[1](newToken);
};

0 comments on commit 2faa247

Please sign in to comment.