import { FC, useEffect } 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 { Checkbox } from "@/lib/components/ui/checkbox"; import { IoEye } from "react-icons/io5"; import { HiPlus } from "react-icons/hi"; import { useLocal } from "@/lib/utils/use-local"; import api from "@/lib/utils/axios"; import { Form } from "../form/Form"; import { Field } from "../form/Field"; import { cloneFM } from "@/lib/utils/cloneFm"; import { toast } from "sonner"; import { AlertTriangle, Check, Loader2 } from "lucide-react"; import { get_user } from "@/lib/utils/get_user"; import { getParams } from "@/lib/utils/get-params"; import { Button } from "flowbite-react"; import get from "lodash.get"; export const AlertCeoRejectMPR: FC = ({ lc }) => { const id = getParams("id"); const local = useLocal({ organization: [] as any[], reject: "reject-all" as any, }); useEffect(() => {}, []); const items = [ { id: "reject-all", label: "Reject All", }, { id: "reject-partially", label: "Reject Partially", }, ] as const; return ( <>
Reject
Reject Are You Sure to Reject This?
{}} onLoad={async () => { return { organization: [], }; }} showResize={false} header={(fm: any) => { return <>; }} children={(fm: any) => { return (
); }} onFooter={(fm: any) => { return (
No
{!fm.data?.notes ? ( { fm.error["notes"] = "Field is required" fm.render(); }}>Yes ) : ( { fm.error = {}; fm.render(); toast.info( <> {"Saving..."} ); try { const param = { id, status: "REJECTED", level: "Level CEO", approver_id: get_user("employee.id"), approved_by: get_user("employee.name"), notes: fm.data?.notes }; const formData = new FormData(); formData.append("payload", JSON.stringify(param)); const res = await api.put( `${process.env.NEXT_PUBLIC_API_MPP}/api/mp-requests/status`, formData, { headers: { "Content-Type": "multipart/form-data", }, } ); setTimeout(() => { lc.data.is_approve = false; lc.render(); toast.success(
{ toast.dismiss(); }} >
Record Saved
); }, 1000); } catch (ex: any) { toast.error(
Submit Failed { get(ex, "response.data.meta.message") || ex.message}.
, { dismissible: true, className: css` background: #ffecec; border: 2px solid red; `, } ); } }} >
Yes
)}
); }} />
); };