diff --git a/modules/customers/src/api/application/mappers/update-customer-input.mapper.ts b/modules/customers/src/api/application/mappers/update-customer-input.mapper.ts index dbc80708..415cf7de 100644 --- a/modules/customers/src/api/application/mappers/update-customer-input.mapper.ts +++ b/modules/customers/src/api/application/mappers/update-customer-input.mapper.ts @@ -53,6 +53,8 @@ export class UpdateCustomerInputMapper implements IUpdateCustomerInputMapper { const errors: ValidationErrorDetail[] = []; const customerPatchProps: CustomerPatchProps = {}; + console.log(dto); + toPatchField(dto.reference).ifSet((reference) => { customerPatchProps.reference = extractOrPushError( maybeFromNullableResult(reference, (value) => Name.create(value)), diff --git a/modules/customers/src/common/locales/es.json b/modules/customers/src/common/locales/es.json index 8921b099..4bc6c92b 100644 --- a/modules/customers/src/common/locales/es.json +++ b/modules/customers/src/common/locales/es.json @@ -122,7 +122,7 @@ "email_secondary": { "label": "Email secundario", "placeholder": "Ingrese el correo electrónico", - "description": "La dirección de correo electrónico secundario del clientºe" + "description": "La dirección de correo electrónico secundario del cliente" }, "phone_primary": { "label": "Teléfono", diff --git a/modules/customers/src/web/update/adapters/customer-to-customer-update-form.adapter.ts b/modules/customers/src/web/update/adapters/customer-to-customer-update-form.adapter.ts index 1e96f903..8cfc2300 100644 --- a/modules/customers/src/web/update/adapters/customer-to-customer-update-form.adapter.ts +++ b/modules/customers/src/web/update/adapters/customer-to-customer-update-form.adapter.ts @@ -39,7 +39,7 @@ export const mapCustomerToCustomerUpdateForm = (customer: Customer): CustomerUpd legalRecord: customer.legalRecord ?? "", - languageCode: customer.languageCode ?? "ES", + languageCode: customer.languageCode ?? "es", currencyCode: customer.currencyCode ?? "EUR", }; }; diff --git a/modules/customers/src/web/update/entities/customer-update-form-defaults.ts b/modules/customers/src/web/update/entities/customer-update-form-defaults.ts index 5b31227f..96b5246a 100644 --- a/modules/customers/src/web/update/entities/customer-update-form-defaults.ts +++ b/modules/customers/src/web/update/entities/customer-update-form-defaults.ts @@ -28,6 +28,6 @@ export const defaultCustomerUpdateForm: CustomerUpdateForm = { legalRecord: "", - languageCode: "ES", + languageCode: "es", currencyCode: "EUR", }; diff --git a/modules/customers/src/web/update/entities/customer-update-form.schema.ts b/modules/customers/src/web/update/entities/customer-update-form.schema.ts index 9f8a9771..1b4ac7f2 100644 --- a/modules/customers/src/web/update/entities/customer-update-form.schema.ts +++ b/modules/customers/src/web/update/entities/customer-update-form.schema.ts @@ -15,32 +15,33 @@ import { z } from "zod/v4"; */ export const CustomerUpdateFormSchema = z.object({ - reference: z.string(), + reference: z.string().optional().or(z.literal("")), isCompany: z.boolean(), name: z.string().min(1, "El nombre es obligatorio"), - tradeName: z.string(), + tradeName: z.string().optional().or(z.literal("")), tin: z.string(), defaultTaxes: z.array(z.string()), - street: z.string(), - street2: z.string(), - city: z.string(), - province: z.string(), - postalCode: z.string(), - country: z.string().min(1, "El país es obligatorio"), + street: z.string().optional().or(z.literal("")), + street2: z.string().optional().or(z.literal("")), + city: z.string().optional().or(z.literal("")), + province: z.string().optional().or(z.literal("")), + postalCode: z.string().optional().or(z.literal("")), + country: z.string().min(1, "El país es obligatorio").optional().or(z.literal("")), - primaryEmail: z.string(), - secondaryEmail: z.string(), - primaryPhone: z.string(), - secondaryPhone: z.string(), - primaryMobile: z.string(), - secondaryMobile: z.string(), + primaryEmail: z.email("Email inválido").optional().or(z.literal("")), + secondaryEmail: z.email("Email inválido").optional().or(z.literal("")), - fax: z.string(), - website: z.string(), + primaryPhone: z.string().optional().or(z.literal("")), + secondaryPhone: z.string().optional().or(z.literal("")), + primaryMobile: z.string().optional().or(z.literal("")), + secondaryMobile: z.string().optional().or(z.literal("")), - legalRecord: z.string(), + fax: z.string().optional().or(z.literal("")), + website: z.url("URL inválida").optional().or(z.literal("")), + + legalRecord: z.string().optional().or(z.literal("")), languageCode: z.string().min(1, "El idioma es obligatorio"), currencyCode: z.string().min(1, "La moneda es obligatoria"), diff --git a/modules/customers/src/web/update/ui/editor/customer-basic-info-fields.tsx b/modules/customers/src/web/update/ui/editor/customer-basic-info-fields.tsx index 0c58a0c3..4bd6e641 100644 --- a/modules/customers/src/web/update/ui/editor/customer-basic-info-fields.tsx +++ b/modules/customers/src/web/update/ui/editor/customer-basic-info-fields.tsx @@ -1,4 +1,4 @@ -import { RadioGroupField, TextAreaField, TextField } from "@repo/rdx-ui/components"; +import { FormFieldLabel, TextAreaField, TextField } from "@repo/rdx-ui/components"; import { Field, FieldDescription, @@ -7,6 +7,9 @@ import { FieldLabel, FieldLegend, FieldSet, + FormControl, + RadioGroup, + RadioGroupItem, } from "@repo/shadcn-ui/components"; import { useEffect } from "react"; import { Controller, useFormContext } from "react-hook-form"; @@ -53,23 +56,38 @@ export const CustomerBasicInfoFields = ({ name="isCompany" render={({ field, fieldState }) => ( - field.onChange(value === "true")} - value={String(field.value)} - /> + {t("form_fields.customer_type.label")} + + + field.onChange(value === "true")} + value={String(field.value)} + > +
+ + +
+ +
+ + +
+
+
+ + {t("form_fields.customer_type.description")}
)}