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

Progress on issue #482 show previous bookings for admin, PA and Liason: #503

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nimanns
Copy link
Collaborator

@nimanns nimanns commented Nov 18, 2024

Implement a function to fetch all bookings with pagination if the user is an admin, pa or liason.

- 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[]);
Copy link
Collaborator

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);
Copy link
Collaborator

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?

Copy link
Collaborator Author

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);
Copy link
Collaborator

@lucia-gomez lucia-gomez Nov 19, 2024

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

@rlho rlho left a 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',
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants