Skip to content

Commit

Permalink
fix: don't allow creation of empty series
Browse files Browse the repository at this point in the history
  • Loading branch information
joonatank committed Jan 8, 2025
1 parent 6446df2 commit faddce2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ function RecurringReservationForm({
removedReservations
).filter((x) => !x.isOverlapping);

const isDisabled = !isDirty || newReservationsToMake.length === 0;

return (
<FormProvider {...form}>
<form onSubmit={handleSubmit(onSubmit)} noValidate>
Expand Down Expand Up @@ -404,7 +406,7 @@ function RecurringReservationForm({
type="submit"
data-testid="recurring-reservation-form__submit-button"
isLoading={isSubmitting}
disabled={!isDirty}
disabled={isDisabled}
>
{t("common.reserve")}
</Button>
Expand Down
4 changes: 3 additions & 1 deletion apps/admin-ui/src/spa/reservations/[id]/series/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ function SeriesPageInner({ pk }: { pk: number }) {
return <Error404 />;
}

const isDisabled = Object.keys(errors).length > 0 || reservationsCount < 1;

return (
<>
<LinkPrev />
Expand Down Expand Up @@ -402,7 +404,7 @@ function SeriesPageInner({ pk }: { pk: number }) {
}}
>
<ButtonLikeLink to="..">{t("common:cancel")}</ButtonLikeLink>
<Button size="small" type="submit">
<Button size="small" type="submit" disabled={isDisabled}>
{t("ReservationEditSeries.submit")}
</Button>
</ButtonContainer>
Expand Down

0 comments on commit faddce2

Please sign in to comment.