diff --git a/src/components/settings/createMeeting.js b/src/components/settings/createMeeting.js new file mode 100644 index 0000000..32ba45a --- /dev/null +++ b/src/components/settings/createMeeting.js @@ -0,0 +1,44 @@ +import { useState } from 'react'; +import axios from 'axios'; +import CategorySelect from '../categorySelect'; + +export default function CreateMeeting({ setIsExist, setWantEdit }) { + const [meetingTitle, setMeetingTitle] = useState(''); + const [category, setCategory] = useState(''); + const [meetingDesc, setMeetingDesc] = useState(''); + const onCreateMeeting = async () => { + var data = new FormData(); + data.append('CategorySeq', category); + data.append('meetingTitle', meetingTitle); + data.append('meetingDesc', meetingDesc); + data.append('meetingCamType', 0); + data.append('meetingMicType', 0); + axios + .post(process.env.REACT_APP_SERVER_URL + '/meetings', data, { + headers: { + Authorization: `Bearer ${localStorage.getItem('accessToken')}`, + }, + }) + .then((response) => { + setIsExist(true); + setWantEdit(false); + }); + }; + return ( +
+
자유열람실 생성
+
생성된 자유열람실이 없습니다. 자유열람실을 생성해주세요.
+
카테고리 선택: {setCategory && }
+
+ 자유열람실 이름:{' '} + setMeetingTitle(e.target.value)} />{' '} +
+
+ 자유열람실 설명:{' '} + setMeetingDesc(e.target.value)}> +
+ + +
+ ); +} diff --git a/src/components/settings/editMeeting.js b/src/components/settings/editMeeting.js new file mode 100644 index 0000000..cfcaedc --- /dev/null +++ b/src/components/settings/editMeeting.js @@ -0,0 +1,82 @@ +import { useEffect, useState } from 'react'; +import CategorySelect from '../categorySelect'; +import axios from 'axios'; + +export default function EditMeeting({ setWantEdit, setIsExist }) { + const [myMeeting, setMyMeeting] = useState(); + const [meetingSeq, setMeetingSeq] = useState(); + const [category, setCategory] = useState(); + const [meetingTitle, setMeetingTitle] = useState(); + const [meetingDesc, setMeetingDesc] = useState(); + + const getMyMeeting = async () => { + axios + .get(process.env.REACT_APP_SERVER_URL + '/users/meetings', { + headers: { + Authorization: `Bearer ${localStorage.getItem('accessToken')}`, + }, + }) + .then((response) => { + setMyMeeting(() => response.data.meetingInfo); + setMeetingSeq(() => response.data.meetingInfo.meetingSeq); + setCategory(() => response.data.meetingInfo.categoryseq); + setMeetingTitle(() => response.data.meetingInfo.meetingTitle); + setMeetingDesc(() => response.data.meetingInfo.meetingDesc); + }); + }; + useEffect(() => { + getMyMeeting(); + }, []); + const onSaveChange = async () => { + var data = new FormData(); + data.append('meetingSeq', meetingSeq); + data.append('categorySeq', category); + data.append('meetingTitle', meetingTitle); + data.append('meetingDesc', meetingDesc); + data.append('meetingCamType', 0); + data.append('meetingMicType', 0); + await axios + .patch(process.env.REACT_APP_SERVER_URL + `/users/meetings/${meetingSeq}`, data, { + headers: { + Authorization: `Bearer ${localStorage.getItem('accessToken')}`, + }, + }) + .then((response) => { + setWantEdit(() => false); + setIsExist(() => true); + }); + }; + const onDelete = async () => { + await axios + .delete(process.env.REACT_APP_SERVER_URL + `/users/meetings/${meetingSeq}`, { + headers: { + Authorization: `Bearer ${localStorage.getItem('accessToken')}`, + }, + }) + .then((response) => { + setWantEdit(() => false); + setIsExist(() => false); + }); + }; + return ( +
+
미팅룸 수정
+ {myMeeting && ( +
+
+ 자유열람실 카테고리: +
+
+ 자유열람실 이름:{' '} + setMeetingTitle(e.target.value)}> +
+
+ 미팅룸 설명: