feature/IO-1710-prevent-duplicate-ins-companies
This commit is contained in:
@@ -934,6 +934,8 @@ export function ShopInfoGeneral({ form, bodyshop }) {
|
|||||||
}}
|
}}
|
||||||
</Form.List>
|
</Form.List>
|
||||||
</LayoutFormRow>
|
</LayoutFormRow>
|
||||||
|
|
||||||
|
{/*Start Insurance Provider Row */}
|
||||||
<LayoutFormRow
|
<LayoutFormRow
|
||||||
grow
|
grow
|
||||||
header={<span id="insurancecos-header">{t("bodyshop.labels.insurancecos")}</span>}
|
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")}
|
label={t("bodyshop.fields.md_ins_co.name")}
|
||||||
key={`${index}name`}
|
key={`${index}name`}
|
||||||
name={[field.name, "name"]}
|
name={[field.name, "name"]}
|
||||||
|
dependencies={[["md_ins_cos"]]}
|
||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: true
|
required: true
|
||||||
//message: t("general.validation.required"),
|
//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 />
|
<Input />
|
||||||
@@ -1031,6 +1053,8 @@ export function ShopInfoGeneral({ form, bodyshop }) {
|
|||||||
}}
|
}}
|
||||||
</Form.List>
|
</Form.List>
|
||||||
</LayoutFormRow>
|
</LayoutFormRow>
|
||||||
|
{/*End Insurance Provider Row */}
|
||||||
|
|
||||||
<LayoutFormRow grow header={t("bodyshop.labels.estimators")} id="estimators">
|
<LayoutFormRow grow header={t("bodyshop.labels.estimators")} id="estimators">
|
||||||
<Form.List name={["md_estimators"]}>
|
<Form.List name={["md_estimators"]}>
|
||||||
{(fields, { add, remove, move }) => {
|
{(fields, { add, remove, move }) => {
|
||||||
|
|||||||
@@ -277,7 +277,8 @@
|
|||||||
"errors": {
|
"errors": {
|
||||||
"creatingdefaultview": "Error creating default view.",
|
"creatingdefaultview": "Error creating default view.",
|
||||||
"loading": "Unable to load shop details. Please call technical support.",
|
"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": {
|
"fields": {
|
||||||
"ReceivableCustomField": "QBO Receivable Custom Field {{number}}",
|
"ReceivableCustomField": "QBO Receivable Custom Field {{number}}",
|
||||||
|
|||||||
@@ -277,7 +277,8 @@
|
|||||||
"errors": {
|
"errors": {
|
||||||
"creatingdefaultview": "",
|
"creatingdefaultview": "",
|
||||||
"loading": "No se pueden cargar los detalles de la tienda. Por favor llame al soporte técnico.",
|
"loading": "No se pueden cargar los detalles de la tienda. Por favor llame al soporte técnico.",
|
||||||
"saving": ""
|
"saving": "",
|
||||||
|
"duplicate_insurance_company": ""
|
||||||
},
|
},
|
||||||
"fields": {
|
"fields": {
|
||||||
"ReceivableCustomField": "",
|
"ReceivableCustomField": "",
|
||||||
|
|||||||
@@ -277,7 +277,8 @@
|
|||||||
"errors": {
|
"errors": {
|
||||||
"creatingdefaultview": "",
|
"creatingdefaultview": "",
|
||||||
"loading": "Impossible de charger les détails de la boutique. Veuillez appeler le support technique.",
|
"loading": "Impossible de charger les détails de la boutique. Veuillez appeler le support technique.",
|
||||||
"saving": ""
|
"saving": "",
|
||||||
|
"duplicate_insurance_company": ""
|
||||||
},
|
},
|
||||||
"fields": {
|
"fields": {
|
||||||
"ReceivableCustomField": "",
|
"ReceivableCustomField": "",
|
||||||
|
|||||||
Reference in New Issue
Block a user