import { useForm } from "@tanstack/react-form"; import { Input } from "../ui/input"; import { Label } from "../ui/label"; import axios from "axios"; import { toast } from "sonner"; import { Button } from "../ui/button"; import { useState } from "react"; export default function ManuallyEnterRn() { const [sending, setSendingRn] = useState(false); const form = useForm({ defaultValues: { runningNr: "", }, onSubmit: async ({ value }) => { console.log(value); setSendingRn(true); try { const res = await axios.post("/ocme/api/v1/postRunningNumber", { runningNr: value.runningNr, areaFrom: "wrapper_1", completed: true, }); if (res.data.success) { form.reset(); toast.success( `${value.runningNr} was just created please login` ); setTimeout(() => { setSendingRn(false); }, 3 * 1000); } if (!res.data.success) { toast.error(res.data.message); setTimeout(() => { setSendingRn(false); }, 3 * 1000); } } catch (error) { //console.log(error); toast.error("There was an error registering"); setTimeout(() => { setSendingRn(false); }, 3 * 1000); } }, }); return (