From b91bbecb1be55b96f92eaca6f4bb8d33982b0834 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Sat, 28 Nov 2020 00:28:02 +0300
Subject: feat: match new event interface

---
 src/containers/BsuFantomSection/EventForm.tsx | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

(limited to 'src/containers/BsuFantomSection/EventForm.tsx')

diff --git a/src/containers/BsuFantomSection/EventForm.tsx b/src/containers/BsuFantomSection/EventForm.tsx
index d92ad44..528636f 100644
--- a/src/containers/BsuFantomSection/EventForm.tsx
+++ b/src/containers/BsuFantomSection/EventForm.tsx
@@ -9,7 +9,7 @@ interface PropTypes {
 
 const EventForm: React.FC<PropTypes> = ({ mutate }) => {
   const [name, setName] = useState<string>('');
-  const [date, setDate] = useState<string>((new Date()).toLocaleDateString());
+  const [schedule, setSchedule] = useState<string>('* * * * * *');
   const [attendanceId, setAttendanceId] = useState<string>('');
   const [conferenceId, setConferenceId] = useState<string>('');
 
@@ -18,19 +18,21 @@ const EventForm: React.FC<PropTypes> = ({ mutate }) => {
   };
 
   const handleSubmit = () => {
-    if (date && conferenceId) {
-      const event: Event["data"] = {
+    if (schedule && conferenceId) {
+      const event: Partial<Event> = {
         name,
-        date: date + ' +03:00',
-        attendanceId,
-        conferenceId,
-        participants: []
-      }
+        schedule,
+        context: {
+          attendanceId,
+          conferenceId,
+          participants: []
+        }
+      };
 
       setName('');
       setAttendanceId('');
       setConferenceId('');
-      setDate('');
+      setSchedule('');
 
       return post('/events', event).then(() => mutate());
     }
@@ -50,8 +52,8 @@ const EventForm: React.FC<PropTypes> = ({ mutate }) => {
       </Grid>
       <Grid item sm={6} xs={12}>
         <TextField
-          value={date}
-          onChange={createHandler(setDate)}
+          value={schedule}
+          onChange={createHandler(setSchedule)}
           variant="outlined"
           label="Date"
           fullWidth
-- 
cgit v1.2.3

