diff --git a/client/src/components/shop-info/shop-info.general.component.jsx b/client/src/components/shop-info/shop-info.general.component.jsx index 04bfb6563..f0ebb9826 100644 --- a/client/src/components/shop-info/shop-info.general.component.jsx +++ b/client/src/components/shop-info/shop-info.general.component.jsx @@ -934,6 +934,8 @@ export function ShopInfoGeneral({ form, bodyshop }) { }} + + {/*Start Insurance Provider Row */} {t("bodyshop.labels.insurancecos")}} @@ -950,11 +952,31 @@ export function ShopInfoGeneral({ form, bodyshop }) { label={t("bodyshop.fields.md_ins_co.name")} key={`${index}name`} name={[field.name, "name"]} + dependencies={[["md_ins_cos"]]} rules={[ { required: true //message: t("general.validation.required"), - } + }, + ({ getFieldValue }) => ({ + validator: async (_, value) => { + const normalizedValue = (value ?? "").toString().trim().toLowerCase(); + if (!normalizedValue) return Promise.resolve(); // handled by required + + const list = getFieldValue(["md_ins_cos"]) || []; + const normalizedNames = list + .map((c) => (c?.name ?? "").toString().trim().toLowerCase()) + .filter(Boolean); + + const count = normalizedNames.filter((n) => n === normalizedValue).length; + + if (count > 1) { + throw new Error(t("bodyshop.errors.duplicate_insurance_company")); + } + + return Promise.resolve(); + } + }) ]} > @@ -1031,6 +1053,8 @@ export function ShopInfoGeneral({ form, bodyshop }) { }} + {/*End Insurance Provider Row */} + {(fields, { add, remove, move }) => { diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index fa2dcb9b6..ead7b78c6 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -277,7 +277,8 @@ "errors": { "creatingdefaultview": "Error creating default view.", "loading": "Unable to load shop details. Please call technical support.", - "saving": "Error encountered while saving. {{message}}" + "saving": "Error encountered while saving. {{message}}", + "duplicate_insurance_company": "Duplicate insurance company name. Each insurance company name must be unique" }, "fields": { "ReceivableCustomField": "QBO Receivable Custom Field {{number}}", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index fb069d9b4..81cfa9472 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -277,7 +277,8 @@ "errors": { "creatingdefaultview": "", "loading": "No se pueden cargar los detalles de la tienda. Por favor llame al soporte técnico.", - "saving": "" + "saving": "", + "duplicate_insurance_company": "" }, "fields": { "ReceivableCustomField": "", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 3fcf19fad..f321608fa 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -277,7 +277,8 @@ "errors": { "creatingdefaultview": "", "loading": "Impossible de charger les détails de la boutique. Veuillez appeler le support technique.", - "saving": "" + "saving": "", + "duplicate_insurance_company": "" }, "fields": { "ReceivableCustomField": "",