Merged in release/2025-12-19 (pull request #2750)
feature/IO-1710-prevent-duplicate-ins-companies
This commit is contained in:
@@ -934,6 +934,8 @@ export function ShopInfoGeneral({ form, bodyshop }) {
|
||||
}}
|
||||
</Form.List>
|
||||
</LayoutFormRow>
|
||||
|
||||
{/*Start Insurance Provider Row */}
|
||||
<LayoutFormRow
|
||||
grow
|
||||
header={<span id="insurancecos-header">{t("bodyshop.labels.insurancecos")}</span>}
|
||||
@@ -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();
|
||||
}
|
||||
})
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
@@ -1031,6 +1053,8 @@ export function ShopInfoGeneral({ form, bodyshop }) {
|
||||
}}
|
||||
</Form.List>
|
||||
</LayoutFormRow>
|
||||
{/*End Insurance Provider Row */}
|
||||
|
||||
<LayoutFormRow grow header={t("bodyshop.labels.estimators")} id="estimators">
|
||||
<Form.List name={["md_estimators"]}>
|
||||
{(fields, { add, remove, move }) => {
|
||||
|
||||
@@ -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}}",
|
||||
|
||||
@@ -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": "",
|
||||
|
||||
@@ -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": "",
|
||||
|
||||
Reference in New Issue
Block a user