From b7396881b3bd5e35807bfd44b68b21e21e592b4c Mon Sep 17 00:00:00 2001 From: david Date: Sun, 21 Sep 2025 21:10:05 +0200 Subject: [PATCH] Clientes --- apps/web/index.html | 10 - modules/core/src/web/components/form/index.ts | 2 +- .../form/taxes-multi-select-field.tsx.bak | 30 ++ .../src/web/components/taxes-multi-select.tsx | 5 +- modules/core/src/web/constants/index.ts | 1 + modules/core/src/web/constants/taxes.ts | 30 ++ modules/customers/src/common/locales/en.json | 5 + modules/customers/src/common/locales/es.json | 5 + .../src/web/constants/customer.constants.ts | 16 +- .../customer-additional-config-fields.tsx | 2 +- .../pages/update/customer-address-fields.tsx | 99 ++-- .../update/customer-basic-info-fields.tsx | 2 +- .../pages/update/customer-contact-fields.tsx | 6 +- .../web/pages/update/customer-edit-form.tsx | 2 + .../src/components/form/SelectField.tsx | 22 +- packages/rdx-ui/src/components/form/index.tsx | 1 + .../components/form/multi-select-field.tsx | 459 ++++++++++++++++++ .../rdx-ui/src/components/multi-select.tsx | 4 +- packages/shadcn-ui/src/components/label.tsx | 19 +- packages/shadcn-ui/src/styles/globals.css | 13 +- 20 files changed, 641 insertions(+), 92 deletions(-) create mode 100644 modules/core/src/web/components/form/taxes-multi-select-field.tsx.bak create mode 100644 modules/core/src/web/constants/index.ts create mode 100644 modules/core/src/web/constants/taxes.ts create mode 100644 packages/rdx-ui/src/components/form/multi-select-field.tsx diff --git a/apps/web/index.html b/apps/web/index.html index c6d6ac78..90c7a9ff 100644 --- a/apps/web/index.html +++ b/apps/web/index.html @@ -7,16 +7,6 @@ - - - - - - FactuGES 2025 diff --git a/modules/core/src/web/components/form/index.ts b/modules/core/src/web/components/form/index.ts index 90f1bc4a..960ce369 100644 --- a/modules/core/src/web/components/form/index.ts +++ b/modules/core/src/web/components/form/index.ts @@ -1 +1 @@ -export * from "./taxes-multi-select-field"; +export * from "./taxes-multi-select-field.tsx"; diff --git a/modules/core/src/web/components/form/taxes-multi-select-field.tsx.bak b/modules/core/src/web/components/form/taxes-multi-select-field.tsx.bak new file mode 100644 index 00000000..127f2c78 --- /dev/null +++ b/modules/core/src/web/components/form/taxes-multi-select-field.tsx.bak @@ -0,0 +1,30 @@ +import { MultiSelectField, MultiSelectFieldProps } from "@repo/rdx-ui/components"; +import * as React from "react"; +import type { FieldValues } from "react-hook-form"; +import { TaxesList } from "../../constants"; + +/** + * Igual que MultiSelect pero con `options` preconfiguradas a TaxesList. + * Puedes sobreescribir `options` si lo necesitas, se mergean (TaxesList primero). + */ +export type TaxesMultiSelectFieldProps = Omit< + MultiSelectFieldProps, + "options" +>; + +const TaxesMultiSelectFieldInner = React.forwardRef( + ( + props: TaxesMultiSelectFieldProps, + ref: React.Ref + ) => { + return ( + )} options={TaxesList} /> + ); + } +); + +TaxesMultiSelectFieldInner.displayName = "TaxesMultiSelectField"; + +export const TaxesMultiSelectField = TaxesMultiSelectFieldInner as ( + p: TaxesMultiSelectFieldProps & { ref?: React.Ref } +) => React.JSX.Element; diff --git a/modules/core/src/web/components/taxes-multi-select.tsx b/modules/core/src/web/components/taxes-multi-select.tsx index d7671e63..435b17e5 100644 --- a/modules/core/src/web/components/taxes-multi-select.tsx +++ b/modules/core/src/web/components/taxes-multi-select.tsx @@ -2,7 +2,7 @@ import { MultiSelect } from "@repo/rdx-ui/components"; import { cn } from "@repo/shadcn-ui/lib/utils"; import { useTranslation } from "../i18n"; -const taxesList = [ +export const TaxesList = [ { label: "IVA 21%", value: "iva_21", group: "IVA" }, { label: "IVA 10%", value: "iva_10", group: "IVA" }, { label: "IVA 7,5%", value: "iva_7_5", group: "IVA" }, @@ -34,6 +34,7 @@ const taxesList = [ ]; interface TaxesMultiSelect { + name: string; value: string[]; onChange: (selectedValues: string[]) => void; [key: string]: any; // Allow other props to be passed @@ -58,7 +59,7 @@ export const TaxesMultiSelect = (props: TaxesMultiSelect) => { return (
{ const { control } = useForm(); return ( - + {t("form_groups.preferences.title")} {t("form_groups.preferences.description")} diff --git a/modules/customers/src/web/pages/update/customer-address-fields.tsx b/modules/customers/src/web/pages/update/customer-address-fields.tsx index f8e2a4c9..f879b1c7 100644 --- a/modules/customers/src/web/pages/update/customer-address-fields.tsx +++ b/modules/customers/src/web/pages/update/customer-address-fields.tsx @@ -13,54 +13,65 @@ export function CustomerAddressFields({ control }: { control: any }) { const { t } = useTranslation(); return ( - + {t("form_groups.address.title")} {t("form_groups.address.description")} - - - - - - + +
+ + + + + +
+
+ + +
); diff --git a/modules/customers/src/web/pages/update/customer-basic-info-fields.tsx b/modules/customers/src/web/pages/update/customer-basic-info-fields.tsx index 10ec6dd6..d2717525 100644 --- a/modules/customers/src/web/pages/update/customer-basic-info-fields.tsx +++ b/modules/customers/src/web/pages/update/customer-basic-info-fields.tsx @@ -20,7 +20,7 @@ export const CustomerBasicInfoFields = ({ control }: { control: any }) => { const { t } = useTranslation(); return ( - + Identificación diff --git a/modules/customers/src/web/pages/update/customer-contact-fields.tsx b/modules/customers/src/web/pages/update/customer-contact-fields.tsx index b8263013..d43d9b69 100644 --- a/modules/customers/src/web/pages/update/customer-contact-fields.tsx +++ b/modules/customers/src/web/pages/update/customer-contact-fields.tsx @@ -19,7 +19,7 @@ export function CustomerContactFields({ control }: { control: any }) { const [open, setOpen] = useState(true); return ( - + {t("form_groups.contact_info.title")} {t("form_groups.contact_info.description")} @@ -55,7 +55,7 @@ export function CustomerContactFields({ control }: { control: any }) { /> -
+
+ +
diff --git a/packages/rdx-ui/src/components/form/SelectField.tsx b/packages/rdx-ui/src/components/form/SelectField.tsx index 82bada63..ec6d10b8 100644 --- a/packages/rdx-ui/src/components/form/SelectField.tsx +++ b/packages/rdx-ui/src/components/form/SelectField.tsx @@ -13,7 +13,7 @@ import { } from "@repo/shadcn-ui/components"; import { cn } from "@repo/shadcn-ui/lib/utils"; -import { Control, FieldPath, FieldValues } from "react-hook-form"; +import { Control, FieldPath, FieldValues, useController, useFormState } from "react-hook-form"; import { useTranslation } from "../../locales/i18n.ts"; type SelectFieldProps = { @@ -42,6 +42,10 @@ export function SelectField({ className, }: SelectFieldProps) { const { t } = useTranslation(); + + const { isSubmitting, isValidating } = useFormState({ control, name }); + const { field, fieldState } = useController({ control, name }); + const isDisabled = disabled || readOnly; return ( @@ -51,9 +55,19 @@ export function SelectField({ render={({ field }) => ( {label && ( -
- {label} - {required && {t("common.required")}} +
+
+ + {label} + + {required && ( + {t("common.required")} + )} +
+ {/* Punto “unsaved” */} + {fieldState.isDirty && ( + {t("common.modified")} + )}
)}