From 842cb548674ff6521e7712925e1f15702773da21 Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Thu, 27 May 2021 13:15:58 -0700 Subject: [PATCH] IO-1153 Phonebook Validation --- bodyshop_translations.babel | 42 +++++++++++++++++++ .../phonebook-form.component.jsx | 26 +++++++++++- client/src/translations/en_us/common.json | 2 + client/src/translations/es/common.json | 2 + client/src/translations/fr/common.json | 2 + 5 files changed, 73 insertions(+), 1 deletion(-) diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index a4c57daea..36244a534 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -27901,6 +27901,48 @@ labels + + noneselected + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + onenamerequired + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + vendorcategory false diff --git a/client/src/components/phonebook-form/phonebook-form.component.jsx b/client/src/components/phonebook-form/phonebook-form.component.jsx index e962a34c6..e40096ce9 100644 --- a/client/src/components/phonebook-form/phonebook-form.component.jsx +++ b/client/src/components/phonebook-form/phonebook-form.component.jsx @@ -82,7 +82,31 @@ export function PhonebookFormComponent({ - + ({ + validator(rule, value) { + const { firstname, lastname, company } = getFieldsValue([ + "firstname", + "lastname", + "company", + ]); + + if ( + (firstname && firstname.trim() !== "") || + (lastname && lastname.trim() !== "") || + (company && company.trim() !== "") + ) { + return Promise.resolve(); + } + return Promise.reject(t("phonebook.labels.onenamerequired")); + }, + }), + ]} + > diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 4dc554b3a..b978a4ac3 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -1666,6 +1666,8 @@ "state": "Province/State" }, "labels": { + "noneselected": "No phone book entry selected. ", + "onenamerequired": "At least one name related field is required.", "vendorcategory": "Vendor" }, "successes": { diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 0e50e4a16..9ebe3517d 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -1666,6 +1666,8 @@ "state": "" }, "labels": { + "noneselected": "", + "onenamerequired": "", "vendorcategory": "" }, "successes": { diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 4529a34e9..05d7f3ccf 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -1666,6 +1666,8 @@ "state": "" }, "labels": { + "noneselected": "", + "onenamerequired": "", "vendorcategory": "" }, "successes": {