import { LstCard } from "@/components/extendedUI/LstCard"; import { Button } from "@/components/ui/button"; import { CardHeader } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import axios from "axios"; import { useState } from "react"; import { useForm } from "react-hook-form"; import { toast } from "sonner"; export default function ConsumeMaterial() { const { register: register1, handleSubmit: handleSubmit1, reset, } = useForm(); const [submitting, setSubmitting] = useState(false); const handleConsume = async (data: any) => { setSubmitting(true); try { // const result = await axios.post(`/api/logistics/consume`, data, { // headers: {Authorization: `Bearer ${token}`}, // }); const result = await axios.post(`/api/logistics/consume`, data); if (result.data.success) { toast.success(result.data.message); setSubmitting(false); reset(); } if (!result.data.success) { //console.log(result.data); setSubmitting(false); toast.error(result.data.message); } } catch (error: any) { console.log(error); setSubmitting(false); if (error.status === 401) { toast.error("Unauthorized to do this task."); } else { toast.error( "Unexpected error if this continues please constact an admin." ); } } }; return (
Consuming Material.
*This process is only for barcoded material, if it is set to auto consume you will encounter and error.