-
+
+
diff --git a/modules/customers/src/web/components/customer-modal-selector/customer-create-modal.tsx b/modules/customers/src/web/components/customer-modal-selector/customer-create-modal.tsx
index 0a13619c..21791a87 100644
--- a/modules/customers/src/web/components/customer-modal-selector/customer-create-modal.tsx
+++ b/modules/customers/src/web/components/customer-modal-selector/customer-create-modal.tsx
@@ -10,7 +10,7 @@ import {
DialogTitle,
} from "@repo/shadcn-ui/components";
import { Plus } from "lucide-react";
-import { useId } from 'react';
+import { useCallback, useId } from 'react';
import { useTranslation } from "../../i18n";
import { useCustomerCreateController } from '../../pages/create/use-customer-create-controller';
import { CustomerFormData } from "../../schemas";
@@ -32,6 +32,8 @@ export function CustomerCreateModal({
const { t } = useTranslation();
const formId = useId();
+ const { requestConfirm } = useUnsavedChangesContext();
+
const {
form, isCreating, isCreateError, createError,
handleSubmit, handleError, FormProvider
@@ -39,31 +41,40 @@ export function CustomerCreateModal({
const { isDirty } = form.formState;
- const guardClose = async (nextOpen: boolean) => {
+ const guardClose = useCallback(async (nextOpen: boolean) => {
if (nextOpen) return onOpenChange(true);
+
if (isCreating) return;
- const { requestConfirm } = useUnsavedChangesContext();
- const ok = await requestConfirm();
- if (ok) onOpenChange(false);
- };
+
+ if (!isDirty) {
+ return onOpenChange(false);
+ }
+
+ if (await requestConfirm()) {
+ return onOpenChange(false);
+ }
+ }, [requestConfirm, isCreating, onOpenChange, isDirty]);
+
+
+ const handleFormSubmit = (data: CustomerFormData) => handleSubmit(data /*, () => onOpenChange(false)*/);
return (
-
-
-
-
-
-
-
-
-
);
}
\ No newline at end of file
diff --git a/modules/customers/src/web/components/customer-modal-selector/customer-modal-selector-field.tsx b/modules/customers/src/web/components/customer-modal-selector/customer-modal-selector-field.tsx
index e024582f..78828f4a 100644
--- a/modules/customers/src/web/components/customer-modal-selector/customer-modal-selector-field.tsx
+++ b/modules/customers/src/web/components/customer-modal-selector/customer-modal-selector-field.tsx
@@ -1,43 +1,73 @@
-import { FormField, FormItem } from "@repo/shadcn-ui/components";
+import { Field, FieldLabel } from "@repo/shadcn-ui/components";
-import { Control, FieldPath, FieldValues } from "react-hook-form";
+import { cn } from '@repo/shadcn-ui/lib/utils';
+import { Control, Controller, FieldPath, FieldValues } from "react-hook-form";
+import { CustomerSummary } from '../../schemas';
import { CustomerModalSelector } from "./customer-modal-selector";
type CustomerModalSelectorFieldProps
= {
control: Control;
name: FieldPath;
+
+ label?: string;
+ description?: string;
+
+ orientation?: "vertical" | "horizontal" | "responsive",
+
disabled?: boolean;
+ required?: boolean;
readOnly?: boolean;
className?: string;
+ initiaCustomer?: unknown;
};
export function CustomerModalSelectorField({
control,
name,
- disabled = false, // Solo lectura y sin botones
- readOnly = false, // Solo se puede ver la ficha del cliente
+
+ label,
+ description,
+
+ orientation = 'vertical',
+
+
+ disabled = false,
+ required = false,
+ readOnly = false,
className,
+ initiaCustomer = {},
}: CustomerModalSelectorFieldProps) {
const isDisabled = disabled;
const isReadOnly = readOnly && !disabled;
return (
- {
+ render={({ field, fieldState }) => {
const { name, value, onChange, onBlur, ref } = field;
+
return (
-
+
+ {label && (
+
+ {label}
+
+ )}
-
+
);
}}
/>
);
-}
+}
\ No newline at end of file
diff --git a/modules/customers/src/web/components/editor/customer-additional-config-fields.tsx b/modules/customers/src/web/components/editor/customer-additional-config-fields.tsx
index e186f566..a9a5b5d9 100644
--- a/modules/customers/src/web/components/editor/customer-additional-config-fields.tsx
+++ b/modules/customers/src/web/components/editor/customer-additional-config-fields.tsx
@@ -6,12 +6,19 @@ import { CURRENCY_OPTIONS, LANGUAGE_OPTIONS } from "../../constants";
import { useTranslation } from "../../i18n";
import { CustomerFormData } from "../../schemas";
-export const CustomerAdditionalConfigFields = () => {
+interface CustomerAdditionalConfigFieldsProps {
+ className?: string;
+}
+
+
+export const CustomerAdditionalConfigFields = ({
+ className, ...props
+}: CustomerAdditionalConfigFieldsProps) => {
const { t } = useTranslation();
const { control } = useFormContext();
return (
-