diff --git a/components/comp/AlertBatch.tsx b/components/comp/AlertBatch.tsx deleted file mode 100644 index cb9d356..0000000 --- a/components/comp/AlertBatch.tsx +++ /dev/null @@ -1,168 +0,0 @@ -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 -
-
-
-
-
-
- - ); -}; diff --git a/components/comp/AlertCeoApprove.tsx b/components/comp/AlertCeoApprove.tsx deleted file mode 100644 index d16a858..0000000 --- a/components/comp/AlertCeoApprove.tsx +++ /dev/null @@ -1,133 +0,0 @@ -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 api from "@/lib/utils/axios"; -import { get_user } from "@/lib/utils/get_user"; -import { toast } from "sonner"; -import { AlertTriangle, Check, Loader2 } from "lucide-react"; -import get from "lodash.get"; -export const AlertCeoApprove: FC = ({ fm }) => { - return ( - <> - - -
- Approve -
-
- - - Approve - - Are You Sure to Approve This Batch? - - - - - -
- No -
-
-
- - { - toast.info( - <> - - {"Saving..."} - - ); - try { - const batch = await api.get( - `${process.env.NEXT_PUBLIC_API_MPP}/api/batch/find-by-status/NEED APPROVAL` - ); - const id = batch?.data?.data?.id; - const param = { - id, - status: "APPROVED", - approved_by: get_user("employee.id"), - approver_name: get_user("employee.name"), - }; - - const res = await api.put( - `${process.env.NEXT_PUBLIC_API_MPP}/api/batch/update-status`, - param - ); - - fm.data = null; - fm.render(); - setTimeout(() => { - 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 -
-
-
-
-
-
- - ); -}; diff --git a/components/comp/AlertCeoApproveMPR.tsx b/components/comp/AlertCeoApproveMPR.tsx deleted file mode 100644 index 30abcfb..0000000 --- a/components/comp/AlertCeoApproveMPR.tsx +++ /dev/null @@ -1,139 +0,0 @@ -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 api from "@/lib/utils/axios"; -import { get_user } from "@/lib/utils/get_user"; -import { toast } from "sonner"; -import { AlertTriangle, Check, Loader2 } from "lucide-react"; -import { getParams } from "@/lib/utils/get-params"; -import get from "lodash.get"; -export const AlertCeoApproveMPR: FC = ({fm}) => { - const id = getParams("id"); - return ( - <> - - -
- Approve -
-
- - - Approve - - Are You Sure to Approve This? - - - - - -
- No -
-
-
- - { - toast.info( - <> - - {"Saving..."} - - ); - try { - - const param = { - id, - status: "APPROVED", - level: "Level CEO", - approver_id: get_user("employee.id"), - approved_by: get_user("employee.name"), - }; - - 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(() => { - fm.data.is_approve = false; - fm.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 -
-
-
-
-
-
- - ); -}; diff --git a/components/comp/AlertCeoReject.tsx b/components/comp/AlertCeoReject.tsx deleted file mode 100644 index 99796d0..0000000 --- a/components/comp/AlertCeoReject.tsx +++ /dev/null @@ -1,317 +0,0 @@ -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 { events } from "@/lib/utils/event"; -import get from "lodash.get"; -export const AlertCeoReject: FC = ({ lc }) => { - const local = useLocal({ - organization: [] as any[], - reject: "reject-all" as any, - fm: null as any, - org: [] as string[] - }); - useEffect(() => { - const run = async () => { - const batch: any = await api.get( - `${process.env.NEXT_PUBLIC_API_MPP}/api/batch/find-by-status/NEED APPROVAL` - ); - const btc = batch?.data?.data; - const addtional = { - status: "APPROVED", - paging: 1, - take: 500, - }; - const params = await events("onload-param", addtional); - const res: any = await api.get( - `${process.env.NEXT_PUBLIC_API_MPP}/api/batch/organizations/${btc?.id}` + - params - ); - const data: any[] = res.data.data; - const result = data?.length - ? data.map((e) => { - return { id: e.id, label: e.name }; - }) - : []; - local.organization = result; - local.render(); - }; - run(); - }, []); - const items = [ - { - id: "reject-all", - label: "Reject All", - }, - { - id: "reject-partially", - label: "Reject Partially", - }, - ] as const; - - return ( - <> - - -
- Reject -
-
- - - Reject - - -
-
- {items.map((item) => ( -
- { - local.reject = item.id; - local.render(); - }} - /> - -
- ))} -
- - {local?.reject === "reject-partially" && - local?.organization?.length && ( - <> -
{}} - onLoad={async () => { - return { - organization: [], - }; - }} - showResize={false} - header={(fm: any) => { - return <>; - }} - onInit={(fm: any) => { - local.fm = fm; - local.render(); - }} - children={(fm: any) => { - return ( -
- {local.organization.map((item) => { - const is_check = fm.data?.organization?.length - ? fm.data.organization.find( - (org: any) => org?.id === item.id - ) - : false; - const data = fm.data?.organization?.length - ? fm.data.organization.find( - (org: any) => org?.id === item.id - ) - : {}; - return ( -
-
- { - if (e) { - if ( - !Array.isArray(fm.data?.organization) - ) { - fm.data["organization"] = []; - fm.render(); - } - // Jika checkbox dicentang, tambahkan item ke array organization - fm.data.organization.push({ - id: item.id, - }); - } else { - // Jika checkbox tidak dicentang, hapus item dari array organization - fm.data["organization"] = fm.data - ?.organization?.length - ? fm.data.organization.filter( - (org: any) => org?.id !== item.id - ) - : []; - } - fm.render(); - local.org = fm.data?.organization?.length ? fm.data.organization.map((e: any) => { - return { - id: e.id - } - }) : []; - local.render(); - }} - /> - -
- {is_check ? ( -
- -
- ) : ( - <> - )} -
- ); - })} -
- ); - }} - /> - - )} -
- - - -
- No -
-
-
- { - toast.info( - <> - - {"Saving..."} - - ); - try { - const isPartial = local.reject === "reject-partially"; - if (isPartial) { - const partial = local?.org || []; - const res = await api.put( - `${process.env.NEXT_PUBLIC_API_MPP}/api/mp-plannings/lines/reject-partial-pt`, - { approver_id: get_user("employee.id"), payload: partial } - ); - } else { - const batch = await api.get( - `${process.env.NEXT_PUBLIC_API_MPP}/api/batch/find-by-status/NEED APPROVAL` - ); - const id = batch?.data?.data?.id; - const param = { - id, - status: "REJECTED", - approved_by: get_user("employee.id"), - approver_name: get_user("employee.name"), - }; - - const res = await api.put( - `${process.env.NEXT_PUBLIC_API_MPP}/api/batch/update-status`, - param - ); - } - lc.data = null; - lc.render() - - setTimeout(() => { - 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 -
-
-
-
-
-
- - ); -}; diff --git a/components/comp/AlertCeoRejectMPR.tsx b/components/comp/AlertCeoRejectMPR.tsx deleted file mode 100644 index 8d2f4bb..0000000 --- a/components/comp/AlertCeoRejectMPR.tsx +++ /dev/null @@ -1,203 +0,0 @@ -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 -
-
-
- )} -
- ); - }} - /> -
-
-
- - ); -}; diff --git a/components/partials/Sidebar.tsx b/components/partials/Sidebar.tsx index 3a01778..78389ea 100644 --- a/components/partials/Sidebar.tsx +++ b/components/partials/Sidebar.tsx @@ -1,18 +1,13 @@ "use client"; import React, { FC } from "react"; -import Link from "next/link"; -import { Dropdown, Sidebar, TextInput, Tooltip } from "flowbite-react"; +import { Dropdown, Sidebar, Tooltip } from "flowbite-react"; import { useEffect, useState } from "react"; -import { useSidebarContext } from "@/context/SidebarContext"; import classNames from "classnames"; -import { HiAdjustments, HiChartPie, HiCog } from "react-icons/hi"; -import isSmallScreen from "@/lib/helpers/is-small-screen"; +import { HiAdjustments, HiCog } from "react-icons/hi"; import { css } from "@emotion/css"; import { FaAngleUp, FaChevronDown, FaChevronUp } from "react-icons/fa"; -import { Minimize } from "lucide-react"; import { SidebarLinkBetter } from "../ui/link-better"; import { detectCase } from "@/lib/utils/detectCase"; -import { Skeleton } from "../ui/Skeleton"; import { useLocal } from "@/lib/utils/use-local"; interface TreeMenuItem { title: string; diff --git a/components/ui/Pagination.tsx b/components/ui/Pagination.tsx new file mode 100644 index 0000000..7e47d91 --- /dev/null +++ b/components/ui/Pagination.tsx @@ -0,0 +1,116 @@ +import * as React from "react" +import { ChevronLeft, ChevronRight, MoreHorizontal } from "lucide-react" +import { cn } from "@/lib/utils/utils" +import { ButtonProps, buttonVariants } from "./button" + +const Pagination = ({ className, ...props }: React.ComponentProps<"nav">) => ( +