fix: fetch next batch if event types are empty and cursor exists (#17109)

* fix: fetch next batch if event types are empty and cursor exists

* refactor: improve

* fix: add isFetchingForFirstTime

* chore: add number type

* fix: type err

* chore: add logs

* fix: type err

* fix: conflict

* fix: bug

* fix: type err

* chore: try changing type

* chore: add nul

* Update packages/trpc/server/routers/viewer/eventTypes/getEventTypesFromGroup.handler.ts

Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>

* chore: use log.info

---------

Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
Co-authored-by: Bailey Pumfleet <bailey@pumfleet.co.uk>
This commit is contained in:
Udit Takkar
2024-11-13 14:37:03 +00:00
committed by GitHub
co-authored by sean-brydon Bailey Pumfleet
parent 18c7c3c940
commit 5c6e60b726
2 changed files with 80 additions and 22 deletions
@@ -81,7 +81,7 @@ interface InfiniteEventTypeListProps {
group: InfiniteEventTypeGroup;
readOnly: boolean;
bookerUrl: string | null;
pages: { nextCursor: number | undefined; eventTypes: InfiniteEventType[] }[] | undefined;
pages: { nextCursor: number | null | undefined; eventTypes: InfiniteEventType[] }[] | undefined;
lockedByOrg?: boolean;
isPending?: boolean;
debouncedSearchTerm?: string;
@@ -349,9 +349,14 @@ export const InfiniteEventTypeList = ({
group: { teamId: group?.teamId, parentId: group?.parentId },
},
(data) => {
if (!data) return { pages: [], pageParams: [] };
return {
pageParams: data?.pageParams ?? [],
pages: newOrder,
...data,
pages: newOrder.map((page) => ({
...page,
nextCursor: page.nextCursor ?? undefined,
})),
};
}
);