From 1167f5bc141685728cad9a145e2313df12c0f5bb Mon Sep 17 00:00:00 2001 From: david Date: Sun, 12 Apr 2026 21:58:11 +0200 Subject: [PATCH] . --- .../proformas/pages/update/ui/blocks/index.ts | 1 - .../pages/update/ui/blocks/recipient/index.ts | 2 - ...roforma-recipient-modal-selector-field.tsx | 73 ------------------- .../blocks/recipient/proforma-recipient.tsx | 34 --------- .../web/proformas/update/ui/blocks/index.ts | 2 +- .../ui/blocks/proforma-section-card.tsx | 20 ++--- .../selected-recipient}/customer-card.tsx | 2 +- .../customer-view-dialog.tsx | 0 .../ui/blocks/selected-recipient/index.ts | 1 + .../selected-recipient-summary.tsx | 28 ++++--- .../proforma-update-recipient-editor.tsx | 31 +++----- .../customer-empty-card.tsx | 27 ------- .../customer-modal-selector.tsx | 4 +- modules/customers/tsconfig.json | 7 +- 14 files changed, 49 insertions(+), 183 deletions(-) delete mode 100644 modules/customer-invoices/src/web/proformas/pages/update/ui/blocks/recipient/index.ts delete mode 100644 modules/customer-invoices/src/web/proformas/pages/update/ui/blocks/recipient/proforma-recipient-modal-selector-field.tsx delete mode 100644 modules/customer-invoices/src/web/proformas/pages/update/ui/blocks/recipient/proforma-recipient.tsx rename modules/{customers/src/web/_archived/components/customer-modal-selector => customer-invoices/src/web/proformas/update/ui/blocks/selected-recipient}/customer-card.tsx (98%) rename modules/{customers/src/web/_archived/components/customer-modal-selector => customer-invoices/src/web/proformas/update/ui/blocks/selected-recipient}/customer-view-dialog.tsx (100%) create mode 100644 modules/customer-invoices/src/web/proformas/update/ui/blocks/selected-recipient/index.ts rename modules/customer-invoices/src/web/proformas/update/ui/blocks/{ => selected-recipient}/selected-recipient-summary.tsx (70%) delete mode 100644 modules/customers/src/web/_archived/components/customer-modal-selector/customer-empty-card.tsx diff --git a/modules/customer-invoices/src/web/proformas/pages/update/ui/blocks/index.ts b/modules/customer-invoices/src/web/proformas/pages/update/ui/blocks/index.ts index 8119968d..c9c839bc 100644 --- a/modules/customer-invoices/src/web/proformas/pages/update/ui/blocks/index.ts +++ b/modules/customer-invoices/src/web/proformas/pages/update/ui/blocks/index.ts @@ -1,4 +1,3 @@ export * from "./items"; export * from "./proforma-basic-info-fields"; export * from "./proforma-totals"; -export * from "./recipient"; diff --git a/modules/customer-invoices/src/web/proformas/pages/update/ui/blocks/recipient/index.ts b/modules/customer-invoices/src/web/proformas/pages/update/ui/blocks/recipient/index.ts deleted file mode 100644 index 36a4a99c..00000000 --- a/modules/customer-invoices/src/web/proformas/pages/update/ui/blocks/recipient/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./proforma-recipient"; -export * from "./proforma-recipient-modal-selector-field"; diff --git a/modules/customer-invoices/src/web/proformas/pages/update/ui/blocks/recipient/proforma-recipient-modal-selector-field.tsx b/modules/customer-invoices/src/web/proformas/pages/update/ui/blocks/recipient/proforma-recipient-modal-selector-field.tsx deleted file mode 100644 index 7a2e5fec..00000000 --- a/modules/customer-invoices/src/web/proformas/pages/update/ui/blocks/recipient/proforma-recipient-modal-selector-field.tsx +++ /dev/null @@ -1,73 +0,0 @@ -import { CustomerModalSelector } from "@erp/customers/components"; -import { Field, FieldLabel } from "@repo/shadcn-ui/components"; -import { cn } from "@repo/shadcn-ui/lib/utils"; -import type { CustomerSummary } from "node_modules/@erp/customers/src/web/schemas"; -import { type Control, Controller, type FieldPath, type FieldValues } from "react-hook-form"; - -type RecipientModalSelectorFieldProps = { - control: Control; - name: FieldPath; - - label?: string; - description?: string; - - orientation?: "vertical" | "horizontal" | "responsive"; - - disabled?: boolean; - required?: boolean; - readOnly?: boolean; - className?: string; - initialRecipient?: unknown; -}; - -export function RecipientModalSelectorField({ - control, - name, - - label, - description, - - orientation = "vertical", - - disabled = false, - required = false, - readOnly = false, - className, - initialRecipient = {}, -}: RecipientModalSelectorFieldProps) { - const isDisabled = disabled; - const isReadOnly = readOnly && !disabled; - - return ( - { - const { name, value, onChange, onBlur, ref } = field; - - return ( - - {label && ( - - {label} - - )} - - - ); - }} - /> - ); -} diff --git a/modules/customer-invoices/src/web/proformas/pages/update/ui/blocks/recipient/proforma-recipient.tsx b/modules/customer-invoices/src/web/proformas/pages/update/ui/blocks/recipient/proforma-recipient.tsx deleted file mode 100644 index d905054e..00000000 --- a/modules/customer-invoices/src/web/proformas/pages/update/ui/blocks/recipient/proforma-recipient.tsx +++ /dev/null @@ -1,34 +0,0 @@ -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"; - -import { RecipientModalSelectorField } from "./proforma-recipient-modal-selector-field"; - -export const ProformaRecipient = (props: ComponentProps<"fieldset">) => { - const { t } = useTranslation(); - const { control, getValues } = useFormContext(); - - const recipient = getValues("recipient"); - - return ( -
- - {t("form_groups.recipient.title")} - - - {t("form_groups.recipient.description")} - - - - - -
- ); -}; 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 0472be58..c3c8cd30 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 @@ -3,4 +3,4 @@ export * from "./proforma-form-field-shell"; export * from "./proforma-header-fields-card"; export * from "./proforma-header-form-grid"; export * from "./proforma-section-card"; -export * from "./selected-recipient-summary"; +export * from "./selected-recipient"; 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 index a6e01920..5dddd452 100644 --- 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 @@ -5,7 +5,7 @@ import { cn } from "@repo/shadcn-ui/lib/utils"; import type { ReactNode } from "react"; interface ProformaSectionCardProps { - title: string; + title?: string; description?: string; children: ReactNode; className?: string; @@ -20,14 +20,16 @@ export const ProformaSectionCard = ({ return (
- -

{title}

- {description ? ( - - {description} - - ) : null} -
+ {title || description ? ( + + {title ?

{title}

: null} + {description ? ( + + {description} + + ) : null} +
+ ) : null} {children}
diff --git a/modules/customers/src/web/_archived/components/customer-modal-selector/customer-card.tsx b/modules/customer-invoices/src/web/proformas/update/ui/blocks/selected-recipient/customer-card.tsx similarity index 98% rename from modules/customers/src/web/_archived/components/customer-modal-selector/customer-card.tsx rename to modules/customer-invoices/src/web/proformas/update/ui/blocks/selected-recipient/customer-card.tsx index b2c85cff..1d45932d 100644 --- a/modules/customers/src/web/_archived/components/customer-modal-selector/customer-card.tsx +++ b/modules/customer-invoices/src/web/proformas/update/ui/blocks/selected-recipient/customer-card.tsx @@ -3,7 +3,7 @@ import { cn } from "@repo/shadcn-ui/lib/utils"; import { EyeIcon, MapPinIcon, RefreshCwIcon, UserPlusIcon } from "lucide-react"; import React, { useMemo } from "react"; -import type { CustomerSummary } from "../../schemas"; +import type { CustomerSummary } from "../../../../../../../../customers/src/web/_archived/schemas"; interface CustomerCardProps { customer: CustomerSummary; diff --git a/modules/customers/src/web/_archived/components/customer-modal-selector/customer-view-dialog.tsx b/modules/customer-invoices/src/web/proformas/update/ui/blocks/selected-recipient/customer-view-dialog.tsx similarity index 100% rename from modules/customers/src/web/_archived/components/customer-modal-selector/customer-view-dialog.tsx rename to modules/customer-invoices/src/web/proformas/update/ui/blocks/selected-recipient/customer-view-dialog.tsx diff --git a/modules/customer-invoices/src/web/proformas/update/ui/blocks/selected-recipient/index.ts b/modules/customer-invoices/src/web/proformas/update/ui/blocks/selected-recipient/index.ts new file mode 100644 index 00000000..2604913d --- /dev/null +++ b/modules/customer-invoices/src/web/proformas/update/ui/blocks/selected-recipient/index.ts @@ -0,0 +1 @@ +export * from "./selected-recipient-summary"; diff --git a/modules/customer-invoices/src/web/proformas/update/ui/blocks/selected-recipient-summary.tsx b/modules/customer-invoices/src/web/proformas/update/ui/blocks/selected-recipient/selected-recipient-summary.tsx similarity index 70% rename from modules/customer-invoices/src/web/proformas/update/ui/blocks/selected-recipient-summary.tsx rename to modules/customer-invoices/src/web/proformas/update/ui/blocks/selected-recipient/selected-recipient-summary.tsx index a9cbb0b0..4fd1a77a 100644 --- a/modules/customer-invoices/src/web/proformas/update/ui/blocks/selected-recipient-summary.tsx +++ b/modules/customer-invoices/src/web/proformas/update/ui/blocks/selected-recipient/selected-recipient-summary.tsx @@ -1,15 +1,21 @@ import type { CustomerSelectionOption } from "@erp/customers"; import { Button } from "@repo/shadcn-ui/components"; -import { useTranslation } from "../../../../i18n"; +import { useTranslation } from "../../../../../i18n"; type SelectedRecipientSummaryProps = { + disabled?: boolean; + readOnly?: boolean; + recipient?: CustomerSelectionOption | null; onChangeClick: () => void; onCreateClick?: () => void; }; export const SelectedRecipientSummary = ({ + disabled = false, + readOnly = false, + recipient, onChangeClick, onCreateClick, @@ -17,11 +23,9 @@ export const SelectedRecipientSummary = ({ const { t } = useTranslation(); return ( -
+
-

{t("customers.selected_customer.title", "Cliente")}

- {recipient ? (

{recipient.name}

@@ -37,17 +41,19 @@ export const SelectedRecipientSummary = ({
- {onCreateClick ? ( + {onCreateClick && !readOnly && !disabled && ( - ) : null} + )} - + {onChangeClick && !readOnly && !disabled && ( + + )}
diff --git a/modules/customer-invoices/src/web/proformas/update/ui/editors/proforma-update-recipient-editor.tsx b/modules/customer-invoices/src/web/proformas/update/ui/editors/proforma-update-recipient-editor.tsx index 407468a8..a3f3a489 100644 --- a/modules/customer-invoices/src/web/proformas/update/ui/editors/proforma-update-recipient-editor.tsx +++ b/modules/customer-invoices/src/web/proformas/update/ui/editors/proforma-update-recipient-editor.tsx @@ -1,9 +1,7 @@ import type { CustomerSelectionOption } from "@erp/customers"; -import { useFormContext } from "react-hook-form"; import { useTranslation } from "../../../../i18n"; -import type { ProformaUpdateForm } from "../../entities"; -import { ProformaHeaderFormGrid, ProformaSectionCard, SelectedRecipientSummary } from "../blocks"; +import { ProformaSectionCard, SelectedRecipientSummary } from "../blocks"; interface ProformaUpdateRecipientEditorProps { disabled?: boolean; @@ -24,26 +22,15 @@ export const ProformaUpdateRecipientEditor = ({ }: ProformaUpdateRecipientEditorProps) => { const { t } = useTranslation(); - const { - register, - control, - formState: { errors }, - } = useFormContext(); - - const isFieldLocked = disabled || readOnly; - return ( - - - - + + ); }; diff --git a/modules/customers/src/web/_archived/components/customer-modal-selector/customer-empty-card.tsx b/modules/customers/src/web/_archived/components/customer-modal-selector/customer-empty-card.tsx deleted file mode 100644 index 1accd7f4..00000000 --- a/modules/customers/src/web/_archived/components/customer-modal-selector/customer-empty-card.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { UserSearchIcon } from "lucide-react"; - -export const CustomerEmptyCard = (props: React.ComponentProps<"button">) => { - return ( - - ); -}; diff --git a/modules/customers/src/web/_archived/components/customer-modal-selector/customer-modal-selector.tsx b/modules/customers/src/web/_archived/components/customer-modal-selector/customer-modal-selector.tsx index 3ed2242d..8cfbe603 100644 --- a/modules/customers/src/web/_archived/components/customer-modal-selector/customer-modal-selector.tsx +++ b/modules/customers/src/web/_archived/components/customer-modal-selector/customer-modal-selector.tsx @@ -1,5 +1,6 @@ import { useEffect, useId, useMemo, useState } from "react"; +import { CustomerEmptyCard } from "../../../../../../customer-invoices/src/web/proformas/update/ui/blocks/selected-recipient/selected-recipient-empty-card"; import { useCustomerListQuery } from "../../hooks"; import { type CustomerFormData, @@ -7,9 +8,10 @@ import { defaultCustomerFormData, } from "../../schemas"; +../../../../../../customer-invoices/src/web/proformas/update/ui/blocks/selected-recipient/customer-card + import { CustomerCard } from "./customer-card"; import { CustomerCreateModal } from "./customer-create-modal"; -import { CustomerEmptyCard } from "./customer-empty-card"; import { CustomerSearchDialog } from "./customer-search-dialog"; import { CustomerViewDialog } from "./customer-view-dialog"; diff --git a/modules/customers/tsconfig.json b/modules/customers/tsconfig.json index 4fea4749..733bf13f 100644 --- a/modules/customers/tsconfig.json +++ b/modules/customers/tsconfig.json @@ -28,6 +28,11 @@ "noFallthroughCasesInSwitch": true, "noUncheckedSideEffectImports": true }, - "include": ["src"], + "include": [ + "src", + "../customer-invoices/src/web/proformas/update/ui/blocks/selected-recipient/customer-view-dialog.tsx", + "../customer-invoices/src/web/proformas/update/ui/blocks/selected-recipient/customer-card.tsx", + "../customer-invoices/src/web/proformas/update/ui/blocks/selected-recipient/selected-recipient-empty-card.tsx" + ], "exclude": ["node_modules"] }