-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #10 (Overlapping Rides) Resolved along with Issues #6, #8, #12 #14
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,15 +29,15 @@ const places = [ | |
"Hyd. Deccan Stn.", | ||
]; | ||
|
||
const AllUserBookings = () => { | ||
const [startTime, setStartTime] = useState(null); | ||
const [endTime, setEndTime] = useState(null); | ||
const [fromValue, setFromValue] = useState(null); | ||
const [toValue, setToValue] = useState(null); | ||
const AllUserBookings = ({startTimeProp, endTimeProp, fromValueProp, toValueProp}) => { | ||
const router = useRouter(); | ||
const [startTime, setStartTime] = useState(startTimeProp); | ||
const [endTime, setEndTime] = useState(endTimeProp); | ||
const [fromValue, setFromValue] = useState(fromValueProp); | ||
const [toValue, setToValue] = useState(toValueProp); | ||
const [filteredBookings, setFilteredBookings] = useState([]); | ||
const [username, setUsername] = useState(""); | ||
const [email, setEmail] = useState(""); | ||
const router = useRouter(); | ||
const [show_all, setShowAll] = useState(false); | ||
const [checked, setChecked] = useState(false); | ||
const [request_checked, setRequestChecked] = useState(false); | ||
|
@@ -64,9 +64,12 @@ const AllUserBookings = () => { | |
let apiURL = `${process.env.NEXT_PUBLIC_BACKEND_URL}/bookings`; | ||
|
||
if (fromValue && toValue) { | ||
if(endTime < startTime) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
toast.warn("End Time can't be before Start Time"); | ||
} | ||
if (startTime || endTime) { | ||
const isoStartTime = startTime?.toISOString(); | ||
const isoEndTime = endTime?.toISOString(); | ||
const isoStartTime = startTime ? new Date(startTime).toISOString() : null; | ||
const isoEndTime = endTime ? new Date(endTime).toISOString() : null; | ||
|
||
// makes sure that the query string takes care of null values | ||
const queryString = (isoStartTime && isoEndTime) ? `?from_loc=${fromValue}&to_loc=${toValue}&start_time=${isoStartTime}&end_time=${isoEndTime}` | ||
|
@@ -79,8 +82,8 @@ const AllUserBookings = () => { | |
apiURL += `?from_loc=${fromValue}&to_loc=${toValue}`; | ||
} | ||
} else if (startTime || endTime) { | ||
const isoStartTime = startTime?.toISOString(); | ||
const isoEndTime = endTime?.toISOString(); | ||
const isoStartTime = startTime ? new Date(startTime).toISOString() : null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this necessary? I think the optional chaining present here should automatically handle it? |
||
const isoEndTime = endTime ? new Date(endTime).toISOString() : null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto as above. |
||
|
||
// makes sure that the query string takes care of null values | ||
const queryString = (isoStartTime && isoEndTime) ? `?start_time=${isoStartTime}&end_time=${isoEndTime}` | ||
|
@@ -421,37 +424,48 @@ const AllUserBookings = () => { | |
(startTime === null && | ||
endTime === null && | ||
toValue === null && | ||
fromValue === null) | ||
fromValue === null) || | ||
(fromValue === toValue) | ||
} | ||
> | ||
Search | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="sm:my-10"> | ||
{filteredBookings?.map((item, index) => { | ||
if (show_all || item.capacity > item.travellers.length) { | ||
return ( | ||
<CabShareSmall | ||
fetchFilteredBookings={fetchFilteredBookings} | ||
userSpecific={false} | ||
key={index} | ||
index={index} | ||
bookingData={item} | ||
username={username} | ||
email={email} | ||
phone={phone} | ||
loaded_phone={loaded_phone} | ||
is_there_a_phone_number={is_there_a_phone_number} | ||
setIsThereAPhoneNumber={setIsThereAPhoneNumber} | ||
setPhone={setPhone} | ||
setLoadedPhone={setLoadedPhone} | ||
/> | ||
); | ||
} | ||
})} | ||
</div> | ||
{filteredBookings.length == 0 ? ( | ||
<div className="sm:my-10"> | ||
<div | ||
className={`bg-secondary/10 px-2 md:p-5 py-2 sm:py-0 sm:mx-auto sm:mt-5 border-t-2 border-black/20 sm:border-2 sm:three-d sm:shadow-md sm:border-black text-black text-center rounded-none sm:rounded-md w-[100vw] sm:w-[90vw] lg:w-[60rem]`} | ||
> | ||
Oops! No Ride Available | ||
</div> | ||
</div> | ||
) : ( | ||
<div className="sm:my-10"> | ||
{filteredBookings?.map((item, index) => { | ||
if (show_all || item.capacity > item.travellers.length) { | ||
return ( | ||
<CabShareSmall | ||
fetchFilteredBookings={fetchFilteredBookings} | ||
userSpecific={false} | ||
key={index} | ||
index={index} | ||
bookingData={item} | ||
username={username} | ||
email={email} | ||
phone={phone} | ||
loaded_phone={loaded_phone} | ||
is_there_a_phone_number={is_there_a_phone_number} | ||
setIsThereAPhoneNumber={setIsThereAPhoneNumber} | ||
setPhone={setPhone} | ||
setLoadedPhone={setLoadedPhone} | ||
/> | ||
); | ||
} | ||
})} | ||
</div> | ||
)} | ||
</div> | ||
)} | ||
</div> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Open this form in a new tab |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from "react"; | ||
import { useRouter } from "next/router"; | ||
import BugReportIcon from '@mui/icons-material/BugReport'; | ||
|
||
function ReportBugButton() { | ||
const router = useRouter(); | ||
|
||
const handleReport = () => { | ||
window.location.href = "https://docs.google.com/forms/d/e/1FAIpQLScEKZIbE45xn8TzD_OzehhNnS0BDXdSfvJBm1FAG_l0KywSEw/viewform"; | ||
}; | ||
|
||
return ( | ||
<button | ||
className="btn bg-transparent h-1 min-h-8 p-1 border-none text-black mx-5 mb-5 hover:bg-secondary/80 hover:text-white/80 capitalize font-[400] text-sm my-3 transition-all hover:-translate-y-[.5px] ml-[auto]" | ||
onClick={handleReport} | ||
> | ||
Report Bug <BugReportIcon className="text-[.9rem] text-black/50" /> | ||
</button> | ||
); | ||
} | ||
|
||
export default ReportBugButton; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { useRouter } from "next/router"; | ||
import React, { useEffect, useState } from "react"; | ||
|
||
const OverlappingModal = ({ | ||
numOverlapping, | ||
findFunction, | ||
bookFunction, | ||
}) => { | ||
const [isModalOpen, setModalOpen] = useState(false); | ||
|
||
const router = useRouter(); | ||
|
||
useEffect(() => { | ||
if (numOverlapping > 0) { | ||
setModalOpen(true); | ||
} else { | ||
setModalOpen(false); | ||
} | ||
}, [numOverlapping]); | ||
|
||
const closeModal = () => { | ||
setModalOpen(false); | ||
}; | ||
|
||
return ( | ||
<> | ||
{isModalOpen && ( | ||
<dialog | ||
id="my_modal_3" | ||
className="modal modal-open" | ||
onClick={(e) => e.stopPropagation()} | ||
> | ||
<form | ||
method="dialog" | ||
className="modal-box bg-white text-black border-black border-2" | ||
> | ||
<button | ||
className="btn btn-sm btn-circle btn-ghost absolute right-2" | ||
onClick={() => closeModal()} | ||
> | ||
✕ | ||
</button> | ||
<div className="flex flex-col gap-4"> | ||
<h3 className="font-bold text-lg text-secondary/80 border-secondary border-b-2 w-fit"> | ||
Overlapping Rides | ||
</h3> | ||
{"There are " + numOverlapping + " rides matching your info. Would you like to check them out?"} | ||
<button | ||
className="btn ml-auto bg-secondary/70 text-white/80 hover:bg-secondary/80 " | ||
onClick={() => { | ||
findFunction(); | ||
closeModal(); | ||
}} | ||
> | ||
{"Yes, Find Rides"} | ||
</button> | ||
<button | ||
className="btn ml-auto bg-secondary/70 text-white/80 hover:bg-secondary/80 " | ||
onClick={() => { | ||
bookFunction(); | ||
closeModal(); | ||
}} | ||
> | ||
{"No, Continue booking"} | ||
</button> | ||
</div> | ||
</form> | ||
<form method="dialog" className="modal-backdrop"> | ||
<button onClick={() => closeModal()}>close</button> | ||
</form> | ||
</dialog> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default OverlappingModal; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these dependency changes required for this issue? If not, please address them separately