1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-20 14:54:15 +01:00

(quality) prevent invalid settings

This commit is contained in:
Sylvain 2023-02-16 12:03:48 +01:00
parent b55eb68813
commit b2a95e1acb
3 changed files with 6 additions and 4 deletions

View File

@ -96,7 +96,7 @@ export const TrainingsSettings: React.FC<TrainingsSettingsProps> = ({ onError, o
<FormInput id="trainings_auto_cancel_threshold"
type="number"
register={register}
rules={{ required: isActiveAutoCancellation, min: 0 }}
rules={{ required: isActiveAutoCancellation, min: { value: 0, message: t('app.admin.trainings_settings.must_be_positive') } }}
step={1}
nullable
formState={formState}
@ -104,7 +104,7 @@ export const TrainingsSettings: React.FC<TrainingsSettingsProps> = ({ onError, o
<FormInput id="trainings_auto_cancel_deadline"
type="number"
register={register}
rules={{ required: isActiveAutoCancellation, min: 1 }}
rules={{ required: isActiveAutoCancellation, min: { value: 1, message: t('app.admin.trainings_settings.must_be_above_zero') } }}
nullable
step={1}
formState={formState}

View File

@ -6,8 +6,8 @@ export type ruleTypes = {
pattern?: RegExp | { value: RegExp, message: string },
minLength?: number | { value: number, message: string },
maxLength?: number | { value: number, message: string },
min?: number,
max?: number,
min?: number | { value: number, message: string },
max?: number | { value: number, message: string },
validate?: Validate<unknown>;
};

View File

@ -481,7 +481,9 @@ en:
automatic_cancellation_info: "Minimum number of participants required to maintain a session. You will be notified if a session is cancelled. Credit notes and refunds will be automatic if the wallet is enabled. Otherwise you will have to do it manually."
automatic_cancellation_switch: "Activate automatic cancellation for all the trainings"
automatic_cancellation_threshold: "Minimum number of registrations to maintain a session"
must_be_positive: "You must specify a number above or equal to 0"
automatic_cancellation_deadline: "Deadline, in hours, before automatic cancellation"
must_be_above_zero: "You must specify a number above or equal to 1"
authorization_validity: "Authorisations validity period"
authorization_validity_info: "Define a validity period for all training authorisations. After this period, the authorisation will lapse"
authorization_validity_switch: "Activate an authorization validity period"