From 4edab75d7fbc40b59fcb8470d52e5d25320b5af7 Mon Sep 17 00:00:00 2001 From: YearaChoi <22200750@handong.ac.kr> Date: Fri, 7 Jun 2024 13:47:29 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=BD=98=ED=8B=B0=20=EB=B3=B4=EA=B4=80?= =?UTF-8?q?=ED=95=A8=20=EC=95=85=EB=B3=B4=EC=97=90=20ReadContiModalMemo=20?= =?UTF-8?q?=EC=97=B0=EA=B2=B0,=20=EC=BD=98=ED=8B=B0=20=ED=81=B4=EB=A6=AD?= =?UTF-8?q?=20API=20=EC=97=B0=EA=B2=B0=20=ED=95=84=EC=9A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/atom.js | 7 +- src/components/MainPage/ContiSheetStorage.jsx | 23 +++--- src/components/Modal/ReadContiModalMemo.jsx | 82 +++++++++---------- 3 files changed, 59 insertions(+), 53 deletions(-) diff --git a/src/atom.js b/src/atom.js index 3e206af..068083b 100644 --- a/src/atom.js +++ b/src/atom.js @@ -40,6 +40,11 @@ export const musicIdState = atom({ default: null, }); +export const setListIdState = atom({ + key: "setListIdState", + default: null, +}); + export const musicIdListState = atom({ key: "musicIdListState", default: [], @@ -53,4 +58,4 @@ export const contiStepModalState = atom({ export const contiIdState = atom({ key: "contiIdState", default: null, -}) +}); diff --git a/src/components/MainPage/ContiSheetStorage.jsx b/src/components/MainPage/ContiSheetStorage.jsx index eadd29d..a4ad1dc 100644 --- a/src/components/MainPage/ContiSheetStorage.jsx +++ b/src/components/MainPage/ContiSheetStorage.jsx @@ -3,10 +3,16 @@ import styled from "styled-components"; import SelectMonthDropdown from "./SelectMonthDropDown"; import SelectYearDropdown from "./SelectYearDropDown"; import { useSetRecoilState } from "recoil"; -import { contiIdState, musicIdState, readMusicModalState } from "../../atom"; +import { + contiIdState, + musicIdState, + readMusicModalMemoState, + readMusicModalState, +} from "../../atom"; import { useRecoilValue } from "recoil"; import getContiMusicList from "../../apis/getcontiMusicList"; import ModifyContiModal from "../Modal/ModifyContiModal"; +import ReadContiModalMemo from "../Modal/ReadContiModalMemo"; const DateContainer = styled.div` /* border: 1px solid blue; */ @@ -81,19 +87,16 @@ const SheetInfoOverlay = styled.div` } `; - - export default function ContiSheetStorage() { - const readMusicModal = useSetRecoilState(readMusicModalState); - const [sheetMusic,setSheetMusic] = useState([]); + const readMusicModal = useSetRecoilState(readMusicModalMemoState); + const [sheetMusic, setSheetMusic] = useState([]); const toggleReadMusicModal = () => { readMusicModal((prevState) => !prevState); }; const setMusicId = useSetRecoilState(musicIdState); const setListId = useRecoilValue(contiIdState); - console.log("setListId",setListId) - + console.log("setListId", setListId); useEffect(() => { const fetchMusicList = async () => { @@ -102,14 +105,12 @@ export default function ContiSheetStorage() { }; fetchMusicList(); }, [setListId]); -console.log("sheetMusicData:",sheetMusic); - - + console.log("sheetMusicData:", sheetMusic); return ( <> - + diff --git a/src/components/Modal/ReadContiModalMemo.jsx b/src/components/Modal/ReadContiModalMemo.jsx index 613bf8e..7729cfa 100644 --- a/src/components/Modal/ReadContiModalMemo.jsx +++ b/src/components/Modal/ReadContiModalMemo.jsx @@ -168,9 +168,9 @@ export default function ReadContiModalMemo() { setIsEditable(false); }; - const toggleEditMode = () => { - setIsEditable((prevState) => !prevState); - }; + // const toggleEditMode = () => { + // setIsEditable((prevState) => !prevState); + // }; const handleChange = (e) => { const { name, value } = e.target; @@ -213,42 +213,42 @@ export default function ReadContiModalMemo() { }; }, [isModalOpen]); - const handleSubmit = async () => { - console.log("Form Data Submitted: ", formData); - try { - const { musicName, code, link, description, version } = formData; - const groupId = localStorage.getItem("groupId"); - console.log("Group ID:", groupId); - - const formDataToSend = new FormData(); - formDataToSend.append("musicName", musicName); - formDataToSend.append("code", code); - formDataToSend.append("link", link); - formDataToSend.append("description", description); - formDataToSend.append("groupId", groupId); - formDataToSend.append("version", version); - - await updateMusic(formDataToSend, musicId); - setIsEditable(false); - } catch (error) { - console.error("악보 수정 실패:", error); - } - }; - - const handleDelete = async () => { - if (window.confirm("삭제하시겠습니까?")) { - try { - await deleteMusic(musicId); - window.location.reload(); - } catch (error) { - console.error("악보 삭제 실패:", error); - } - } else { - alert("취소"); - } - }; - - console.log({ isModalOpen }); + // const handleSubmit = async () => { + // console.log("Form Data Submitted: ", formData); + // try { + // const { musicName, code, link, description, version } = formData; + // const groupId = localStorage.getItem("groupId"); + // console.log("Group ID:", groupId); + + // const formDataToSend = new FormData(); + // formDataToSend.append("musicName", musicName); + // formDataToSend.append("code", code); + // formDataToSend.append("link", link); + // formDataToSend.append("description", description); + // formDataToSend.append("groupId", groupId); + // formDataToSend.append("version", version); + + // await updateMusic(formDataToSend, musicId); + // setIsEditable(false); + // } catch (error) { + // console.error("악보 수정 실패:", error); + // } + // }; + + // const handleDelete = async () => { + // if (window.confirm("삭제하시겠습니까?")) { + // try { + // await deleteMusic(musicId); + // window.location.reload(); + // } catch (error) { + // console.error("악보 삭제 실패:", error); + // } + // } else { + // alert("취소"); + // } + // }; + + // console.log({ isModalOpen }); return ( <> @@ -276,11 +276,11 @@ export default function ReadContiModalMemo() { - 쓰레기통 아이콘 + /> */} 공유 아이콘 프린트 아이콘