Skip to content

Commit

Permalink
Merge pull request #187 from boostcampwm2023/hotfix/update-rollback
Browse files Browse the repository at this point in the history
[hotfix] 일기 수정 버그 고치기 위해 롤백
  • Loading branch information
dbwhdtjr0457 authored Nov 30, 2023
2 parents cd2f6ca + 9c23233 commit 1aee6a5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 37 deletions.
4 changes: 2 additions & 2 deletions FE/src/components/DiaryModal/DiaryCreateModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function DiaryCreateModal(props) {
body: JSON.stringify(data.diaryData),
})
.then((res) => {
if (res.status === 200) {
if (res.status === 201) {
return res.json();
}
if (res.status === 403) {
Expand All @@ -75,7 +75,7 @@ function DiaryCreateModal(props) {
sessionStorage.removeItem("accessToken");
window.location.href = "/";
}
throw new Error("일기 작성에 실패했습니다.");
throw new Error("error");
})
.then(() => {
refetch();
Expand Down
2 changes: 1 addition & 1 deletion FE/src/components/DiaryModal/DiaryDeleteModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function DiaryDeleteModal(props) {
},
})
.then((res) => {
if (res.status === 200) {
if (res.status === 204) {
return res;
}
if (res.status === 403) {
Expand Down
44 changes: 10 additions & 34 deletions FE/src/components/DiaryModal/DiaryUpdateModal.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable */

import React, { useState, useEffect, useRef } from "react";
import { useRecoilState, useRecoilValue } from "recoil";
import { useMutation, useQuery } from "react-query";
Expand All @@ -17,19 +19,7 @@ async function getDiary(accessToken, diaryUuid) {
"Content-Type": "application/json",
Authorization: `Bearer ${accessToken}`,
},
}).then((res) => {
if (res.status === 200) {
return res.json();
}
if (res.status === 403) {
alert("로그인이 만료되었습니다. 다시 로그인해주세요.");
localStorage.removeItem("accessToken");
sessionStorage.removeItem("accessToken");
window.removeEventListener("beforeunload", preventBeforeUnload);
window.location.href = "/";
}
return {};
});
}).then((res) => res.json());
}

// TODO: 일기 데이터 수정 API 연결
Expand Down Expand Up @@ -60,27 +50,13 @@ function DiaryUpdateModal(props) {
Authorization: `Bearer ${data.accessToken}`,
},
body: JSON.stringify(data.diaryData),
})
.then((res) => {
if (res.status === 200) {
return res;
}
if (res.status === 403) {
alert("로그인이 만료되었습니다. 다시 로그인해주세요.");
localStorage.removeItem("accessToken");
sessionStorage.removeItem("accessToken");
window.removeEventListener("beforeunload", preventBeforeUnload);
window.location.href = "/";
}
return null;
})
.then(() => {
refetch();
setDiaryState((prev) => ({
...prev,
isLoading: true,
}));
});
}).then(() => {
refetch();
setDiaryState((prev) => ({
...prev,
isLoading: true,
}));
});
}

useEffect(() => {
Expand Down

0 comments on commit 1aee6a5

Please sign in to comment.