From b88632d395ae5288346e90b5b45e82b02efcd76f Mon Sep 17 00:00:00 2001 From: david Date: Thu, 9 Apr 2026 20:39:54 +0200 Subject: [PATCH] Pruebas --- .../shared/ui/blocks/proforma-layout.tsx | 2 +- .../web/proformas/update/ui/blocks/index.ts | 5 +- .../ui/blocks/proforma-basic-info-fields.tsx | 74 ++++ .../ui/blocks/proforma-form-field-shell.tsx | 55 +++ .../ui/blocks/proforma-header-fields-card.tsx | 68 ++- .../ui/blocks/proforma-header-form-grid.tsx | 13 + .../ui/blocks/proforma-section-card.tsx | 29 ++ .../ui/blocks/proforma-update-editor-form.tsx | 74 ++++ .../ui/blocks/proforma-update-editor.tsx | 59 --- .../web/proformas/update/ui/editors/index.ts | 1 + .../editors/proforma-update-header-editor.tsx | 391 ++++++++++++++++++ .../update/ui/pages/proforma-update-page.tsx | 106 ++--- .../pages/update/customer-update-page.tsx | 119 ------ .../src/components/form/date-picker-field.tsx | 180 +++----- .../date-input-field.tsx | 158 +++---- .../date-picker-input-comp.tsx | 282 +++++++------ .../date-picker-input-field.tsx | 46 ++- .../date-popover-calendar.tsx | 121 +++--- .../components/form/multi-select-field.tsx | 8 +- .../src/components/form/select-field.tsx | 5 +- .../src/components/form/text-area-field.tsx | 4 +- .../rdx-ui/src/components/form/text-field.tsx | 5 +- .../src/components/layout/app-layout.tsx | 2 +- packages/rdx-ui/src/locales/es.json | 6 +- packages/shadcn-ui/src/styles/globals.css | 6 +- 25 files changed, 1175 insertions(+), 644 deletions(-) create mode 100644 modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-basic-info-fields.tsx create mode 100644 modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-form-field-shell.tsx create mode 100644 modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-header-form-grid.tsx create mode 100644 modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-section-card.tsx create mode 100644 modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-update-editor-form.tsx delete mode 100644 modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-update-editor.tsx create mode 100644 modules/customer-invoices/src/web/proformas/update/ui/editors/index.ts create mode 100644 modules/customer-invoices/src/web/proformas/update/ui/editors/proforma-update-header-editor.tsx delete mode 100644 modules/customers/src/web/_archived/pages/update/customer-update-page.tsx diff --git a/modules/customer-invoices/src/web/proformas/shared/ui/blocks/proforma-layout.tsx b/modules/customer-invoices/src/web/proformas/shared/ui/blocks/proforma-layout.tsx index 097bb778..1ec7888a 100644 --- a/modules/customer-invoices/src/web/proformas/shared/ui/blocks/proforma-layout.tsx +++ b/modules/customer-invoices/src/web/proformas/shared/ui/blocks/proforma-layout.tsx @@ -1,5 +1,5 @@ import type { PropsWithChildren } from "react"; export const ProformaLayout = ({ children }: PropsWithChildren) => { - return
{children}
; + return
{children}
; }; diff --git a/modules/customer-invoices/src/web/proformas/update/ui/blocks/index.ts b/modules/customer-invoices/src/web/proformas/update/ui/blocks/index.ts index a0ac584a..28cbd977 100644 --- a/modules/customer-invoices/src/web/proformas/update/ui/blocks/index.ts +++ b/modules/customer-invoices/src/web/proformas/update/ui/blocks/index.ts @@ -1,2 +1,5 @@ +export * from "./proforma-form-field-shell"; export * from "./proforma-header-fields-card"; -export * from "./proforma-update-editor"; +export * from "./proforma-header-form-grid"; +export * from "./proforma-section-card"; +export * from "./proforma-update-editor-form"; diff --git a/modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-basic-info-fields.tsx b/modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-basic-info-fields.tsx new file mode 100644 index 00000000..a7ab80c6 --- /dev/null +++ b/modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-basic-info-fields.tsx @@ -0,0 +1,74 @@ +import { DatePickerInputField, TextField } from "@repo/rdx-ui/components"; +import { FieldDescription, FieldGroup, FieldLegend, FieldSet } from "@repo/shadcn-ui/components"; +import type { ComponentProps } from "react"; +import { useFormContext } from "react-hook-form"; + +import { useTranslation } from "../../../../i18n"; + +export const ProformaBasicInfoFields = (props: ComponentProps<"fieldset">) => { + const { t } = useTranslation(); + const { control } = useFormContext(); + + return ( +
+ + {t("form_groups.basic_info.title")} + + + {t("form_groups.basic_info.description")} + + + + + + + + + + + + + +
+ ); +}; diff --git a/modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-form-field-shell.tsx b/modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-form-field-shell.tsx new file mode 100644 index 00000000..24cd777c --- /dev/null +++ b/modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-form-field-shell.tsx @@ -0,0 +1,55 @@ +// update/ui/blocks/proforma-form-field-shell.tsx + +import { cn } from "@repo/shadcn-ui/lib/utils"; +import type { ReactNode } from "react"; + +export type ProformaFieldSpan = "xs" | "sm" | "md" | "lg" | "full"; + +const fieldSpanClasses: Record = { + xs: "md:col-span-2", + sm: "md:col-span-3", + md: "md:col-span-4", + lg: "md:col-span-6", + full: "md:col-span-12", +}; + +interface ProformaFormFieldShellProps { + label: ReactNode; + htmlFor: string; + span?: ProformaFieldSpan; + required?: boolean; + description?: ReactNode; + error?: ReactNode; + children: ReactNode; + className?: string; +} + +export const ProformaFormFieldShell = ({ + label, + htmlFor, + span = "md", + required = false, + description, + error, + children, + className, +}: ProformaFormFieldShellProps) => { + return ( +
+ + + {children} + + {description ?

{description}

: null} + + {error ? ( +

+ {error} +

+ ) : null} +
+ ); +}; diff --git a/modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-header-fields-card.tsx b/modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-header-fields-card.tsx index 6a2c742a..4c59c4d6 100644 --- a/modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-header-fields-card.tsx +++ b/modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-header-fields-card.tsx @@ -1,17 +1,83 @@ +import { DatePickerField, TextField } from "@repo/rdx-ui/components"; import { Card, CardContent, CardHeader, CardTitle, + FieldDescription, + FieldGroup, + FieldLegend, + FieldSet, Input, Textarea, } from "@repo/shadcn-ui/components"; +import type { ComponentProps } from "react"; import { useFormContext } from "react-hook-form"; import { useTranslation } from "../../../../i18n"; import type { ProformaUpdateForm } from "../../entities"; -export const ProformaHeaderFieldsCard = () => { +export const ProformaHeaderFieldsCard = (props: ComponentProps<"fieldset">) => { + const { className, ...rest } = props; + const { t } = useTranslation(); + //const { register, formState } = useFormContext(); + + return ( +
+ + {t("form_groups.basic_info.title")} + + {t("form_groups.basic_info.description")} + + + + + + + + + + + + +
+ ); +}; + +const ProformaHeaderFieldsCard2 = () => { const { t } = useTranslation(); const { register, formState } = useFormContext(); diff --git a/modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-header-form-grid.tsx b/modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-header-form-grid.tsx new file mode 100644 index 00000000..c709c2b7 --- /dev/null +++ b/modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-header-form-grid.tsx @@ -0,0 +1,13 @@ +// update/ui/blocks/proforma-header-form-grid.tsx + +import { cn } from "@repo/shadcn-ui/lib/utils"; +import type { ReactNode } from "react"; + +interface ProformaHeaderFormGridProps { + children: ReactNode; + className?: string; +} + +export const ProformaHeaderFormGrid = ({ children, className }: ProformaHeaderFormGridProps) => { + return
{children}
; +}; diff --git a/modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-section-card.tsx b/modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-section-card.tsx new file mode 100644 index 00000000..c8896604 --- /dev/null +++ b/modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-section-card.tsx @@ -0,0 +1,29 @@ +// update/ui/blocks/proforma-section-card.tsx + +import { cn } from "@repo/shadcn-ui/lib/utils"; +import type { ReactNode } from "react"; + +interface ProformaSectionCardProps { + title: string; + description?: string; + children: ReactNode; + className?: string; +} + +export const ProformaSectionCard = ({ + title, + description, + children, + className, +}: ProformaSectionCardProps) => { + return ( +
+
+

{title}

+ {description ?

{description}

: null} +
+ + {children} +
+ ); +}; diff --git a/modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-update-editor-form.tsx b/modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-update-editor-form.tsx new file mode 100644 index 00000000..c0846f79 --- /dev/null +++ b/modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-update-editor-form.tsx @@ -0,0 +1,74 @@ +// modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-update-editor.tsx + +import { Button } from "@repo/shadcn-ui/components"; +import { cn } from "@repo/shadcn-ui/lib/utils"; + +import { useTranslation } from "../../../../i18n"; +import type { Proforma } from "../../../shared/entities"; +import { ProformaUpdateHeaderEditor } from "../editors"; + +import { ProformaHeaderFieldsCard } from "./proforma-header-fields-card"; + +type ProformaUpdateEditorProps = { + formId: string; + proforma?: Proforma; + isSubmitting: boolean; + onSubmit: React.FormEventHandler; + onReset: () => void; + className?: string; +}; + +export const ProformaUpdateEditorForm = ({ + formId, + isSubmitting, + onSubmit, + onReset, + className, +}: ProformaUpdateEditorProps) => { + const { t } = useTranslation(); + + return ( +
+
+ + +
+ + + +
+
+
+ ); + + return ( +
+
+ + +
+ + + +
+
+
+ ); +}; diff --git a/modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-update-editor.tsx b/modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-update-editor.tsx deleted file mode 100644 index 2b93d0a1..00000000 --- a/modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-update-editor.tsx +++ /dev/null @@ -1,59 +0,0 @@ -// modules/customer-invoices/src/web/proformas/update/ui/blocks/proforma-update-editor.tsx - -import { AppContent, BackHistoryButton } from "@repo/rdx-ui/components"; -import { Button } from "@repo/shadcn-ui/components"; - -import { useTranslation } from "../../../../i18n"; -import type { Proforma } from "../../../shared/entities"; - -import { ProformaHeaderFieldsCard } from "./proforma-header-fields-card"; - -type ProformaUpdateEditorProps = { - formId: string; - proforma?: Proforma; - isSubmitting: boolean; - onSubmit: React.FormEventHandler; - onReset: () => void; -}; - -export const ProformaUpdateEditor = ({ - formId, - proforma, - isSubmitting, - onSubmit, - onReset, -}: ProformaUpdateEditorProps) => { - const { t } = useTranslation(); - - return ( - -
-
-

- {t("proformas.update.page_title", "Editar proforma")} -

- - {proforma?.reference ? ( -

{proforma.reference}

- ) : null} -
- - -
- -
- - -
- - - -
- -
- ); -}; diff --git a/modules/customer-invoices/src/web/proformas/update/ui/editors/index.ts b/modules/customer-invoices/src/web/proformas/update/ui/editors/index.ts new file mode 100644 index 00000000..2c24e86e --- /dev/null +++ b/modules/customer-invoices/src/web/proformas/update/ui/editors/index.ts @@ -0,0 +1 @@ +export * from "./proforma-update-header-editor"; diff --git a/modules/customer-invoices/src/web/proformas/update/ui/editors/proforma-update-header-editor.tsx b/modules/customer-invoices/src/web/proformas/update/ui/editors/proforma-update-header-editor.tsx new file mode 100644 index 00000000..c07f0acd --- /dev/null +++ b/modules/customer-invoices/src/web/proformas/update/ui/editors/proforma-update-header-editor.tsx @@ -0,0 +1,391 @@ +import { + Input, + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, + Textarea, +} from "@repo/shadcn-ui/components"; +import { Controller, useFormContext } from "react-hook-form"; + +import { useTranslation } from "../../../../i18n"; +import type { ProformaUpdateForm } from "../../entities"; +import { ProformaFormFieldShell, ProformaHeaderFormGrid, ProformaSectionCard } from "../blocks"; + +interface SelectOption { + value: string; + label: string; +} + +interface ProformaUpdateHeaderEditorProps { + statusOptions: SelectOption[]; + customerOptions: SelectOption[]; + currencyOptions: SelectOption[]; + paymentMethodOptions: SelectOption[]; + salesPersonOptions: SelectOption[]; + warehouseOptions: SelectOption[]; + priceListOptions: SelectOption[]; + disabled?: boolean; + readOnly?: boolean; +} + +export const ProformaUpdateHeaderEditor = ({ + statusOptions, + customerOptions, + currencyOptions, + paymentMethodOptions, + salesPersonOptions, + warehouseOptions, + priceListOptions, + disabled = false, + readOnly = false, +}: ProformaUpdateHeaderEditorProps) => { + const { t } = useTranslation(); + + const { + register, + control, + formState: { errors }, + } = useFormContext(); + + const isFieldLocked = disabled || readOnly; + + return ( +
+ + + + + + + + + + + + + + + + ( + + )} + /> + + + + + + + + + + + + ( + + )} + /> + + + + + + + + + + + + + + + + ( + + )} + /> + + + + ( + + )} + /> + + + + + + + + ( + + )} + /> + + + + ( + + )} + /> + + + + ( + + )} + /> + + + + + + + + + + + +