Skip to content

Commit

Permalink
Merge branch 'main' into feat/103-diary-update-response-handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mingxoxo committed Nov 22, 2023
2 parents e341e80 + 7d892e8 commit f87e0b3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
25 changes: 24 additions & 1 deletion FE/src/components/DiaryModal/DiaryDeleteModal.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
import React from "react";
import { useMutation } from "react-query";
import styled from "styled-components";
import { useSetRecoilState } from "recoil";
import { useRecoilValue, useSetRecoilState } from "recoil";
import diaryAtom from "../../atoms/diaryAtom";
import userAtom from "../../atoms/userAtom";
import ModalWrapper from "../../styles/Modal/ModalWrapper";

async function deleteDiaryFn(data) {
return fetch(`http://223.130.129.145:3005/diaries/${data.diaryUuid}`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${data.accessToken}`,
},
});
}

function DiaryDeleteModal() {
const diaryState = useRecoilValue(diaryAtom);
const userState = useRecoilValue(userAtom);
const setDiaryState = useSetRecoilState(diaryAtom);
const {
mutate: deleteDiary,
// isLoading,
// error,
} = useMutation(deleteDiaryFn);

return (
<DeleteModalWrapper left='50%' width='15vw' height='10vh' opacity='0'>
Expand All @@ -23,6 +42,10 @@ function DiaryDeleteModal() {
</DeleteModalButton>
<DeleteModalButton
onClick={() => {
deleteDiary({
diaryUuid: diaryState.diaryUuid,
accessToken: userState.accessToken,
});
setDiaryState((prev) => ({
...prev,
isRead: false,
Expand Down
2 changes: 1 addition & 1 deletion FE/src/pages/MainPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function MainPage() {
<MainPageWrapper
onClick={(e) => {
e.preventDefault();
setDiaryState((prev) => ({ ...prev, isRead: true }));
setDiaryState((prev) => ({ ...prev, isCreate: true }));
}}
>
<MainTitle>대충 메인 페이지</MainTitle>
Expand Down

0 comments on commit f87e0b3

Please sign in to comment.