diff --git a/src/App.js b/src/App.js index 6d70383..e782697 100644 --- a/src/App.js +++ b/src/App.js @@ -21,7 +21,7 @@ const existingUser = JSON.parse(localStorage.getItem('user')); export default function App() { const [isAuthenticated, setIsAuthenticated] = useState(!!existingToken); const [currentUser, setCurrentUser] = useState(existingUser || ''); - + const [participant, setParticipant] = useState(); const [possibleDates, setPossibleDates] = useState(); const [currentMeeting, setCurrentMeeting] = useState({ title: '', @@ -76,6 +76,7 @@ export default function App() { currentMeeting={currentMeeting} setCurrentMeeting={setCurrentMeeting} currentUser={currentUser} + setParticipant={setParticipant} /> + - diff --git a/src/screens/Availability.js b/src/screens/Availability.js index 4e3bc08..6fe89cd 100644 --- a/src/screens/Availability.js +++ b/src/screens/Availability.js @@ -20,19 +20,6 @@ import dtToUTC from '../helpers/datetimeToUTC'; import { backend } from '../helpers/http-common'; import './styles/Availability.less'; import './styles/layout.less'; -// // DEV possibleDates -// const possibleDates = [ -// { -// id: 63, -// start: '2020-08-01', -// display: 'background', -// }, -// { -// id: 64, -// start: '2020-08-02', -// display: 'background', -// }, -// ]; // NOTES: // Even though Fullcalendar is supposed to work with timezone, @@ -42,8 +29,8 @@ import './styles/layout.less'; export default function Availability({ currentUser, - currentMeeting, possibleDates, + participant, }) { const [availability, setAvailability] = useState([]); const [timezone, setTimezone] = useState(currentUser.timezone); @@ -84,8 +71,7 @@ export default function Availability({ ); return { - meeting_id: currentMeeting.id, - account_id: currentUser.id, + participant_id: participant.id, possible_date_id: date.id, preference: false, // set to 'true" when implementing preference start_time: dtToUTC(event.start, timezone), @@ -205,7 +191,9 @@ export default function Availability({ appearance='ghost' size='lg' block - onClick={() => history.push('dashboard')} + onClick={() => + history.push('dashboard') + } > Go to dashboard diff --git a/src/screens/Invite.js b/src/screens/Invite.js index 8bc0b0d..60c7487 100644 --- a/src/screens/Invite.js +++ b/src/screens/Invite.js @@ -56,6 +56,49 @@ export default function Invite() { setParticipants([]); }; + // const handleSubmit = () => { + // // Create a list of participants to post + // const participantsList = participants.map((participant) => { + // // + + // return { + // account_id: '', + // meeting_id: currentMeeting.id, + // quorum: 0, // update when implementing functionality + // mandatory: false, // update when implementing functionality + // host: 0, // update when implementing functionality + // answered: 0, + // }; + // }); + + // // Create participants post request + // const postAvailability = (data) => { + // return backend.post('/participants', data); + // }; + + // const requests = participantsList.map((event) => + // postAvailability(event), + // ); + + // Promise.all(requests) + // .then(function (results) { + // // Add confirmation message + // setStatus({ + // success: true, + // error: false, + // message: 'Your availability has been added to the meeting.', + // }); + // }) + // .catch((error) => { + // setStatus({ + // error: true, + // success: false, + // message: + // "Your availability couldn't be added to the meeting.", + // }); + // }); + // }; + return ( <> @@ -85,7 +128,7 @@ export default function Invite() { > Clear selection - diff --git a/src/screens/Schedule.js b/src/screens/Schedule.js index a761e6d..2221ce4 100644 --- a/src/screens/Schedule.js +++ b/src/screens/Schedule.js @@ -29,6 +29,7 @@ export default function Schedule({ currentMeeting, setCurrentMeeting, currentUser, + setParticipant, }) { const [eventsList, setEventsList] = useState([]); const [datesList, setDatesList] = useState(eventsToDates(eventsList)); @@ -147,6 +148,7 @@ export default function Schedule({ addParticipant({ account_id: currentUser.id, + email: currentUser.email, meeting_id: response.data.id, quorum: 0, // 'false' while functionality not implemented mandatory: 0, // 'false' while functionality not implemented @@ -163,6 +165,7 @@ export default function Schedule({ backend .post('/participants', data) .then((response) => { + setParticipant(response.data); addPossibleDates({ meeting_id: response.data.meeting_id }); }) .catch((error) => {