From 6cc19211c196bba33adfa693d10d5516f0c2380b Mon Sep 17 00:00:00 2001 From: rui hildt Date: Wed, 2 Sep 2020 23:08:41 +0200 Subject: [PATCH] Fix rendering of events in Availability & refactor - Possible dates were not ordered by dates, which in turn crashed the rendering of Availability component - Token was not added to headers after login - Refactor Schedule by removing useless UseEffect - Simplify rendering of events in Selected Dates (for now) --- package.json | 2 +- src/App.js | 2 +- src/components/IntervalSelector.js | 5 +- src/components/Schedule/SelectedDates.js | 9 ++-- src/constants.js | 2 +- src/helpers/http-common.js | 1 + src/screens/Availability.js | 2 +- src/screens/Schedule.js | 58 ++++++++++-------------- 8 files changed, 35 insertions(+), 46 deletions(-) diff --git a/package.json b/package.json index cb06e9a..ba290dd 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ }, "scripts": { "start": "react-app-rewired start", - "dev": "PORT=8000 BROWSER=firefox-developer-edition react-app-rewired start", + "dev": "BROWSER=firefox-developer-edition react-app-rewired start", "build": "react-app-rewired build", "test": "react-app-rewired test", "eject": "react-app-rewired eject" diff --git a/src/App.js b/src/App.js index e782697..89f789f 100644 --- a/src/App.js +++ b/src/App.js @@ -22,7 +22,7 @@ export default function App() { const [isAuthenticated, setIsAuthenticated] = useState(!!existingToken); const [currentUser, setCurrentUser] = useState(existingUser || ''); const [participant, setParticipant] = useState(); - const [possibleDates, setPossibleDates] = useState(); + const [possibleDates, setPossibleDates] = useState([]); const [currentMeeting, setCurrentMeeting] = useState({ title: '', description: '', // optional diff --git a/src/components/IntervalSelector.js b/src/components/IntervalSelector.js index f8b1a1f..c438503 100644 --- a/src/components/IntervalSelector.js +++ b/src/components/IntervalSelector.js @@ -28,10 +28,7 @@ export default function IntervalSelector({ .toFormat('yyyy-MM-dd'); // Create an event dates list used to create the days columns - const daysList = []; - selectedDates.forEach((event) => { - daysList.push(event.start); - }); + const daysList = selectedDates.map((event) => event.start); const handleDayDidMount = (info) => { let currentDate = DateTime.fromJSDate(info.date).toFormat('yyyy-MM-dd'); diff --git a/src/components/Schedule/SelectedDates.js b/src/components/Schedule/SelectedDates.js index e584743..2859b19 100644 --- a/src/components/Schedule/SelectedDates.js +++ b/src/components/Schedule/SelectedDates.js @@ -1,13 +1,12 @@ import React from 'react'; import { Divider, Icon, IconButton } from 'rsuite'; -export default function SelectedDates({ datesList, handleDelete }) { +export default function SelectedDates({ possibleDates, handleDelete }) { return (