Skip to content

Commit

Permalink
fix: rejected occurrences tab sorting and pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
vincit-matu authored and joonatank committed Jan 14, 2025
1 parent 09d11e0 commit 4a29d38
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions apps/admin-ui/gql/gql-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6799,6 +6799,7 @@ export type RejectedOccurrencesQueryVariables = Exact<{

export type RejectedOccurrencesQuery = {
rejectedOccurrences?: {
totalCount?: number | null;
pageInfo: { hasNextPage: boolean; endCursor?: string | null };
edges: Array<{
node?: {
Expand Down Expand Up @@ -12252,6 +12253,7 @@ export const RejectedOccurrencesDocument = gql`
hasNextPage
endCursor
}
totalCount
edges {
node {
id
Expand Down
1 change: 1 addition & 0 deletions apps/admin-ui/src/common/apolloClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ function createClient(apiBaseUrl: string) {
applicationSections: relayStylePagination(),
allocatedTimeSlots: relayStylePagination(),
bannerNotifications: relayStylePagination(),
rejectedOccurrences: relayStylePagination(),
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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
Expand Down Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export function RejectedOccurrencesTable({
isLoading,
sort,
sortChanged: onSortChanged,
}: Props) {
}: Readonly<Props>) {
const { t } = useTranslation();

const rows = rejectedOccurrences.map((ro) => timeSlotMapper(t, ro));
Expand Down

0 comments on commit 4a29d38

Please sign in to comment.