import { FC } from "react"; import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "@/lib/components/ui/dialog"; import { ButtonBetter, ButtonContainer } from "@/lib/components/ui/button"; import { IoEye } from "react-icons/io5"; import { HiPlus } from "react-icons/hi"; import { formatMoney } from "../form/field/TypeInput"; import { get_user } from "@/lib/utils/get_user"; import api from "@/lib/utils/axios"; import { toast } from "sonner"; import { AlertTriangle, Check, Loader2 } from "lucide-react"; import { getNumber } from "@/lib/utils/getNumber"; import { events } from "@/lib/utils/event"; import get from "lodash.get"; export const AlertBatch: FC = ({ local }) => { // const fm = useLocal({ // // open: // }) return ( <>
Create Batch
Create Batch
Are you sure to continue this action? {local?.location_null ? ` There are ${formatMoney( local?.location_null )} locations NULL` : ``}
No
{ try { toast.info( <> {"Saving..."} ); if (local.batch_lines?.length) { const data = { approver_id: get_user("employee.id"), approver_name: get_user("employee.name"), batch_lines: local.batch_lines?.length ? local.batch_lines.map((e: any) => { return { mp_planning_header_id: e, }; }) : [], }; await api.post( `${process.env.NEXT_PUBLIC_API_MPP}/api/batch/create`, data ); local.can_add = false; local.render(); try { const batch: any = await api.get( `${process.env.NEXT_PUBLIC_API_MPP}/api/batch/find-by-status/NEED APPROVAL` ); local.batch = batch?.data?.data; } catch (ex) {} try { const batch_ceo: any = await api.get( `${process.env.NEXT_PUBLIC_API_MPP}/api/batch/find-by-status/APPROVED` ); local.batch = batch_ceo?.data?.data; } catch (ex) {} local.render(); } setTimeout(() => { toast.success(
{ toast.dismiss(); }} >
Record Saved
); }, 1000); } catch (ex: any) { toast.error(
Create Batch Failed { get(ex, "response.data.meta.message") || ex.message}.
, { dismissible: true, className: css` background: #ffecec; border: 2px solid red; `, } ); } }} >
Yes
); };