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

Fix rejected occurrences tab sorting and pagination #1558

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -6950,6 +6950,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 @@ -12320,6 +12321,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
Loading