diff --git a/react-native/components/BottomDrawer.tsx b/react-native/components/BottomDrawer.tsx
index 740e7a0..5c36310 100644
--- a/react-native/components/BottomDrawer.tsx
+++ b/react-native/components/BottomDrawer.tsx
@@ -9,14 +9,13 @@ import { useAuth } from '../contexts/Auth';
const highlight = (text: string, registered: boolean) =>
{text}
-let date = new Date();
function BottomDrawer(props: BottomDrawerProps) {
const [currentEvent, setCurrentEvent] = useState(0);
const [openSaveForm, setOpenSaveForm] = useState(false);
const [resultsTitle, setResultsTitle] = useState('title');
const [openEventForm, setOpenEventForm] = useState(false);
- const [eventForm, setEventForm] = useState({title: '', date: '', cId: 1, description: ''});
+ const [eventForm, setEventForm] = useState({cId: 1, title: '', date: '', description: ''});
// TEST: mockup data
const [user, setUser] = useState({uid: 1, uprofileImg: 1, username: 'hee', ulanguage: 'ko', uchildren: [{cid: 1, cname: 'soo', color: 1}, {cid: 2, cname: 'joo', color: 3}]})
// const [user, setUser] = useState();
@@ -47,19 +46,8 @@ function BottomDrawer(props: BottomDrawerProps) {
const closePopup = () => {
setCurrentEvent(0);
}
-
- const handleOpenSaveForm = (prop?: string) => {
- if (prop==='save') {
- // TODO: fetch api
- // data 보내고, success 라면, 서버에 저장된 제목 받아와서 보여주기!
- let data = {
- id: props?.results?.id,
- title: resultsTitle,
- date: date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate()
- }
- console.log(data);
- Alert.alert(`The result was saved in Search as [${resultsTitle}]`)
- }
+
+ const handleOpenSaveForm = () => {
if (openSaveForm) {
setResultsTitle('title');
}
@@ -75,8 +63,22 @@ function BottomDrawer(props: BottomDrawerProps) {
const addEvent = () => {
// TODO: fetch api
- // TEST
let status = "success";
+
+ if (auth?.authData?.jwt_token && eventForm) {
+ fetch("http://localhost:8080/notice/calendar", {
+ method: 'POST',
+ headers: {
+ 'JWT_TOKEN': auth.authData.jwt_token
+ },
+ body: JSON.stringify(eventForm),
+ redirect: 'follow'
+ })
+ .then(response => response.json())
+ .then(data => status = data)
+ .catch(error => console.log('error', error));
+ }
+
switch (status) {
case "success":
Alert.alert("The event has been successfully added to your calendar!");
@@ -129,9 +131,7 @@ function BottomDrawer(props: BottomDrawerProps) {
}}>
Cancel
-