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

Commit 5ddd7a1

Browse files
committed
fix: reservation series edit
- Don't validate start time nor allow user to change it. - Don't allow user to change the type of series.
1 parent 4d49347 commit 5ddd7a1

5 files changed

Lines changed: 9 additions & 4 deletions

File tree

apps/admin-ui/src/component/ReservationTypeForm.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,12 @@ function ReservationTypeForm({
105105
reservationUnit,
106106
children,
107107
disableBufferToggle,
108+
disableTypeSelect,
108109
}: {
109110
reservationUnit: TypeFormReservationUnit;
110111
children?: React.ReactNode;
111112
disableBufferToggle?: boolean;
113+
disableTypeSelect?: boolean;
112114
}) {
113115
const { t } = useTranslation();
114116

@@ -121,7 +123,7 @@ function ReservationTypeForm({
121123
return (
122124
<>
123125
<Element $wide>
124-
<TypeSelect />
126+
<TypeSelect isDisabled={disableTypeSelect} />
125127
</Element>
126128
{type === ReservationTypeChoice.Blocked && (
127129
<CommentsTextArea

apps/admin-ui/src/i18n/messages.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ const translations: ITranslations = {
221221
RESERVATION_END_DATE_TOO_FAR: [
222222
"Ei pystytty luomaan varauksia yli 2 vuoden päähän",
223223
],
224+
RESERVATION_SERIES_ALREADY_STARTED: ["Toistuva varaus on jo alkanut"],
224225
},
225226
descriptive: {
226227
"Reservation overlaps with reservation before due to buffer time.": [

apps/admin-ui/src/schemas/recurringReservation.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,7 @@ const RescheduleReservationSeriesFormSchemaRefined = (
135135
// TODO do we need it here? reschedule might not have metadata
136136
.passthrough()
137137
// this refine works without partial since it's the last required value
138-
.superRefine((val, ctx) =>
139-
checkDateNotInPast(convertToDate(val.startingDate), ctx, "startingDate")
140-
)
138+
/* Don't validate start time since it's not editable */
141139
.superRefine((val, ctx) =>
142140
checkDateNotInPast(convertToDate(val.endingDate), ctx, "endingDate")
143141
)

apps/admin-ui/src/spa/reservations/[id]/edit.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ function EditReservation({
179179
<ReservationTypeForm
180180
reservationUnit={reservationUnit}
181181
disableBufferToggle
182+
// backend doesn't allow changing type for series but does allow it for single reservations
183+
disableTypeSelect={reservation.recurringReservation?.pk != null}
182184
>
183185
{reservation.recurringReservation?.pk && (
184186
<InnerTextInput

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ function SeriesPageInner({ pk }: { pk: number }) {
317317
control={control}
318318
error={translateError(errors.startingDate?.message)}
319319
required
320+
// NOTE we can't change the start date of the series
321+
disabled
320322
/>
321323

322324
<ControlledDateInput

0 commit comments

Comments
 (0)