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

Commit 54bee50

Browse files
committed
fix: dont allow reject if not in allocation state
1 parent 3501ba6 commit 54bee50

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,11 @@ function SchedulesContent({
342342

343343
function RejectOptionButton({
344344
option,
345+
applicationStatus,
345346
refetch,
346347
}: {
347348
option: ReservationUnitOptionNode;
349+
applicationStatus: ApplicationStatusChoice;
348350
refetch: () => Promise<ApolloQueryResult<Query>>;
349351
}) {
350352
const [mutation, { loading }] = useMutation<
@@ -409,7 +411,8 @@ function RejectOptionButton({
409411
console.warn("no allocatedTimeSlots", option);
410412
}
411413

412-
const isDisabled = option.allocatedTimeSlots?.length > 0;
414+
const canReject = applicationStatus === ApplicationStatusChoice.InAllocation;
415+
const isDisabled = !canReject || option.allocatedTimeSlots?.length > 0;
413416
return (
414417
<Button
415418
variant="supplementary"
@@ -497,6 +500,9 @@ function ApplicationSectionDetails({
497500
return (
498501
<RejectOptionButton
499502
option={reservationUnitOption}
503+
applicationStatus={
504+
application.status ?? ApplicationStatusChoice.Draft
505+
}
500506
refetch={refetch}
501507
/>
502508
);

apps/admin-ui/src/spa/applications/queries.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const APPLICATION_ADMIN_QUERY = gql`
66
${APPLICATION_ADMIN_FRAGMENT}
77
query ApplicationAdmin($id: ID!) {
88
application(id: $id) {
9-
...ApplicationCommon
9+
...ApplicationAdminFragment
1010
workingMemo
1111
}
1212
}

packages/common/src/queries/application.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,9 @@ const APPLICATION_ROUND_FRAGMENT = gql`
200200
export const APPLICATION_ADMIN_FRAGMENT = gql`
201201
${APPLICANT_FRAGMENT}
202202
${APPLICATION_SECTION_UI_FRAGMENT}
203-
fragment ApplicationCommon on ApplicationNode {
203+
fragment ApplicationAdminFragment on ApplicationNode {
204204
pk
205+
id
205206
status
206207
lastModifiedDate
207208
...ApplicantFragment
@@ -215,6 +216,7 @@ export const APPLICATION_ADMIN_FRAGMENT = gql`
215216
rejected
216217
allocatedTimeSlots {
217218
pk
219+
id
218220
}
219221
}
220222
}

0 commit comments

Comments
 (0)