import axios from "axios"; import { useState } from "react"; import { Controller, useForm } from "react-hook-form"; import { toast } from "sonner"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { LstCard } from "@/components/ui/lstCard"; //import CycleCountLog from "./CycleCountLog"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { Skeleton } from "@/components/ui/skeleton"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; export default function OcmeCycleCount() { const token = localStorage.getItem("auth_token"); const [data, setData] = useState([]); const [counting, setCounting] = useState(false); const { register, handleSubmit, //watch, formState: { errors }, reset, control, } = useForm({ defaultValues: { lane: "", laneType: "name", }, }); const onSubmit = async (data: any) => { setData([]); setCounting(true); if (data.laneType === "") { toast.error("Please select a type"); setCounting(false); return; } toast.success(`Cycle count started`); try { const res = await axios.post("/lst/old/ocme/api/v1/cycleCount", data, { headers: { Authorization: `Bearer ${token}` }, }); if (res.data.success) { toast.success(res.data.message); setData(res.data.data); setCounting(false); reset(); } if (!res.data.success) { toast.success(res.data.message); setCounting(false); } } catch (error) { toast.error("There was an error cycle counting"); setCounting(false); reset(); } }; return (
Please enter the name or laneID you want to cycle count.