From 07c439eee0ffc2554cfb022b66efc4185caf928a Mon Sep 17 00:00:00 2001 From: GitLukeW Date: Mon, 17 Jul 2023 20:47:04 -0400 Subject: [PATCH 1/4] added card confirm state --- src/pages/SessionSignup/MentorCard.js | 195 +++++++++++++++-------- src/pages/SessionSignup/Preview.jsx | 50 ++++++ src/pages/SessionSignup/SessionSignup.js | 24 ++- src/pages/SessionSignup/SubmitButton.jsx | 2 +- 4 files changed, 186 insertions(+), 85 deletions(-) create mode 100644 src/pages/SessionSignup/Preview.jsx diff --git a/src/pages/SessionSignup/MentorCard.js b/src/pages/SessionSignup/MentorCard.js index 45532db..0e7de55 100644 --- a/src/pages/SessionSignup/MentorCard.js +++ b/src/pages/SessionSignup/MentorCard.js @@ -10,6 +10,7 @@ import { } from "@mui/material"; import { useState } from "react"; import { createTheme, ThemeProvider } from "@mui/material/styles"; +import Preview from "./Preview"; const theme = createTheme({ components: { @@ -23,90 +24,144 @@ const theme = createTheme({ }, }); -export default function MentorCard({ mentor, selectedDay, onSlotSelect }) { +export default function MentorCard({ + mentor, + selectedDay, + onSlotSelect, + openSnackbar, + handleCloseSnackbar, + handleSubmitSession, +}) { const [selected, setSelected] = useState(null); const handleButtonChange = (event, newSelectedAvailability) => { setSelected(newSelectedAvailability); if (newSelectedAvailability) { - onSlotSelect(newSelectedAvailability.availabilityPk, newSelectedAvailability.start, newSelectedAvailability.end) + onSlotSelect( + newSelectedAvailability.availabilityPk, + newSelectedAvailability.start, + newSelectedAvailability.end + ); } - }; return ( - - + - {mentor.profile_photo ? ( - - ) : ( - - )} - - {mentor.first_name} {mentor.last_name} - Bio: {mentor.about_me} - {/* Pull in bio from database */} - + + {mentor.profile_photo ? ( + + ) : ( + + )} + + + {mentor.first_name} + + {/* Flip to preview if time is selected */} + {selected ? ( + setSelected(null)} + onSlotSelect={onSlotSelect} + openSnackbar={openSnackbar} + handleCloseSnackbar={handleCloseSnackbar} + handleSubmitSession={handleSubmitSession} + /> + ) : ( + <> + + Bio: + + {mentor.about_me} + + {/* Pull in bio from database */} + {/* Skills:{" "} {mentor.skills ? mentor.skills.join(", ") : "No skills listed"} - - Available Time Slots: - {/*Makes the time slots scrollable */} - - {mentor.availabilities && - mentor.availabilities - .filter(availability => ( - new Date(availability.start).toDateString() === - new Date(selectedDay).toDateString() - ) - ) - .map((availability) => ( - */} + + Available Time Slots: + + + {/*Makes the time slots scrollable */} + - - {new Date(availability.start).toLocaleTimeString()} -{" "} - {new Date(availability.end).toLocaleTimeString()} - - - ))} - - - - + {mentor.availabilities && + mentor.availabilities + .filter( + (availability) => + new Date(availability.start).toDateString() === + new Date(selectedDay).toDateString() + ) + .map((availability) => ( + + + {new Date( + availability.start + ).toLocaleTimeString([], { + hour: "2-digit", + minute: "2-digit", + })}{" "} + -{" "} + {new Date(availability.end).toLocaleTimeString( + [], + { hour: "2-digit", minute: "2-digit" } + )} + + + ))} + + + + )} + + + ); diff --git a/src/pages/SessionSignup/Preview.jsx b/src/pages/SessionSignup/Preview.jsx new file mode 100644 index 0000000..5119520 --- /dev/null +++ b/src/pages/SessionSignup/Preview.jsx @@ -0,0 +1,50 @@ +// Component for previewing the session time prior to submitting the request. +import SubmitButton from "./SubmitButton"; +import { Box, Button, Typography } from "@mui/material"; + +const Preview = ({ + selected, + onCancel, + openSnackbar, + handleCloseSnackbar, + handleSubmitSession, +}) => { + return ( +
+ + Confirm Session? + + + {new Date(selected.start).toLocaleTimeString([], { + hour: "2-digit", + minute: "2-digit", + })}{" "} + -{" "} + {new Date(selected.end).toLocaleTimeString([], { + hour: "2-digit", + minute: "2-digit", + })} + + + + + +
+ ); +}; + +export default Preview; diff --git a/src/pages/SessionSignup/SessionSignup.js b/src/pages/SessionSignup/SessionSignup.js index 1edd03f..4cbac6a 100644 --- a/src/pages/SessionSignup/SessionSignup.js +++ b/src/pages/SessionSignup/SessionSignup.js @@ -325,36 +325,32 @@ export default function SessionSignup({ token }) { {/* Once a skill and day is selected view a list of mentors that have the skill selected and have an open avaliblity on the day they selected */} {filteredMentors.map((mentor) => mentor.skills ? ( - + ) : null )} - {/* The Submit button. It's only be visible if a mentor is selected */} - - {filteredMentors.length > 0 && ( - - )} - {/* */} diff --git a/src/pages/SessionSignup/SubmitButton.jsx b/src/pages/SessionSignup/SubmitButton.jsx index aeea4a1..710b76b 100644 --- a/src/pages/SessionSignup/SubmitButton.jsx +++ b/src/pages/SessionSignup/SubmitButton.jsx @@ -9,7 +9,7 @@ const SubmitButton = ({ handleSubmitSession, openSnackbar, handleCloseSnackbar } onClick={handleSubmitSession} sx={{ justifyContent: "center", backgroundColor: "#0EC202" }} > - Submit Session + Request Date: Tue, 18 Jul 2023 13:43:20 -0400 Subject: [PATCH 2/4] updated mentor card with padding at the bottom --- src/pages/SessionSignup/MentorCard.js | 9 ++++++--- src/pages/SessionSignup/SessionSignup.js | 1 - 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pages/SessionSignup/MentorCard.js b/src/pages/SessionSignup/MentorCard.js index 0e7de55..066fcb6 100644 --- a/src/pages/SessionSignup/MentorCard.js +++ b/src/pages/SessionSignup/MentorCard.js @@ -54,7 +54,7 @@ export default function MentorCard({ alignItems="center" justifyContent="center" > - + {mentor.profile_photo ? ( )} - + {mentor.first_name} @@ -87,7 +87,7 @@ export default function MentorCard({ ) : ( <> - Bio: + Bio: {mentor.about_me} @@ -109,6 +109,7 @@ export default function MentorCard({ style={{ maxHeight: "250px", textAlign: "center", + overflowY: "auto", }} > {/*Makes the time slots scrollable */} @@ -117,6 +118,7 @@ export default function MentorCard({ value={selected} orientation="vertical" onChange={handleButtonChange} + sx={{paddingBottom: "2rem"}} > {mentor.availabilities && mentor.availabilities @@ -134,6 +136,7 @@ export default function MentorCard({ alignSelf: "center", width: "100%", border: "darkgrey solid", + }} > Date: Tue, 18 Jul 2023 15:27:02 -0400 Subject: [PATCH 3/4] took out second over-flow --- src/pages/SessionSignup/MentorCard.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/SessionSignup/MentorCard.js b/src/pages/SessionSignup/MentorCard.js index 066fcb6..db8aa39 100644 --- a/src/pages/SessionSignup/MentorCard.js +++ b/src/pages/SessionSignup/MentorCard.js @@ -109,7 +109,6 @@ export default function MentorCard({ style={{ maxHeight: "250px", textAlign: "center", - overflowY: "auto", }} > {/*Makes the time slots scrollable */} From f57dedf385f3ec586c9ff70c7002536ec9b324b5 Mon Sep 17 00:00:00 2001 From: GitLukeW Date: Tue, 18 Jul 2023 15:49:04 -0400 Subject: [PATCH 4/4] fixed the naming on slot select and tweaked css on the card --- src/pages/SessionSignup/MentorCard.js | 16 +++++++--------- src/pages/SessionSignup/SessionSignup.js | 4 ++-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/pages/SessionSignup/MentorCard.js b/src/pages/SessionSignup/MentorCard.js index db8aa39..5e779ad 100644 --- a/src/pages/SessionSignup/MentorCard.js +++ b/src/pages/SessionSignup/MentorCard.js @@ -27,7 +27,7 @@ const theme = createTheme({ export default function MentorCard({ mentor, selectedDay, - onSlotSelect, + handleSlotSelect, openSnackbar, handleCloseSnackbar, handleSubmitSession, @@ -37,10 +37,9 @@ export default function MentorCard({ const handleButtonChange = (event, newSelectedAvailability) => { setSelected(newSelectedAvailability); if (newSelectedAvailability) { - onSlotSelect( + handleSlotSelect( newSelectedAvailability.availabilityPk, - newSelectedAvailability.start, - newSelectedAvailability.end + newSelectedAvailability.start ); } }; @@ -54,18 +53,18 @@ export default function MentorCard({ alignItems="center" justifyContent="center" > - + {mentor.profile_photo ? ( ) : ( @@ -79,7 +78,6 @@ export default function MentorCard({ setSelected(null)} - onSlotSelect={onSlotSelect} openSnackbar={openSnackbar} handleCloseSnackbar={handleCloseSnackbar} handleSubmitSession={handleSubmitSession} @@ -107,7 +105,7 @@ export default function MentorCard({ diff --git a/src/pages/SessionSignup/SessionSignup.js b/src/pages/SessionSignup/SessionSignup.js index c7e7edb..8bad3c3 100644 --- a/src/pages/SessionSignup/SessionSignup.js +++ b/src/pages/SessionSignup/SessionSignup.js @@ -31,7 +31,7 @@ export default function SessionSignup({ token }) { setTimeBlock(event.target.value); }; - const handleSlotSelect = (availPk, start, end) => { + const handleSlotSelect = (availPk, start) => { setSelectedAvailabilityPk(availPk); setSelectedStartTime(start); }; @@ -342,7 +342,7 @@ export default function SessionSignup({ token }) { mentor={mentor} token={token} selectedDay={selectedDay} - onSlotSelect={handleSlotSelect} + handleSlotSelect={handleSlotSelect} handleSubmitSession={handleSubmitSession} />