Skip to content
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

Feature/view past reservations 482 #538

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default function BookingTableFilters({
<Dropdown
value={selectedDateRange}
updateValue={(x) => handleDateRangeFilterClick(null, x)}
options={["Today", "This Week", "All Future", "Past 24 hours", "Past Week", "Past Month", "Past 6 Months", "All Past"]}
options={["Today", "This Week", "All Future", "Past 24 hours", "Past Week", "Past Month", "Past 6 Months", "Past 9 Months"]}
placeholder={"Today"}
sx={{ width: "125px", mr: 1 }}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export const Bookings: React.FC<BookingsProps> = ({
const isUserView = pageContext === PageContextLevel.USER;

useEffect(() => {
// reloadFutureBookings();
return ()=>{
setLastItem(null);
}
Expand Down Expand Up @@ -209,10 +208,10 @@ export const Bookings: React.FC<BookingsProps> = ({
closeModal={() => setModalData(null)}
/>
)}
{loadMoreEnabled &&
{/* {loadMoreEnabled &&
(<Box sx={{ display: "flex", justifyContent: "center" }}>
<Button onClick={() => { fetchAllBookings(true) }}>Load More</Button>
</Box>)}
</Box>)} */}
</Box>
);
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Booking } from "@/components/src/types";

export type DateRangeFilter = "Today" | "This Week" | "All Future" | "Past 24 hours" | "Past Week" | "Past Month" | "Past 6 Months" | "All Past";
export type DateRangeFilter = "Today" | "This Week" | "All Future" | "Past 24 hours" | "Past Week" | "Past Month" | "Past 6 Months" | "Past 9 Months";

export const DATE_FILTERS: Record<DateRangeFilter, (x: Booking) => boolean> = {
Today: (row) => {
Expand Down Expand Up @@ -79,7 +79,7 @@ export const DATE_FILTERS: Record<DateRangeFilter, (x: Booking) => boolean> = {
return diff >= 0 && diff < 6 * 30 * 24 * 60 * 60 * 1000;
},

"All Past": (row) => {
"Past 9 Months": (row) => {
const today = new Date();
const date = row.startDate.toDate();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,15 @@ function getDateRangeFromDateSelection(selectedDateRange: DateRangeFilter) {
startOfPast6Months.setMonth(today.getMonth() - 6);
return [startOfPast6Months, today];
}
case "All Past": {
case "Past 9 Months": {
// return an array of the start of time and the end of today
const today = new Date();
const endOfToday = new Date(today);
endOfToday.setHours(23, 59, 59, 999);
return [null, endOfToday];

const startOfPast9Months = new Date(today);
startOfPast9Months.setMonth(today.getMonth() - 9);
return [startOfPast9Months, endOfToday];
}
default:
return "Today";
Expand Down
6 changes: 3 additions & 3 deletions booking-app/lib/firebase/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const getPaginatedData = async<T> (
...queryParams,
orderBy(filters.sortField, 'desc'),
orderBy("__name__", 'desc'),
limit(itemsPerPage)
// limit(itemsPerPage)
);

// If we have a last visible item, start after it
Expand All @@ -125,8 +125,8 @@ export const getPaginatedData = async<T> (
...queryParams,
orderBy(filters.sortField, 'desc'),
orderBy("__name__", 'desc'),
startAfter(lastVisible[filters.sortField], lastVisible.id),
limit(itemsPerPage)
// startAfter(lastVisible[filters.sortField], lastVisible.id),
// limit(itemsPerPage)
);
}

Expand Down
Loading