-
Notifications
You must be signed in to change notification settings - Fork 2
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
Progress on issue #482 show previous bookings for admin, PA and Liason: #503
base: main
Are you sure you want to change the base?
Conversation
- General code cleanup. - Implement a function to fetch all bookings with pagination if the user is an admin, pa or liason. - Fix an issue with page permission where it wasn't changing after the user email and admins array were loaded.
walkedInAt: item.walkedInAt, | ||
})); | ||
setBookings(bookings); | ||
setFutureBookings(fetchedData as Booking[]); |
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.
amazing
@@ -98,9 +103,12 @@ export const DatabaseProvider = ({ | |||
const [userApiData, setUserApiData] = useState<UserApiData | undefined>( | |||
undefined | |||
); | |||
const [lastItem, setLastItem] = useState<any>(null); |
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.
can you type this instead of using any
?
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.
Sure
setBookingsLoading(false); | ||
}) | ||
.catch((error) => console.error("Error fetching data:", error)); | ||
}; | ||
|
||
const fetchBookings = async () => { | ||
try{ | ||
const bookingsResponse : Booking[] = await fetchAllBookings(LIMIT, lastItem); |
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.
can you clarify what's happening here with LIMIT
and lastItem
? is there a reason we limit to 3?
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.
So we probably don't want to load all the previous bookings at the same time, I'm adding pagination here to load them in steps, the limit is just arbitrary we can change it to any number, or have a control for the admin to be able to change how many they would like to see at a time.
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.
LGTM 🚀
export const getPaginatedData = async<T> ( | ||
collectionName, | ||
itemsPerPage = 10, | ||
orderByField = 'calendarEventId', |
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.
we discussed it, and it's better to use requestedAt
as the key.
Implement a function to fetch all bookings with pagination if the user is an admin, pa or liason.