Skip to content

Commit

Permalink
[feat] Store academy & circle data at session storage
Browse files Browse the repository at this point in the history
  • Loading branch information
WooHyunKing committed Sep 5, 2023
1 parent f7336c6 commit 8f9c723
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 8 deletions.
45 changes: 44 additions & 1 deletion src/atoms/memberAtom.ts
@@ -1 +1,44 @@
export const value = null;
import { atom } from "recoil";

interface IStudentAcademyList {
aplyColgCd: string;
aplyDt: string;
aplyShtmCd: string;
aplySustCd: string;
aplyYy: string;
diuseDt: string;
emplNo: string;
intApprCtnt: string;
meatngCd: string;
meatngFg: string;
meatngFondtPurp: string;
meatngFormaPrecon: string;
meatngNm: string;
meatngTypeCd: string;
modDttm: number;
modId: string;
modIp: string;
modPosbYn: string;
modPosbYnNm: string;
rcnt: number;
recaResn: string;
regDttm: number;
regId: string;
regIp: string;
rowStatus: number;
tretSt1: string;
tretSt2: string;
tretSt3: string;
tretStNm: string;
useYn: string;
}

export const studentAcademyListAtom = atom<IStudentAcademyList[]>({
key: "studentAcademyList",
default: [],
});

export const studentCircleListAtom = atom<IStudentAcademyList[]>({
key: "studentCircleList",
default: [],
});
18 changes: 11 additions & 7 deletions src/pages/account/login/Login.tsx
Expand Up @@ -4,11 +4,18 @@ import { useRecoilState } from "recoil";
import styled from "styled-components";
import { accountAtom } from "../../../atoms/accountAtom";
import axios from "axios";
import {
studentAcademyListAtom,
studentCircleListAtom,
} from "../../../atoms/memberAtom";

const Login = () => {
const [id, setId] = useState("");
const [password, setPassword] = useState("");
const [studentId, setStudentId] = useState("");
const [academyList, setAcademyList] = useRecoilState(studentAcademyListAtom);
const [circleList, setCircleList] = useRecoilState(studentCircleListAtom);
const navigate = useNavigate();

const loginPost = async (id: string, password: string, studentId: string) => {
const response = await axios.post(
Expand All @@ -25,14 +32,11 @@ const Login = () => {
}
);

// const response = await fetch("/login",{
// method:"POST",
// headers:{
// 'Content-Type': "application/json"
// },
// })
sessionStorage.setItem("token", response.data.accessToken);
setAcademyList(response.data.studentAcademyInfo);
setCircleList(response.data.studentCircleInfo);

console.log(response);
navigate("/member-club");
};

const onSumbit = (e: React.FormEvent<HTMLFormElement>) => {
Expand Down

0 comments on commit 8f9c723

Please sign in to comment.