Facturas de cliente
This commit is contained in:
parent
fdbdb0ee26
commit
29bbd51b0d
@ -94,7 +94,7 @@ export const UpdateCommitButtonGroup = ({
|
||||
className
|
||||
)}
|
||||
>
|
||||
{preview && <SubmitFormButton {...submit} />}
|
||||
|
||||
{submit && <SubmitFormButton {...submit} />}
|
||||
{showCancel && <CancelFormButton {...cancel} />}
|
||||
|
||||
|
||||
@ -1 +1,4 @@
|
||||
export * from "./invoice-edit-form";
|
||||
export * from "./invoice-basic-info-fields";
|
||||
export * from "./invoice-items-editor";
|
||||
export * from "./invoice-totals";
|
||||
export * from "./recipient";
|
||||
|
||||
@ -9,8 +9,7 @@ export const InvoiceRecipient = (props: ComponentProps<"fieldset">) => {
|
||||
const { t } = useTranslation();
|
||||
const { control, getValues } = useFormContext();
|
||||
|
||||
|
||||
const recipient = getValues('recipient');
|
||||
const recipient = getValues("recipient");
|
||||
|
||||
return (
|
||||
<FieldSet {...props}>
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
export * from "../pages/list/invoices-list-grid";
|
||||
export * from "./customer-invoice-editor-skeleton";
|
||||
export * from "./customer-invoice-prices-card";
|
||||
export * from "./customer-invoice-status-badge";
|
||||
|
||||
@ -4,10 +4,10 @@ import { Button } from "@repo/shadcn-ui/components";
|
||||
import { PlusIcon } from "lucide-react";
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { InvoicesListGrid, PageHeader } from '../../components';
|
||||
import { useInvoicesQuery } from '../../hooks';
|
||||
import { useTranslation } from "../../i18n";
|
||||
import { invoiceResumeDtoToFormAdapter } from '../../schemas/invoice-resume-dto.adapter';
|
||||
import { InvoicesListGrid } from './invoices-list-grid';
|
||||
|
||||
export const InvoiceListPage = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
@ -9,7 +9,6 @@ import { useMemo } from 'react';
|
||||
import { FieldErrors, FormProvider } from "react-hook-form";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import {
|
||||
InvoiceEditForm,
|
||||
PageHeader
|
||||
} from "../../components";
|
||||
import { useInvoiceContext } from '../../context';
|
||||
@ -22,6 +21,7 @@ import {
|
||||
defaultCustomerInvoiceFormData,
|
||||
invoiceDtoToFormAdapter
|
||||
} from "../../schemas";
|
||||
import { InvoiceUpdateForm } from './invoice-update-form';
|
||||
|
||||
|
||||
export type InvoiceUpdateCompProps = {
|
||||
@ -104,7 +104,7 @@ export const InvoiceUpdateComp = ({
|
||||
|
||||
<AppContent>
|
||||
<FormProvider {...form}>
|
||||
<InvoiceEditForm
|
||||
<InvoiceUpdateForm
|
||||
formId="invoice-update-form"
|
||||
onSubmit={handleSubmit}
|
||||
onError={handleError}
|
||||
|
||||
@ -2,25 +2,22 @@ import { FieldErrors, useFormContext } from "react-hook-form";
|
||||
|
||||
import { FormDebug } from '@erp/core/components';
|
||||
import { cn } from '@repo/shadcn-ui/lib/utils';
|
||||
import { InvoiceBasicInfoFields, InvoiceItems, InvoiceRecipient, InvoiceTotals } from '../../components';
|
||||
import { InvoiceFormData } from "../../schemas";
|
||||
import { InvoiceBasicInfoFields } from "./invoice-basic-info-fields";
|
||||
import { InvoiceItems } from './invoice-items-editor';
|
||||
import { InvoiceTotals } from './invoice-totals';
|
||||
import { InvoiceRecipient } from "./recipient";
|
||||
|
||||
interface CustomerInvoiceFormProps {
|
||||
interface InvoiceUpdateFormProps {
|
||||
formId: string;
|
||||
onSubmit: (data: InvoiceFormData) => void;
|
||||
onError: (errors: FieldErrors<InvoiceFormData>) => void;
|
||||
className: string;
|
||||
}
|
||||
|
||||
export const InvoiceEditForm = ({
|
||||
export const InvoiceUpdateForm = ({
|
||||
formId,
|
||||
onSubmit,
|
||||
onError,
|
||||
className,
|
||||
}: CustomerInvoiceFormProps) => {
|
||||
}: InvoiceUpdateFormProps) => {
|
||||
const form = useFormContext<InvoiceFormData>();
|
||||
|
||||
return (
|
||||
@ -20,6 +20,7 @@ export const invoiceDtoToFormAdapter = {
|
||||
operation_date: dto.operation_date,
|
||||
|
||||
customer_id: dto.customer_id,
|
||||
recipient: dto.recipient,
|
||||
|
||||
reference: dto.reference ?? "",
|
||||
description: dto.description ?? "",
|
||||
|
||||
@ -74,33 +74,33 @@ export const CustomerCard = ({
|
||||
)}
|
||||
</ItemDescription>
|
||||
</ItemContent>
|
||||
<ItemFooter>
|
||||
<div className='flex flex-wrap gap-2'>
|
||||
<Button
|
||||
type="button"
|
||||
variant='outline'
|
||||
size='sm'
|
||||
onClick={onChangeCustomer}
|
||||
className='flex-1 min-w-36 gap-2 cursor-pointer'
|
||||
>
|
||||
<RefreshCwIcon className='size-4' />
|
||||
<span className='text-sm text-muted-foreground'>
|
||||
Cambiar de cliente
|
||||
</span>
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
variant='outline'
|
||||
size='sm'
|
||||
onClick={onAddNewCustomer}
|
||||
className='flex-1 min-w-36 gap-2 cursor-pointer'
|
||||
>
|
||||
<UserPlusIcon className='size-4' />
|
||||
<span className='text-sm text-muted-foreground'>
|
||||
Nuevo cliente
|
||||
</span>
|
||||
</Button>
|
||||
</div>
|
||||
<ItemFooter className='flex-wrap'>
|
||||
|
||||
<Button
|
||||
type="button"
|
||||
variant='outline'
|
||||
size='sm'
|
||||
onClick={onChangeCustomer}
|
||||
className='flex-1 min-w-36 gap-2 cursor-pointer'
|
||||
>
|
||||
<RefreshCwIcon className='size-4' />
|
||||
<span className='text-sm text-muted-foreground'>
|
||||
Cambiar de cliente
|
||||
</span>
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
variant='outline'
|
||||
size='sm'
|
||||
onClick={onAddNewCustomer}
|
||||
className='flex-1 min-w-36 gap-2 cursor-pointer'
|
||||
>
|
||||
<UserPlusIcon className='size-4' />
|
||||
<span className='text-sm text-muted-foreground'>
|
||||
Nuevo cliente
|
||||
</span>
|
||||
</Button>
|
||||
|
||||
</ItemFooter>
|
||||
</Item>
|
||||
);
|
||||
|
||||
@ -33,7 +33,7 @@ export const CustomerModalSelector = ({
|
||||
readOnly = false,
|
||||
className,
|
||||
}: CustomerModalSelectorProps) => {
|
||||
// UI state
|
||||
|
||||
const [showSearch, setShowSearch] = useState(false);
|
||||
const [showForm, setShowForm] = useState(false);
|
||||
const [searchQuery, setSearchQuery] = useState("");
|
||||
@ -82,6 +82,8 @@ export const CustomerModalSelector = ({
|
||||
setShowSearch(false);
|
||||
};
|
||||
|
||||
console.log(selected);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user