Clientes
This commit is contained in:
parent
5acf018a22
commit
d8f7c70e7e
@ -2,7 +2,7 @@ import { Description, FieldGroup, Fieldset, Legend } from "@repo/rdx-ui/componen
|
|||||||
import { FieldErrors, useFormContext } from "react-hook-form";
|
import { FieldErrors, useFormContext } from "react-hook-form";
|
||||||
|
|
||||||
import { FormDebug } from "@erp/core/components";
|
import { FormDebug } from "@erp/core/components";
|
||||||
import { CustomerModalSelector } from "@erp/customers/components";
|
import { CustomerModalSelectorField } from "@erp/customers/components";
|
||||||
import { UserIcon } from "lucide-react";
|
import { UserIcon } from "lucide-react";
|
||||||
import { useTranslation } from "../../i18n";
|
import { useTranslation } from "../../i18n";
|
||||||
import { CustomerInvoiceFormData } from "../../schemas";
|
import { CustomerInvoiceFormData } from "../../schemas";
|
||||||
@ -42,7 +42,7 @@ export const CustomerInvoiceEditForm = ({
|
|||||||
</Legend>
|
</Legend>
|
||||||
<Description>{t("form_groups.customer.description")}</Description>
|
<Description>{t("form_groups.customer.description")}</Description>
|
||||||
<FieldGroup>
|
<FieldGroup>
|
||||||
<CustomerModalSelector />
|
<CustomerModalSelectorField control={form.control} name='customer_id' />
|
||||||
</FieldGroup>
|
</FieldGroup>
|
||||||
</Fieldset>
|
</Fieldset>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import { CustomerInvoiceFormData } from "../../schemas";
|
|||||||
import { BlocksView, TableView } from "./items";
|
import { BlocksView, TableView } from "./items";
|
||||||
|
|
||||||
export const InvoiceItems = () => {
|
export const InvoiceItems = () => {
|
||||||
const [viewMode, setViewMode] = useState<"blocks" | "table">("blocks");
|
const [viewMode, setViewMode] = useState<"blocks" | "table">("table");
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { control } = useFormContext<CustomerInvoiceFormData>();
|
const { control } = useFormContext<CustomerInvoiceFormData>();
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ export const InvoiceItems = () => {
|
|||||||
<div className='flex items-center gap-2'>
|
<div className='flex items-center gap-2'>
|
||||||
<div className='flex items-center border rounded-lg p-1'>
|
<div className='flex items-center border rounded-lg p-1'>
|
||||||
<Button
|
<Button
|
||||||
variant={viewMode === "blocks" ? "default" : "ghost"}
|
variant={viewMode === "blocks" ? "secondary" : "ghost"}
|
||||||
size='sm'
|
size='sm'
|
||||||
onClick={() => setViewMode("blocks")}
|
onClick={() => setViewMode("blocks")}
|
||||||
className='h-8 px-3'
|
className='h-8 px-3'
|
||||||
@ -95,7 +95,7 @@ export const InvoiceItems = () => {
|
|||||||
Bloques
|
Bloques
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant={viewMode === "table" ? "default" : "ghost"}
|
variant={viewMode === "table" ? "secondary" : "ghost"}
|
||||||
size='sm'
|
size='sm'
|
||||||
onClick={() => setViewMode("table")}
|
onClick={() => setViewMode("table")}
|
||||||
className='h-8 px-3'
|
className='h-8 px-3'
|
||||||
|
|||||||
@ -11,6 +11,7 @@ export const CustomerInvoiceFormSchema = z.object({
|
|||||||
|
|
||||||
customer_id: z.string().optional(),
|
customer_id: z.string().optional(),
|
||||||
|
|
||||||
|
description: z.string().optional(),
|
||||||
notes: z.string().optional(),
|
notes: z.string().optional(),
|
||||||
|
|
||||||
language_code: z
|
language_code: z
|
||||||
@ -77,6 +78,7 @@ export const defaultCustomerInvoiceFormData: CustomerInvoiceFormData = {
|
|||||||
invoice_date: "",
|
invoice_date: "",
|
||||||
operation_date: "",
|
operation_date: "",
|
||||||
|
|
||||||
|
description: "",
|
||||||
notes: "",
|
notes: "",
|
||||||
|
|
||||||
language_code: "es",
|
language_code: "es",
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
import { ArrayElement } from "@repo/rdx-utils";
|
import { Building2Icon, FileTextIcon, Mail, Phone, User } from "lucide-react";
|
||||||
import { Building2Icon, FileTextIcon, Mail, Phone, Search, User } from "lucide-react";
|
import { CustomerSummary } from "../../schemas";
|
||||||
import { CustomersListData } from "../../schemas";
|
|
||||||
|
|
||||||
interface CustomerCardProps {
|
interface CustomerCardProps {
|
||||||
customer: ArrayElement<CustomersListData["items"]>;
|
customer: CustomerSummary;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CustomerCard = ({ customer }: CustomerCardProps) => {
|
export const CustomerCard = ({ customer }: CustomerCardProps) => {
|
||||||
@ -13,15 +12,15 @@ export const CustomerCard = ({ customer }: CustomerCardProps) => {
|
|||||||
<User className='h-6 w-6 text-primary' />
|
<User className='h-6 w-6 text-primary' />
|
||||||
</div>
|
</div>
|
||||||
<div className='flex-1 space-y-2'>
|
<div className='flex-1 space-y-2'>
|
||||||
<div className='flex items-center justify-between'>
|
<p className='text-left font-semibold text-foreground text-base'>{customer.name}</p>
|
||||||
<h3 className='font-semibold text-foreground text-lg'>{customer.name}</h3>
|
|
||||||
<Search className='size-4 text-muted-foreground' />
|
|
||||||
</div>
|
|
||||||
<div className='space-y-1 text-sm text-muted-foreground'>
|
<div className='space-y-1 text-sm text-muted-foreground'>
|
||||||
<div className='flex items-center gap-2'>
|
{customer.email_primary && (
|
||||||
<Mail className='h-3 w-3' />
|
<div className='flex items-center gap-2'>
|
||||||
{customer.email_primary}
|
<Mail className='h-3 w-3' />
|
||||||
</div>
|
{customer.email_primary}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{customer.mobile_primary && (
|
{customer.mobile_primary && (
|
||||||
<div className='flex items-center gap-2'>
|
<div className='flex items-center gap-2'>
|
||||||
<Phone className='h-3 w-3' />
|
<Phone className='h-3 w-3' />
|
||||||
|
|||||||
@ -0,0 +1,40 @@
|
|||||||
|
import { FormField, FormItem } from "@repo/shadcn-ui/components";
|
||||||
|
|
||||||
|
import { Control, FieldPath, FieldValues } from "react-hook-form";
|
||||||
|
import { CustomerModalSelector } from "./customer-modal-selector";
|
||||||
|
|
||||||
|
type CustomerModalSelectorFieldProps<TFormValues extends FieldValues> = {
|
||||||
|
control: Control<TFormValues>;
|
||||||
|
name: FieldPath<TFormValues>;
|
||||||
|
disabled?: boolean;
|
||||||
|
required?: boolean;
|
||||||
|
readOnly?: boolean;
|
||||||
|
className?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function CustomerModalSelectorField<TFormValues extends FieldValues>({
|
||||||
|
control,
|
||||||
|
name,
|
||||||
|
disabled = false,
|
||||||
|
required = false,
|
||||||
|
readOnly = false,
|
||||||
|
className,
|
||||||
|
}: CustomerModalSelectorFieldProps<TFormValues>) {
|
||||||
|
const isDisabled = disabled;
|
||||||
|
const isReadOnly = readOnly && !disabled;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<FormField
|
||||||
|
control={control}
|
||||||
|
name={name}
|
||||||
|
render={({ field }) => {
|
||||||
|
console.log(field);
|
||||||
|
return (
|
||||||
|
<FormItem className={className}>
|
||||||
|
<CustomerModalSelector />
|
||||||
|
</FormItem>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -1 +1,2 @@
|
|||||||
export * from "./customer-modal-selector";
|
export * from "./customer-modal-selector";
|
||||||
|
export * from "./customer-modal-selector-field";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user