Clientes
This commit is contained in:
parent
b7396881b3
commit
580beaba4c
@ -15,10 +15,15 @@ export const CreateCustomerRequestSchema = z.object({
|
|||||||
city: z.string().default(""),
|
city: z.string().default(""),
|
||||||
province: z.string().default(""),
|
province: z.string().default(""),
|
||||||
postal_code: z.string().default(""),
|
postal_code: z.string().default(""),
|
||||||
country: z.string().default(""),
|
country: z.string().default("es"),
|
||||||
|
|
||||||
|
email_primary: z.string().default(""),
|
||||||
|
email_secondary: z.string().default(""),
|
||||||
|
phone_primary: z.string().default(""),
|
||||||
|
phone_secondary: z.string().default(""),
|
||||||
|
mobile_primary: z.string().default(""),
|
||||||
|
mobile_secondary: z.string().default(""),
|
||||||
|
|
||||||
email: z.string().default(""),
|
|
||||||
phone: z.string().default(""),
|
|
||||||
fax: z.string().default(""),
|
fax: z.string().default(""),
|
||||||
website: z.string().default(""),
|
website: z.string().default(""),
|
||||||
|
|
||||||
|
|||||||
@ -19,8 +19,13 @@ export const UpdateCustomerByIdRequestSchema = z.object({
|
|||||||
postal_code: z.string().optional(),
|
postal_code: z.string().optional(),
|
||||||
country: z.string().optional(),
|
country: z.string().optional(),
|
||||||
|
|
||||||
email: z.string().optional(),
|
email_primary: z.string().optional(),
|
||||||
phone: z.string().optional(),
|
email_secondary: z.string().optional(),
|
||||||
|
phone_primary: z.string().optional(),
|
||||||
|
phone_secondary: z.string().optional(),
|
||||||
|
mobile_primary: z.string().optional(),
|
||||||
|
mobile_secondary: z.string().optional(),
|
||||||
|
|
||||||
fax: z.string().optional(),
|
fax: z.string().optional(),
|
||||||
website: z.string().optional(),
|
website: z.string().optional(),
|
||||||
|
|
||||||
|
|||||||
@ -7,13 +7,15 @@ import {
|
|||||||
CardHeader,
|
CardHeader,
|
||||||
CardTitle,
|
CardTitle,
|
||||||
} from "@repo/shadcn-ui/components";
|
} from "@repo/shadcn-ui/components";
|
||||||
import { useForm } from "react-hook-form";
|
import { Control } from "react-hook-form";
|
||||||
import { CURRENCY_OPTIONS, LANGUAGE_OPTIONS } from "../../constants";
|
import { CURRENCY_OPTIONS, LANGUAGE_OPTIONS } from "../../constants";
|
||||||
import { useTranslation } from "../../i18n";
|
import { useTranslation } from "../../i18n";
|
||||||
|
import { CustomerUpdateData } from "../../schemas";
|
||||||
|
|
||||||
export const CustomerAdditionalConfigFields = () => {
|
export const CustomerAdditionalConfigFields = ({
|
||||||
|
control,
|
||||||
|
}: { control: Control<CustomerUpdateData> }) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { control } = useForm();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className='border-0 shadow-none'>
|
<Card className='border-0 shadow-none'>
|
||||||
|
|||||||
@ -6,10 +6,12 @@ import {
|
|||||||
CardHeader,
|
CardHeader,
|
||||||
CardTitle,
|
CardTitle,
|
||||||
} from "@repo/shadcn-ui/components";
|
} from "@repo/shadcn-ui/components";
|
||||||
|
import { Control } from "react-hook-form";
|
||||||
import { COUNTRY_OPTIONS } from "../../constants";
|
import { COUNTRY_OPTIONS } from "../../constants";
|
||||||
import { useTranslation } from "../../i18n";
|
import { useTranslation } from "../../i18n";
|
||||||
|
import { CustomerUpdateData } from "../../schemas";
|
||||||
|
|
||||||
export function CustomerAddressFields({ control }: { control: any }) {
|
export const CustomerAddressFields = ({ control }: { control: Control<CustomerUpdateData> }) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -75,4 +77,4 @@ export function CustomerAddressFields({ control }: { control: any }) {
|
|||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|||||||
@ -14,9 +14,11 @@ import {
|
|||||||
RadioGroup,
|
RadioGroup,
|
||||||
RadioGroupItem,
|
RadioGroupItem,
|
||||||
} from "@repo/shadcn-ui/components";
|
} from "@repo/shadcn-ui/components";
|
||||||
|
import { Control } from "react-hook-form";
|
||||||
import { useTranslation } from "../../i18n";
|
import { useTranslation } from "../../i18n";
|
||||||
|
import { CustomerUpdateData } from "../../schemas";
|
||||||
|
|
||||||
export const CustomerBasicInfoFields = ({ control }: { control: any }) => {
|
export const CustomerBasicInfoFields = ({ control }: { control: Control<CustomerUpdateData> }) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -12,9 +12,11 @@ import {
|
|||||||
import { TextField } from "@repo/rdx-ui/components";
|
import { TextField } from "@repo/rdx-ui/components";
|
||||||
import { ChevronDown, MailIcon, PhoneIcon, SmartphoneIcon } from "lucide-react";
|
import { ChevronDown, MailIcon, PhoneIcon, SmartphoneIcon } from "lucide-react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { Control } from "react-hook-form";
|
||||||
import { useTranslation } from "../../i18n";
|
import { useTranslation } from "../../i18n";
|
||||||
|
import { CustomerUpdateData } from "../../schemas";
|
||||||
|
|
||||||
export function CustomerContactFields({ control }: { control: any }) {
|
export const CustomerContactFields = ({ control }: { control: Control<CustomerUpdateData> }) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [open, setOpen] = useState(true);
|
const [open, setOpen] = useState(true);
|
||||||
|
|
||||||
@ -137,4 +139,4 @@ export function CustomerContactFields({ control }: { control: any }) {
|
|||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|||||||
@ -1,12 +1,3 @@
|
|||||||
import {
|
|
||||||
Card,
|
|
||||||
CardContent,
|
|
||||||
CardDescription,
|
|
||||||
CardFooter,
|
|
||||||
CardHeader,
|
|
||||||
CardTitle,
|
|
||||||
} from "@repo/shadcn-ui/components";
|
|
||||||
|
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { FieldErrors, useForm } from "react-hook-form";
|
import { FieldErrors, useForm } from "react-hook-form";
|
||||||
|
|
||||||
@ -86,45 +77,4 @@ export const CustomerEditForm = ({ defaultValues, onSubmit, isPending }: Custome
|
|||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
|
||||||
<Form {...form}>
|
|
||||||
<FormDebug form={form} />
|
|
||||||
<form id={formId} onSubmit={form.handleSubmit(handleSubmit, handleError)}>
|
|
||||||
<div className='grid grid-cols-3 gap-12'>
|
|
||||||
<div className='col-span-2'>
|
|
||||||
<Card className='border-0 shadow-none bg-background'>
|
|
||||||
<CardHeader className='px-0'>
|
|
||||||
<CardTitle>{t("form_groups.basic_info.title")}</CardTitle>
|
|
||||||
<CardDescription>{t("form_groups.basic_info.description")}</CardDescription>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent className='px-0'>
|
|
||||||
<CustomerBasicInfoFields />
|
|
||||||
</CardContent>
|
|
||||||
<CardFooter>
|
|
||||||
<p> </p>
|
|
||||||
</CardFooter>
|
|
||||||
</Card>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<CustomerAdditionalConfigFields />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</Form>
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Form {...form}>
|
|
||||||
<FormDebug form={form} />
|
|
||||||
<form id={formId} onSubmit={form.handleSubmit(handleSubmit, handleError)}>
|
|
||||||
<div className='w-full grid grid-cols-1 space-y-8 space-x-8 xl:grid-cols-2'>
|
|
||||||
<CustomerBasicInfoFields control={form.control} />
|
|
||||||
<CustomerAddressFields control={form.control} />
|
|
||||||
<CustomerContactFields control={form.control} />
|
|
||||||
<CustomerAdditionalConfigFields control={form.control} />
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</Form>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user