Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit 49165d1

Browse files
committed
fix: rejected query missing organisation name
1 parent 68ab8f9 commit 49165d1

5 files changed

Lines changed: 25 additions & 13 deletions

File tree

apps/admin-ui/gql/gql-types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8608,6 +8608,7 @@ export type RejectedOccurrencesQuery = {
86088608
firstName: string;
86098609
lastName: string;
86108610
} | null;
8611+
organisation?: { id: string; name: string } | null;
86118612
};
86128613
};
86138614
reservationUnit: {
@@ -15492,6 +15493,10 @@ export const RejectedOccurrencesDocument = gql`
1549215493
firstName
1549315494
lastName
1549415495
}
15496+
organisation {
15497+
id
15498+
name
15499+
}
1549515500
}
1549615501
}
1549715502
reservationUnit {

apps/admin-ui/src/helpers/index.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,22 @@ export const reservationToInterval = (
7171
};
7272
};
7373

74+
// NOTE optionals (?) are super bad because if you forget to query anything from the object there will be no type errors
75+
// can't remove them because they are not mandatory in the gql schema
76+
// maybe using an utility function that forces subobjects to NonNullable could work for this.
7477
type Application = {
7578
applicantType?:
7679
| Pick<ApplicationNode, "applicantType">["applicantType"]
77-
| null;
78-
contactPerson?: Pick<PersonNode, "firstName" | "lastName"> | null;
79-
organisation?: Pick<
80-
NonNullable<Pick<ApplicationNode, "organisation">["organisation"]>,
81-
"name"
82-
> | null;
80+
| null
81+
| undefined;
82+
contactPerson?: Pick<PersonNode, "firstName" | "lastName"> | null | undefined;
83+
organisation?:
84+
| Pick<
85+
NonNullable<Pick<ApplicationNode, "organisation">["organisation"]>,
86+
"name"
87+
>
88+
| null
89+
| undefined;
8390
};
8491
export function getApplicantName(app?: Application | undefined | null): string {
8592
if (!app) {

apps/admin-ui/src/spa/applications/[id]/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ function ApplicationDetails({
857857
application?.billingAddress != null &&
858858
!isEqual(application?.billingAddress, application?.organisation?.address);
859859

860-
const customerName = application != null ? getApplicantName(application) : "";
860+
const customerName = getApplicantName(application);
861861
// TODO where is this defined in the application form?
862862
const homeCity = application?.homeCity?.nameFi ?? "-";
863863

apps/admin-ui/src/spa/recurring-reservations/application-rounds/[id]/allocation/AllocationCard.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,7 @@ export function AllocatedCard({
176176
// TODO should compare the allocated to the suitable time ranges, not to selection
177177
const isTimeMismatch = false;
178178

179-
const applicantName = applicationSection.application
180-
? getApplicantName(applicationSection.application)
181-
: "-";
179+
const applicantName = getApplicantName(applicationSection.application);
182180
const isLoading = isResetLoading || isRefreshLoading;
183181

184182
return (
@@ -284,9 +282,7 @@ export function SuitableTimeCard({
284282
reservationUnitOptionPk,
285283
refresh,
286284
});
287-
const applicantName = applicationSection.application
288-
? getApplicantName(applicationSection.application)
289-
: "-";
285+
const applicantName = getApplicantName(applicationSection.application);
290286

291287
const isDisabled = !reservationUnitOptionPk || !isAllocationEnabled;
292288

apps/admin-ui/src/spa/recurring-reservations/application-rounds/[id]/review/RejectedOccurrencesDataLoader.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ export const REJECTED_OCCURRENCES_QUERY = gql`
177177
firstName
178178
lastName
179179
}
180+
organisation {
181+
id
182+
name
183+
}
180184
}
181185
}
182186
reservationUnit {

0 commit comments

Comments
 (0)