Clientes
This commit is contained in:
parent
c69a7cd142
commit
cad3a403b9
@ -58,7 +58,7 @@ export class CustomerRepository
|
||||
async update(customer: Customer, transaction?: Transaction): Promise<Result<void, Error>> {
|
||||
try {
|
||||
const mapper: ICustomerDomainMapper = this._registry.getDomainMapper({
|
||||
resource: "customer-invoice",
|
||||
resource: "customer",
|
||||
});
|
||||
const dto = mapper.mapToPersistence(customer);
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ import {
|
||||
TextField
|
||||
} from "@repo/rdx-ui/components";
|
||||
import {
|
||||
Field, FieldDescription, FieldGroup, FieldLegend, FieldSet, FormControl,
|
||||
Field, FieldDescription, FieldGroup, FieldLabel, FieldLegend, FieldSet, FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
@ -11,7 +11,7 @@ import {
|
||||
RadioGroup,
|
||||
RadioGroupItem
|
||||
} from '@repo/shadcn-ui/components';
|
||||
import { Controller, useFormContext, useWatch } from "react-hook-form";
|
||||
import { Controller, useFormContext } from "react-hook-form";
|
||||
import { CustomerInvoiceTaxesMultiSelect } from '../../../../../customer-invoices/src/web/components';
|
||||
import { useTranslation } from "../../i18n";
|
||||
import { CustomerFormData } from "../../schemas";
|
||||
@ -20,12 +20,6 @@ export const CustomerBasicInfoFields = () => {
|
||||
const { t } = useTranslation();
|
||||
const { control } = useFormContext<CustomerFormData>();
|
||||
|
||||
const isCompany = useWatch({
|
||||
control,
|
||||
name: "is_company",
|
||||
defaultValue: "true",
|
||||
});
|
||||
|
||||
return (
|
||||
<FieldSet>
|
||||
<FieldLegend>{t("form_groups.basic_info.title")}</FieldLegend>
|
||||
@ -80,7 +74,7 @@ export const CustomerBasicInfoFields = () => {
|
||||
/>
|
||||
</Field>
|
||||
|
||||
{isCompany === "false" ? (
|
||||
|
||||
<TextField
|
||||
className='lg:col-span-full'
|
||||
control={control}
|
||||
@ -89,9 +83,6 @@ export const CustomerBasicInfoFields = () => {
|
||||
placeholder={t("form_fields.trade_name.placeholder")}
|
||||
description={t("form_fields.trade_name.description")}
|
||||
/>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
|
||||
<TextField
|
||||
className='lg:col-span-2 lg:col-start-1'
|
||||
@ -101,11 +92,16 @@ export const CustomerBasicInfoFields = () => {
|
||||
placeholder={t("form_fields.reference.placeholder")}
|
||||
description={t("form_fields.reference.description")}
|
||||
/>
|
||||
|
||||
<Field className='lg:col-span-2'>
|
||||
<Controller
|
||||
control={control}
|
||||
name='default_taxes'
|
||||
render={({ field }) => (
|
||||
render={({ field, fieldState }) => (
|
||||
<Field data-invalid={fieldState.invalid} className={"gap-1"}>
|
||||
<FieldLabel className='text-xs text-muted-foreground text-nowrap' htmlFor={"default_taxes"}>
|
||||
{t("form_fields.default_taxes.label")}
|
||||
</FieldLabel>
|
||||
<CustomerInvoiceTaxesMultiSelect
|
||||
value={field.value}
|
||||
onChange={field.onChange}
|
||||
@ -114,6 +110,7 @@ export const CustomerBasicInfoFields = () => {
|
||||
placeholder={t("form_fields.default_taxes.placeholder")}
|
||||
description={t("form_fields.default_taxes.description")}
|
||||
/>
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
</Field>
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { AppBreadcrumb, AppContent } from "@repo/rdx-ui/components";
|
||||
import { AppContent, AppHeader } from "@repo/rdx-ui/components";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
import { PageHeader } from '@erp/core/components';
|
||||
import { UnsavedChangesProvider, UpdateCommitButtonGroup, useHookForm } from "@erp/core/hooks";
|
||||
import { showErrorToast, showSuccessToast } from "@repo/rdx-ui/helpers";
|
||||
import { FieldErrors, FormProvider } from "react-hook-form";
|
||||
@ -61,19 +62,13 @@ export const CustomerCreatePage = () => {
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<AppBreadcrumb />
|
||||
<AppContent>
|
||||
<UnsavedChangesProvider isDirty={form.formState.isDirty}>
|
||||
<div className='flex items-center justify-between space-y-6'>
|
||||
<div className='space-y-2'>
|
||||
<h2 className='text-2xl font-bold tracking-tight text-balance scroll-m-2'>
|
||||
{t("pages.create.title")}
|
||||
</h2>
|
||||
<p className='text-muted-foreground scroll-m-20 tracking-tight text-balance'>
|
||||
{t("pages.create.description")}
|
||||
</p>
|
||||
</div>
|
||||
<AppHeader>
|
||||
<PageHeader
|
||||
backIcon
|
||||
title={t("pages.create.title")}
|
||||
description={t("pages.create.description")}
|
||||
rightSlot={
|
||||
<UpdateCommitButtonGroup
|
||||
isLoading={isCreating}
|
||||
disabled={isCreating}
|
||||
@ -87,7 +82,10 @@ export const CustomerCreatePage = () => {
|
||||
}}
|
||||
onBack={() => handleBack()}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
</AppHeader>
|
||||
<AppContent>
|
||||
{/* Alerta de error de actualización (si ha fallado el último intento) */}
|
||||
{isCreateError && (
|
||||
<ErrorAlert
|
||||
@ -104,10 +102,11 @@ export const CustomerCreatePage = () => {
|
||||
formId='customer-create-form'
|
||||
onSubmit={handleSubmit}
|
||||
onError={handleError}
|
||||
className="bg-white rounded-xl border shadow-xl max-w-7xl mx-auto"
|
||||
/>
|
||||
</FormProvider>
|
||||
</UnsavedChangesProvider>
|
||||
|
||||
</AppContent>
|
||||
</>
|
||||
</UnsavedChangesProvider>
|
||||
);
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user