diff --git a/frontend/public/locales/en/translation.json b/frontend/public/locales/en/translation.json index 5173d80f..8e41d78f 100644 --- a/frontend/public/locales/en/translation.json +++ b/frontend/public/locales/en/translation.json @@ -106,6 +106,7 @@ "invalid_carousel_limit": "List limit must be >=1 and <= 10", "no_content_type": "No content type available, please create one first", "invalid_max_fallback_attempt_limit": "Max fallback attempt limit must have positive value", + "fallback_message_required": "Fallback message is required", "regex_is_invalid": "Regex is invalid", "regex_is_empty": "Regex cannot be empty", "attachment_not_found": "Attachment is not found", diff --git a/frontend/public/locales/fr/translation.json b/frontend/public/locales/fr/translation.json index 8bc2f29f..1b986c4e 100644 --- a/frontend/public/locales/fr/translation.json +++ b/frontend/public/locales/fr/translation.json @@ -106,6 +106,7 @@ "invalid_carousel_limit": "La limite doit être >=1 et <= 10", "no_content_type": "Il n'y a aucun type de contenu pour le moment, veuillez en ajouter un.", "invalid_max_fallback_attempt_limit": "La limite des tentatives de secours doit être un nombre positif.", + "fallback_message_required": "Le message de secours est requis", "regex_is_invalid": "Le regex est invalide", "regex_is_empty": "Le regex ne peut pas être vide", "attachment_not_found": "La pièce jointe est introuvable", diff --git a/frontend/src/components/visual-editor/form/OptionsForm.tsx b/frontend/src/components/visual-editor/form/OptionsForm.tsx index 2e6a0fe1..58682661 100644 --- a/frontend/src/components/visual-editor/form/OptionsForm.tsx +++ b/frontend/src/components/visual-editor/form/OptionsForm.tsx @@ -104,6 +104,21 @@ export const OptionsForm = () => { name="options.fallback" control={control} defaultValue={block?.options?.fallback} + rules={{ + validate: (value) => { + if (!value) return true; + if (value.max_attempts > 0) { + if ( + !value.message || + value.message.every((msg) => !msg.trim()) + ) { + return t("message.fallback_message_required"); + } + } + + return true; + }, + }} render={({ field }) => ( = ({ value, onChange }) => { multiline={true} minInput={1} minRows={3} + error={!!errors.options?.fallback} + helperText={errors.options?.fallback?.message as string} onChange={(message) => { setFallback({ ...fallback,