This commit is contained in:
Mohamed Chedli Ben Yaghlane 2025-06-13 07:35:14 +01:00 committed by GitHub
commit 5290c4d4c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 0 deletions

View File

@ -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",

View File

@ -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",

View File

@ -104,6 +104,21 @@ export const OptionsForm = () => {
name="options.fallback"
control={control}
defaultValue={block?.options?.fallback}
rules={{
validate: (value) => {
const hasNoValue = !value;
const localFallbackDisabled = value?.max_attempts === 0;
const hasValidFallbackMessage =
Array.isArray(value?.message) &&
value.message.some((m) => m?.trim());
return hasNoValue ||
localFallbackDisabled ||
hasValidFallbackMessage
? true
: t("message.fallback_message_required");
},
}}
render={({ field }) => (
<LocalFallbackInput
value={field?.value}

View File

@ -95,6 +95,8 @@ const LocalFallbackInput: FC<LocalFallbackProps> = ({ value, onChange }) => {
multiline={true}
minInput={1}
minRows={3}
error={!!errors.options?.fallback}
helperText={errors.options?.fallback?.message as string}
onChange={(message) => {
setFallback({
...fallback,