Skip to content

Commit

Permalink
Chore: reset recoil when logout or del account #125
Browse files Browse the repository at this point in the history
  • Loading branch information
seo0o519 committed May 28, 2024
1 parent 6a5ea4a commit 6b7828e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/pages/MypagePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ import DoDisturbOutlinedIcon from "@mui/icons-material/DoDisturbOutlined";
import CancelContent from "../components/common/CancelContent";
import BottomNav from "../layout/BottomNav";
import axios from "axios";
import { useRecoilState } from "recoil";
import { tripNameState, tripIdState, diaryIdState } from "../recoil/commonState";

const MypagePage = () => {
//axios get으로 받아온 username location으로 전달
const navigate = useNavigate();
const [isModalOpen, setIsModalOpen] = useState(false);
const [message, setMessage] = useState("");
const [userInfo, setUserInfo] = useState({ name: "", email: "", profileimg: "" });
const [tripName, setTripName] = useRecoilState(tripNameState);
const [tripId, setTripId] = useRecoilState(tripIdState);
const [diaryID, setDiaryId] = useRecoilState(diaryIdState);

const toggleModal = () => {
console.log(isModalOpen);
Expand Down Expand Up @@ -75,6 +80,9 @@ const MypagePage = () => {
.then((response) => {
const status = response.status;
if (status === 200) {
setTripName("");
setTripId("");
setDiaryId("");
setMessage("로그아웃 성공");
} else if (status === 401) {
setMessage("로그인이 필요합니다.");
Expand All @@ -95,6 +103,9 @@ const MypagePage = () => {
const status = response.status;
console.log("res",status);
if (status === 200) {
setTripName("");
setTripId("");
setDiaryId("");
setMessage("계정이 성공적으로 삭제되었습니다.");
} else if (status === 404) {
setMessage("사용자를 찾을 수 없습니다.");
Expand Down

0 comments on commit 6b7828e

Please sign in to comment.