import { BackHistoryButton, FormDatePickerField, FormTextAreaField, FormTextField, } from "@/components"; import { t } from "i18next"; import { ChevronLeft } from "lucide-react"; import { SubmitButton } from "@/components"; import { Button, Form } from "@/ui"; import { FieldErrors, SubmitErrorHandler, SubmitHandler, useForm } from "react-hook-form"; import { useNavigate } from "react-router-dom"; import { useQuotes } from "./hooks"; type QuoteDataForm = { id: string; status: string; date: string; reference: string; customer_information: string; lang_code: string; currency_code: string; payment_method: string; notes: string; validity: string; items: any[]; }; /*type QuoteCreateProps = { isOverModal?: boolean; };*/ export const QuoteCreate = () => { //const [loading, setLoading] = useState(false); //const { data: userIdentity } = useGetIdentity(); //console.log(userIdentity); const navigate = useNavigate(); const { useMutation } = useQuotes(); const { mutate } = useMutation(); const form = useForm({ defaultValues: { date: new Date(Date.now()).toUTCString(), customer_information: "", reference: "", }, }); const onSubmit: SubmitHandler = async (formData) => { alert(JSON.stringify(formData)); try { //setLoading(true); mutate(formData, { onSuccess: (data) => { navigate(`/quotes/edit/${data.id}`, { relative: "path", replace: true }); }, }); } finally { //setLoading(false); } }; const onErrors: SubmitErrorHandler = async ( errors: FieldErrors ) => { console.log(errors); }; return (

{t("quotes.create.title")}

); };