From e70253c81c9a7b01fd06d09547f7c3537787612d Mon Sep 17 00:00:00 2001 From: Mats Eriksson Date: Tue, 3 Dec 2024 19:07:35 +0200 Subject: [PATCH] fix: rejected occurrences tab sorting and pagination --- apps/admin-ui/gql/gql-types.ts | 2 ++ apps/admin-ui/src/common/apolloClient.ts | 1 + .../[id]/review/RejectedOccurrencesDataLoader.tsx | 10 ++++++++-- .../[id]/review/RejectedOccurrencesTable.tsx | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/apps/admin-ui/gql/gql-types.ts b/apps/admin-ui/gql/gql-types.ts index 3a83f895b0..f661ca4113 100644 --- a/apps/admin-ui/gql/gql-types.ts +++ b/apps/admin-ui/gql/gql-types.ts @@ -6950,6 +6950,7 @@ export type RejectedOccurrencesQueryVariables = Exact<{ export type RejectedOccurrencesQuery = { rejectedOccurrences?: { + totalCount?: number | null; pageInfo: { hasNextPage: boolean; endCursor?: string | null }; edges: Array<{ node?: { @@ -12320,6 +12321,7 @@ export const RejectedOccurrencesDocument = gql` hasNextPage endCursor } + totalCount edges { node { id diff --git a/apps/admin-ui/src/common/apolloClient.ts b/apps/admin-ui/src/common/apolloClient.ts index a9537a9893..e0224d2853 100644 --- a/apps/admin-ui/src/common/apolloClient.ts +++ b/apps/admin-ui/src/common/apolloClient.ts @@ -73,6 +73,7 @@ function createClient(apiBaseUrl: string) { applicationSections: relayStylePagination(), allocatedTimeSlots: relayStylePagination(), bannerNotifications: relayStylePagination(), + rejectedOccurrences: relayStylePagination(), }, }, }, diff --git a/apps/admin-ui/src/spa/application-rounds/[id]/review/RejectedOccurrencesDataLoader.tsx b/apps/admin-ui/src/spa/application-rounds/[id]/review/RejectedOccurrencesDataLoader.tsx index fc98689276..b1c0ed5df4 100644 --- a/apps/admin-ui/src/spa/application-rounds/[id]/review/RejectedOccurrencesDataLoader.tsx +++ b/apps/admin-ui/src/spa/application-rounds/[id]/review/RejectedOccurrencesDataLoader.tsx @@ -16,6 +16,7 @@ import { filterNonNullable } from "common/src/helpers"; import { getPermissionErrors } from "common/src/apolloUtils"; import { useTranslation } from "next-i18next"; import { getFilteredUnits } from "./utils"; +import { LIST_PAGE_SIZE } from "@/common/const"; import { CenterSpinner } from "common/styles/util"; type Props = { @@ -38,6 +39,7 @@ function RejectedOccurrencesDataLoader({ const { data, previousData, loading, fetchMore } = useRejectedOccurrencesQuery({ variables: { + first: LIST_PAGE_SIZE, applicationRound: applicationRoundPk, unit: getFilteredUnits(unitFilter, unitOptions), reservationUnit: reservationUnitFilter @@ -115,10 +117,14 @@ function transformOrderBy( return desc ? [RejectedOccurrenceOrderingChoices.ApplicationSectionNameDesc] : [RejectedOccurrenceOrderingChoices.ApplicationSectionNameAsc]; + case "rejected_unit_name_fi": + return desc + ? [RejectedOccurrenceOrderingChoices.UnitNameDesc] + : [RejectedOccurrenceOrderingChoices.UnitNameAsc]; case "rejected_reservation_unit_name_fi": return desc - ? [RejectedOccurrenceOrderingChoices.ReservationUnitPkDesc] - : [RejectedOccurrenceOrderingChoices.ReservationUnitPkAsc]; + ? [RejectedOccurrenceOrderingChoices.ReservationUnitNameDesc] + : [RejectedOccurrenceOrderingChoices.ReservationUnitNameAsc]; case "time_of_occurrence": return desc ? [RejectedOccurrenceOrderingChoices.BeginDatetimeDesc] diff --git a/apps/admin-ui/src/spa/application-rounds/[id]/review/RejectedOccurrencesTable.tsx b/apps/admin-ui/src/spa/application-rounds/[id]/review/RejectedOccurrencesTable.tsx index a0a22ca8f7..5d77ad4875 100644 --- a/apps/admin-ui/src/spa/application-rounds/[id]/review/RejectedOccurrencesTable.tsx +++ b/apps/admin-ui/src/spa/application-rounds/[id]/review/RejectedOccurrencesTable.tsx @@ -161,7 +161,7 @@ export function RejectedOccurrencesTable({ isLoading, sort, sortChanged: onSortChanged, -}: Props) { +}: Readonly) { const { t } = useTranslation(); const rows = rejectedOccurrences.map((ro) => timeSlotMapper(t, ro));