From b6fab9d48df48d645ec1f46144c64f278822049f Mon Sep 17 00:00:00 2001 From: Qudus Date: Thu, 4 Feb 2021 10:05:22 -0500 Subject: [PATCH 1/3] select days from drop down --- .../components/profile/ProfileRequestForm.js | 139 +++++++++++++----- client/src/pages/Profile.js | 6 +- 2 files changed, 111 insertions(+), 34 deletions(-) diff --git a/client/src/components/profile/ProfileRequestForm.js b/client/src/components/profile/ProfileRequestForm.js index 207ae63..90db7e8 100644 --- a/client/src/components/profile/ProfileRequestForm.js +++ b/client/src/components/profile/ProfileRequestForm.js @@ -8,12 +8,17 @@ import { TextField, Typography, makeStyles, + FormControl, + InputLabel, + Select, + MenuItem, } from "@material-ui/core"; import { AuthDispatchContext, AuthStateContext, } from "../../context/AuthContext"; import { createRequest } from "../../actions/request"; +import { eachHourOfInterval, format } from "date-fns"; const useStyles = makeStyles(() => ({ centerContent: { @@ -40,7 +45,7 @@ const useStyles = makeStyles(() => ({ }, })); -function ProfileRequestForm({ sitterId }) { +function ProfileRequestForm({ sitterId, sitterPrice, sitterAvailability }) { const classes = useStyles(); // Get dispatch method and state from auth context @@ -52,20 +57,10 @@ function ProfileRequestForm({ sitterId }) { const todayFormatted = today.toISOString().split("T")[0]; const [requestSending, setRequestSending] = useState(false); - const [startDate, setStartDate] = useState(todayFormatted); - const [endDate, setEndDate] = useState(todayFormatted); - const [startTime, setStartTime] = useState( - moment() - .add(moment().utcOffset() + 30, "minutes") - .startOf("hour") - .format("HH:mm") - ); - const [endTime, setEndTime] = useState( - moment() - .add(moment().utcOffset() + 150, "minutes") - .startOf("hour") - .format("HH:mm") - ); + const [startDate, setStartDate] = useState(""); + const [endDate, setEndDate] = useState(""); + const [startTime, setStartTime] = useState(""); + const [endTime, setEndTime] = useState(""); const [requestFormData, setRequestFormData] = useState({ sitterId: sitterId, ownerId: user._id, @@ -80,6 +75,9 @@ function ProfileRequestForm({ sitterId }) { .startOf("hour") .format(), }); + const [startHourInterval, setStartHourInterval] = useState([]); + const [endHourInterval, seEndhourInterval] = useState([]); + const [index, setIndex] = useState(); // Changes 'Send Request' button from spinning to normal when alert pops ups useEffect(() => { @@ -180,11 +178,11 @@ function ProfileRequestForm({ sitterId }) { return ( <> - - $14/hr + + ${sitterPrice}/hr DROP OFF + + date + + + + time + + handleStartDateChange(e)} - variant="outlined" + variant='outlined' > { handleStartTimeChange(e); @@ -222,23 +256,62 @@ function ProfileRequestForm({ sitterId }) { PICK UP + + date + + + + time + + handleEndDateChange(e)} + type='date' + variant='outlined' + value={endTime} + onChange={(e) => handleEndTimeChange(e)} > { handleEndTimeChange(e); }} @@ -246,15 +319,15 @@ function ProfileRequestForm({ sitterId }) {