import { LstCard } from "@/components/extendedUI/LstCard"; import { Button } from "@/components/ui/button"; import { CardContent, CardFooter, CardHeader } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { useForm } from "@tanstack/react-form"; import axios from "axios"; import { useState } from "react"; import { toast } from "sonner"; export default function Bookin() { const [bookingIn, setBookingIn] = useState(false); const form = useForm({ defaultValues: { runningNr: " " }, onSubmit: async ({ value }) => { // Do something with form data setBookingIn(true); try { const res = await axios.post("/api/ocp/bookin", { runningNr: parseInt(value.runningNr), }); if (res.data.success) { toast.success(res.data.message); form.reset(); setBookingIn(false); } else { console.log(res.data.data.errors); toast.error(res.data.data.errors[0]?.message); form.reset(); setBookingIn(false); } } catch (error) { console.log(error); toast.error( "There was an error booking in pallet please validate you entered the correct info and try again." ); setBookingIn(false); } }, }); return (

Book in a pallet by running number

{ e.preventDefault(); e.stopPropagation(); }} > value.length > 2 ? undefined : "Please enter a valid running number", }} children={(field) => { return (
field.handleChange(e.target.value) } /> {field.state.meta.errors.length ? ( {field.state.meta.errors.join(",")} ) : null}
); }} />
); }