From 117bd36caaf6702d3af63c84f8b40d2308fa42bf Mon Sep 17 00:00:00 2001 From: Sylvain Date: Mon, 23 Jan 2023 12:05:02 +0100 Subject: [PATCH] (ui) reservable machine cannot be disabled --- .../components/machines/machine-form.tsx | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/frontend/src/javascript/components/machines/machine-form.tsx b/app/frontend/src/javascript/components/machines/machine-form.tsx index 6197511f0..f6d7bd956 100644 --- a/app/frontend/src/javascript/components/machines/machine-form.tsx +++ b/app/frontend/src/javascript/components/machines/machine-form.tsx @@ -63,6 +63,26 @@ export const MachineForm: React.FC = ({ action, machine, onErr }); }; + /** + * Callack triggered when the user changes the 'reservable' status of the machine: + * A reservable machine cannot be disabled + */ + const onReservableToggled = (reservable: boolean) => { + if (reservable) { + setValue('disabled', false); + } + }; + + /** + * Callack triggered when the user changes the 'disabled' status of the machine: + * A disabled machine cannot be reservable + */ + const onDisabledToggled = (disabled: boolean) => { + if (disabled) { + setValue('reservable', false); + } + }; + /** * Convert all machine categories to the select format */ @@ -150,10 +170,12 @@ export const MachineForm: React.FC = ({ action, machine, onErr