From 3051e931ca134b9121ac557a373b3f76db4a6a00 Mon Sep 17 00:00:00 2001 From: rstubryan Date: Thu, 9 Oct 2025 09:12:07 +0700 Subject: [PATCH 1/6] fix: enhance MainDrawer with typed MenuItem structure and submenu handling --- src/components/MainDrawer.tsx | 4 +++- src/config/constant.ts | 12 ++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/MainDrawer.tsx b/src/components/MainDrawer.tsx index 6a5e6f38..f41316f4 100644 --- a/src/components/MainDrawer.tsx +++ b/src/components/MainDrawer.tsx @@ -189,6 +189,8 @@ const MainDrawer = ({ ); const traverseMenuTitle = (menu: typeof activeMenu) => { + if (!menu) return; + const hasSubmenu = menu?.submenu && menu?.submenu.length > 0; if (!title) { @@ -197,7 +199,7 @@ const MainDrawer = ({ title += ' - ' + menu?.title; } - if (!hasSubmenu) return; + if (!hasSubmenu || !menu.submenu) return; const activeSubmenu = menu.submenu.find((item) => isPathActive(pathname, item.link) diff --git a/src/config/constant.ts b/src/config/constant.ts index 1fbef81f..8a5ca62f 100644 --- a/src/config/constant.ts +++ b/src/config/constant.ts @@ -1,4 +1,13 @@ -export const MAIN_DRAWER_LINKS = [ +export type MenuItem = { + title: string; + link: string; + icon: string; + submenu?: MenuItem[]; +}; + +type MainDrawerLink = MenuItem; + +export const MAIN_DRAWER_LINKS: MainDrawerLink[] = [ { title: 'Dashboard', link: '/dashboard', @@ -119,4 +128,3 @@ export const PRODUCT_FLAG_OPTIONS = [ { label: 'VITAMIN', value: 'VITAMIN' }, { label: 'KIMIA', value: 'KIMIA' }, ]; - From 9f2add3a57345f6b3e3fddefab7c1b1c447a9320 Mon Sep 17 00:00:00 2001 From: rstubryan Date: Thu, 9 Oct 2025 09:38:16 +0700 Subject: [PATCH 2/6] feat: add multiple layout components with suspense fallback for loading states --- src/app/master-data/area/detail/layout.tsx | 21 +++++++++++++++++++ src/app/master-data/kandang/detail/layout.tsx | 21 +++++++++++++++++++ .../master-data/location/detail/layout.tsx | 21 +++++++++++++++++++ .../master-data/nonstock/detail/layout.tsx | 21 +++++++++++++++++++ .../product-category/detail/layout.tsx | 21 +++++++++++++++++++ src/app/master-data/product/detail/layout.tsx | 21 +++++++++++++++++++ src/app/master-data/uom/detail/layout.tsx | 17 +++++++++++++++ .../master-data/warehouse/detail/layout.tsx | 21 +++++++++++++++++++ 8 files changed, 164 insertions(+) create mode 100644 src/app/master-data/area/detail/layout.tsx create mode 100644 src/app/master-data/kandang/detail/layout.tsx create mode 100644 src/app/master-data/location/detail/layout.tsx create mode 100644 src/app/master-data/nonstock/detail/layout.tsx create mode 100644 src/app/master-data/product-category/detail/layout.tsx create mode 100644 src/app/master-data/product/detail/layout.tsx create mode 100644 src/app/master-data/uom/detail/layout.tsx create mode 100644 src/app/master-data/warehouse/detail/layout.tsx diff --git a/src/app/master-data/area/detail/layout.tsx b/src/app/master-data/area/detail/layout.tsx new file mode 100644 index 00000000..6a7b249d --- /dev/null +++ b/src/app/master-data/area/detail/layout.tsx @@ -0,0 +1,21 @@ +'use client'; + +import { Suspense } from 'react'; + +export default function AreaLayout({ + children, +}: { + children: React.ReactNode; +}) { + return ( + + + + } + > + {children} + + ); +} diff --git a/src/app/master-data/kandang/detail/layout.tsx b/src/app/master-data/kandang/detail/layout.tsx new file mode 100644 index 00000000..f3c8c490 --- /dev/null +++ b/src/app/master-data/kandang/detail/layout.tsx @@ -0,0 +1,21 @@ +'use client'; + +import { Suspense } from 'react'; + +export default function KandangLayout({ + children, +}: { + children: React.ReactNode; +}) { + return ( + + + + } + > + {children} + + ); +} diff --git a/src/app/master-data/location/detail/layout.tsx b/src/app/master-data/location/detail/layout.tsx new file mode 100644 index 00000000..fbe0ff69 --- /dev/null +++ b/src/app/master-data/location/detail/layout.tsx @@ -0,0 +1,21 @@ +'use client'; + +import { Suspense } from 'react'; + +export default function LocationLayout({ + children, +}: { + children: React.ReactNode; +}) { + return ( + + + + } + > + {children} + + ); +} diff --git a/src/app/master-data/nonstock/detail/layout.tsx b/src/app/master-data/nonstock/detail/layout.tsx new file mode 100644 index 00000000..aa0d1116 --- /dev/null +++ b/src/app/master-data/nonstock/detail/layout.tsx @@ -0,0 +1,21 @@ +'use client'; + +import { Suspense } from 'react'; + +export default function NonstockLayout({ + children, +}: { + children: React.ReactNode; +}) { + return ( + + + + } + > + {children} + + ); +} diff --git a/src/app/master-data/product-category/detail/layout.tsx b/src/app/master-data/product-category/detail/layout.tsx new file mode 100644 index 00000000..76235398 --- /dev/null +++ b/src/app/master-data/product-category/detail/layout.tsx @@ -0,0 +1,21 @@ +'use client'; + +import { Suspense } from 'react'; + +export default function ProductCategoryLayout({ + children, +}: { + children: React.ReactNode; +}) { + return ( + + + + } + > + {children} + + ); +} diff --git a/src/app/master-data/product/detail/layout.tsx b/src/app/master-data/product/detail/layout.tsx new file mode 100644 index 00000000..5a91b249 --- /dev/null +++ b/src/app/master-data/product/detail/layout.tsx @@ -0,0 +1,21 @@ +'use client'; + +import { Suspense } from 'react'; + +export default function ProductLayout({ + children, +}: { + children: React.ReactNode; +}) { + return ( + + + + } + > + {children} + + ); +} diff --git a/src/app/master-data/uom/detail/layout.tsx b/src/app/master-data/uom/detail/layout.tsx new file mode 100644 index 00000000..1938ec61 --- /dev/null +++ b/src/app/master-data/uom/detail/layout.tsx @@ -0,0 +1,17 @@ +'use client'; + +import { Suspense } from 'react'; + +export default function UomLayout({ children }: { children: React.ReactNode }) { + return ( + + + + } + > + {children} + + ); +} diff --git a/src/app/master-data/warehouse/detail/layout.tsx b/src/app/master-data/warehouse/detail/layout.tsx new file mode 100644 index 00000000..6b78cf39 --- /dev/null +++ b/src/app/master-data/warehouse/detail/layout.tsx @@ -0,0 +1,21 @@ +'use client'; + +import { Suspense } from 'react'; + +export default function WarehouseLayout({ + children, +}: { + children: React.ReactNode; +}) { + return ( + + + + } + > + {children} + + ); +} From d1f43c4e423f96cd03875170ea6d1c4b5eed46a2 Mon Sep 17 00:00:00 2001 From: rstubryan Date: Thu, 9 Oct 2025 10:00:38 +0700 Subject: [PATCH 3/6] refactor: rename layout files for consistency and clarity --- .../area/detail/edit/page.tsx | 0 .../{ => (suspense)}/area/detail/page.tsx | 0 .../kandang/detail/edit/page.tsx | 0 .../{ => (suspense)}/kandang/detail/page.tsx | 0 .../{area/detail => (suspense)}/layout.tsx | 3 ++- .../location/detail/edit/page.tsx | 0 .../{ => (suspense)}/location/detail/page.tsx | 0 .../nonstock/detail/edit/page.tsx | 0 .../{ => (suspense)}/nonstock/detail/page.tsx | 0 .../product-category/detail/edit/page.tsx | 0 .../product-category/detail/page.tsx | 0 .../product/detail/edit/page.tsx | 0 .../{ => (suspense)}/product/detail/page.tsx | 0 .../{ => (suspense)}/uom/detail/edit/page.tsx | 0 .../{ => (suspense)}/uom/detail/page.tsx | 0 .../warehouse/detail/edit/page.tsx | 0 .../warehouse/detail/page.tsx | 0 src/app/master-data/kandang/detail/layout.tsx | 21 ------------------- .../master-data/location/detail/layout.tsx | 21 ------------------- .../master-data/nonstock/detail/layout.tsx | 21 ------------------- .../product-category/detail/layout.tsx | 21 ------------------- src/app/master-data/product/detail/layout.tsx | 21 ------------------- src/app/master-data/uom/detail/layout.tsx | 17 --------------- .../master-data/warehouse/detail/layout.tsx | 21 ------------------- 24 files changed, 2 insertions(+), 144 deletions(-) rename src/app/master-data/{ => (suspense)}/area/detail/edit/page.tsx (100%) rename src/app/master-data/{ => (suspense)}/area/detail/page.tsx (100%) rename src/app/master-data/{ => (suspense)}/kandang/detail/edit/page.tsx (100%) rename src/app/master-data/{ => (suspense)}/kandang/detail/page.tsx (100%) rename src/app/master-data/{area/detail => (suspense)}/layout.tsx (80%) rename src/app/master-data/{ => (suspense)}/location/detail/edit/page.tsx (100%) rename src/app/master-data/{ => (suspense)}/location/detail/page.tsx (100%) rename src/app/master-data/{ => (suspense)}/nonstock/detail/edit/page.tsx (100%) rename src/app/master-data/{ => (suspense)}/nonstock/detail/page.tsx (100%) rename src/app/master-data/{ => (suspense)}/product-category/detail/edit/page.tsx (100%) rename src/app/master-data/{ => (suspense)}/product-category/detail/page.tsx (100%) rename src/app/master-data/{ => (suspense)}/product/detail/edit/page.tsx (100%) rename src/app/master-data/{ => (suspense)}/product/detail/page.tsx (100%) rename src/app/master-data/{ => (suspense)}/uom/detail/edit/page.tsx (100%) rename src/app/master-data/{ => (suspense)}/uom/detail/page.tsx (100%) rename src/app/master-data/{ => (suspense)}/warehouse/detail/edit/page.tsx (100%) rename src/app/master-data/{ => (suspense)}/warehouse/detail/page.tsx (100%) delete mode 100644 src/app/master-data/kandang/detail/layout.tsx delete mode 100644 src/app/master-data/location/detail/layout.tsx delete mode 100644 src/app/master-data/nonstock/detail/layout.tsx delete mode 100644 src/app/master-data/product-category/detail/layout.tsx delete mode 100644 src/app/master-data/product/detail/layout.tsx delete mode 100644 src/app/master-data/uom/detail/layout.tsx delete mode 100644 src/app/master-data/warehouse/detail/layout.tsx diff --git a/src/app/master-data/area/detail/edit/page.tsx b/src/app/master-data/(suspense)/area/detail/edit/page.tsx similarity index 100% rename from src/app/master-data/area/detail/edit/page.tsx rename to src/app/master-data/(suspense)/area/detail/edit/page.tsx diff --git a/src/app/master-data/area/detail/page.tsx b/src/app/master-data/(suspense)/area/detail/page.tsx similarity index 100% rename from src/app/master-data/area/detail/page.tsx rename to src/app/master-data/(suspense)/area/detail/page.tsx diff --git a/src/app/master-data/kandang/detail/edit/page.tsx b/src/app/master-data/(suspense)/kandang/detail/edit/page.tsx similarity index 100% rename from src/app/master-data/kandang/detail/edit/page.tsx rename to src/app/master-data/(suspense)/kandang/detail/edit/page.tsx diff --git a/src/app/master-data/kandang/detail/page.tsx b/src/app/master-data/(suspense)/kandang/detail/page.tsx similarity index 100% rename from src/app/master-data/kandang/detail/page.tsx rename to src/app/master-data/(suspense)/kandang/detail/page.tsx diff --git a/src/app/master-data/area/detail/layout.tsx b/src/app/master-data/(suspense)/layout.tsx similarity index 80% rename from src/app/master-data/area/detail/layout.tsx rename to src/app/master-data/(suspense)/layout.tsx index 6a7b249d..a059dcf2 100644 --- a/src/app/master-data/area/detail/layout.tsx +++ b/src/app/master-data/(suspense)/layout.tsx @@ -1,8 +1,9 @@ +// src/app/master-data/(suspense)/layout.tsx 'use client'; import { Suspense } from 'react'; -export default function AreaLayout({ +export default function SuspenseLayout({ children, }: { children: React.ReactNode; diff --git a/src/app/master-data/location/detail/edit/page.tsx b/src/app/master-data/(suspense)/location/detail/edit/page.tsx similarity index 100% rename from src/app/master-data/location/detail/edit/page.tsx rename to src/app/master-data/(suspense)/location/detail/edit/page.tsx diff --git a/src/app/master-data/location/detail/page.tsx b/src/app/master-data/(suspense)/location/detail/page.tsx similarity index 100% rename from src/app/master-data/location/detail/page.tsx rename to src/app/master-data/(suspense)/location/detail/page.tsx diff --git a/src/app/master-data/nonstock/detail/edit/page.tsx b/src/app/master-data/(suspense)/nonstock/detail/edit/page.tsx similarity index 100% rename from src/app/master-data/nonstock/detail/edit/page.tsx rename to src/app/master-data/(suspense)/nonstock/detail/edit/page.tsx diff --git a/src/app/master-data/nonstock/detail/page.tsx b/src/app/master-data/(suspense)/nonstock/detail/page.tsx similarity index 100% rename from src/app/master-data/nonstock/detail/page.tsx rename to src/app/master-data/(suspense)/nonstock/detail/page.tsx diff --git a/src/app/master-data/product-category/detail/edit/page.tsx b/src/app/master-data/(suspense)/product-category/detail/edit/page.tsx similarity index 100% rename from src/app/master-data/product-category/detail/edit/page.tsx rename to src/app/master-data/(suspense)/product-category/detail/edit/page.tsx diff --git a/src/app/master-data/product-category/detail/page.tsx b/src/app/master-data/(suspense)/product-category/detail/page.tsx similarity index 100% rename from src/app/master-data/product-category/detail/page.tsx rename to src/app/master-data/(suspense)/product-category/detail/page.tsx diff --git a/src/app/master-data/product/detail/edit/page.tsx b/src/app/master-data/(suspense)/product/detail/edit/page.tsx similarity index 100% rename from src/app/master-data/product/detail/edit/page.tsx rename to src/app/master-data/(suspense)/product/detail/edit/page.tsx diff --git a/src/app/master-data/product/detail/page.tsx b/src/app/master-data/(suspense)/product/detail/page.tsx similarity index 100% rename from src/app/master-data/product/detail/page.tsx rename to src/app/master-data/(suspense)/product/detail/page.tsx diff --git a/src/app/master-data/uom/detail/edit/page.tsx b/src/app/master-data/(suspense)/uom/detail/edit/page.tsx similarity index 100% rename from src/app/master-data/uom/detail/edit/page.tsx rename to src/app/master-data/(suspense)/uom/detail/edit/page.tsx diff --git a/src/app/master-data/uom/detail/page.tsx b/src/app/master-data/(suspense)/uom/detail/page.tsx similarity index 100% rename from src/app/master-data/uom/detail/page.tsx rename to src/app/master-data/(suspense)/uom/detail/page.tsx diff --git a/src/app/master-data/warehouse/detail/edit/page.tsx b/src/app/master-data/(suspense)/warehouse/detail/edit/page.tsx similarity index 100% rename from src/app/master-data/warehouse/detail/edit/page.tsx rename to src/app/master-data/(suspense)/warehouse/detail/edit/page.tsx diff --git a/src/app/master-data/warehouse/detail/page.tsx b/src/app/master-data/(suspense)/warehouse/detail/page.tsx similarity index 100% rename from src/app/master-data/warehouse/detail/page.tsx rename to src/app/master-data/(suspense)/warehouse/detail/page.tsx diff --git a/src/app/master-data/kandang/detail/layout.tsx b/src/app/master-data/kandang/detail/layout.tsx deleted file mode 100644 index f3c8c490..00000000 --- a/src/app/master-data/kandang/detail/layout.tsx +++ /dev/null @@ -1,21 +0,0 @@ -'use client'; - -import { Suspense } from 'react'; - -export default function KandangLayout({ - children, -}: { - children: React.ReactNode; -}) { - return ( - - - - } - > - {children} - - ); -} diff --git a/src/app/master-data/location/detail/layout.tsx b/src/app/master-data/location/detail/layout.tsx deleted file mode 100644 index fbe0ff69..00000000 --- a/src/app/master-data/location/detail/layout.tsx +++ /dev/null @@ -1,21 +0,0 @@ -'use client'; - -import { Suspense } from 'react'; - -export default function LocationLayout({ - children, -}: { - children: React.ReactNode; -}) { - return ( - - - - } - > - {children} - - ); -} diff --git a/src/app/master-data/nonstock/detail/layout.tsx b/src/app/master-data/nonstock/detail/layout.tsx deleted file mode 100644 index aa0d1116..00000000 --- a/src/app/master-data/nonstock/detail/layout.tsx +++ /dev/null @@ -1,21 +0,0 @@ -'use client'; - -import { Suspense } from 'react'; - -export default function NonstockLayout({ - children, -}: { - children: React.ReactNode; -}) { - return ( - - - - } - > - {children} - - ); -} diff --git a/src/app/master-data/product-category/detail/layout.tsx b/src/app/master-data/product-category/detail/layout.tsx deleted file mode 100644 index 76235398..00000000 --- a/src/app/master-data/product-category/detail/layout.tsx +++ /dev/null @@ -1,21 +0,0 @@ -'use client'; - -import { Suspense } from 'react'; - -export default function ProductCategoryLayout({ - children, -}: { - children: React.ReactNode; -}) { - return ( - - - - } - > - {children} - - ); -} diff --git a/src/app/master-data/product/detail/layout.tsx b/src/app/master-data/product/detail/layout.tsx deleted file mode 100644 index 5a91b249..00000000 --- a/src/app/master-data/product/detail/layout.tsx +++ /dev/null @@ -1,21 +0,0 @@ -'use client'; - -import { Suspense } from 'react'; - -export default function ProductLayout({ - children, -}: { - children: React.ReactNode; -}) { - return ( - - - - } - > - {children} - - ); -} diff --git a/src/app/master-data/uom/detail/layout.tsx b/src/app/master-data/uom/detail/layout.tsx deleted file mode 100644 index 1938ec61..00000000 --- a/src/app/master-data/uom/detail/layout.tsx +++ /dev/null @@ -1,17 +0,0 @@ -'use client'; - -import { Suspense } from 'react'; - -export default function UomLayout({ children }: { children: React.ReactNode }) { - return ( - - - - } - > - {children} - - ); -} diff --git a/src/app/master-data/warehouse/detail/layout.tsx b/src/app/master-data/warehouse/detail/layout.tsx deleted file mode 100644 index 6b78cf39..00000000 --- a/src/app/master-data/warehouse/detail/layout.tsx +++ /dev/null @@ -1,21 +0,0 @@ -'use client'; - -import { Suspense } from 'react'; - -export default function WarehouseLayout({ - children, -}: { - children: React.ReactNode; -}) { - return ( - - - - } - > - {children} - - ); -} From f0eabedcb2dadb46ca086576c9811694ee9495a9 Mon Sep 17 00:00:00 2001 From: rstubryan Date: Thu, 9 Oct 2025 11:06:59 +0700 Subject: [PATCH 4/6] refactor: refactor layout components to use SuspenseHelper for loading states --- src/app/master-data/area/detail/layout.tsx | 26 ++++++------------- src/app/master-data/kandang/detail/layout.tsx | 26 ++++++------------- .../master-data/location/detail/layout.tsx | 26 ++++++------------- .../master-data/nonstock/detail/layout.tsx | 26 ++++++------------- .../product-category/detail/layout.tsx | 26 ++++++------------- src/app/master-data/product/detail/layout.tsx | 26 ++++++------------- src/app/master-data/uom/detail/layout.tsx | 24 +++++++---------- .../master-data/warehouse/detail/layout.tsx | 26 ++++++------------- src/components/helper/SuspenseHelper.tsx | 23 ++++++++++++++++ 9 files changed, 88 insertions(+), 141 deletions(-) create mode 100644 src/components/helper/SuspenseHelper.tsx diff --git a/src/app/master-data/area/detail/layout.tsx b/src/app/master-data/area/detail/layout.tsx index 6a7b249d..7220dfa1 100644 --- a/src/app/master-data/area/detail/layout.tsx +++ b/src/app/master-data/area/detail/layout.tsx @@ -1,21 +1,11 @@ -'use client'; +import SuspenseHelper from '@/components/helper/SuspenseHelper'; -import { Suspense } from 'react'; - -export default function AreaLayout({ +const Layout = ({ children, -}: { +}: Readonly<{ children: React.ReactNode; -}) { - return ( - - - - } - > - {children} - - ); -} +}>) => { + return {children}; +}; + +export default Layout; diff --git a/src/app/master-data/kandang/detail/layout.tsx b/src/app/master-data/kandang/detail/layout.tsx index f3c8c490..7220dfa1 100644 --- a/src/app/master-data/kandang/detail/layout.tsx +++ b/src/app/master-data/kandang/detail/layout.tsx @@ -1,21 +1,11 @@ -'use client'; +import SuspenseHelper from '@/components/helper/SuspenseHelper'; -import { Suspense } from 'react'; - -export default function KandangLayout({ +const Layout = ({ children, -}: { +}: Readonly<{ children: React.ReactNode; -}) { - return ( - - - - } - > - {children} - - ); -} +}>) => { + return {children}; +}; + +export default Layout; diff --git a/src/app/master-data/location/detail/layout.tsx b/src/app/master-data/location/detail/layout.tsx index fbe0ff69..7220dfa1 100644 --- a/src/app/master-data/location/detail/layout.tsx +++ b/src/app/master-data/location/detail/layout.tsx @@ -1,21 +1,11 @@ -'use client'; +import SuspenseHelper from '@/components/helper/SuspenseHelper'; -import { Suspense } from 'react'; - -export default function LocationLayout({ +const Layout = ({ children, -}: { +}: Readonly<{ children: React.ReactNode; -}) { - return ( - - - - } - > - {children} - - ); -} +}>) => { + return {children}; +}; + +export default Layout; diff --git a/src/app/master-data/nonstock/detail/layout.tsx b/src/app/master-data/nonstock/detail/layout.tsx index aa0d1116..7220dfa1 100644 --- a/src/app/master-data/nonstock/detail/layout.tsx +++ b/src/app/master-data/nonstock/detail/layout.tsx @@ -1,21 +1,11 @@ -'use client'; +import SuspenseHelper from '@/components/helper/SuspenseHelper'; -import { Suspense } from 'react'; - -export default function NonstockLayout({ +const Layout = ({ children, -}: { +}: Readonly<{ children: React.ReactNode; -}) { - return ( - - - - } - > - {children} - - ); -} +}>) => { + return {children}; +}; + +export default Layout; diff --git a/src/app/master-data/product-category/detail/layout.tsx b/src/app/master-data/product-category/detail/layout.tsx index 76235398..7220dfa1 100644 --- a/src/app/master-data/product-category/detail/layout.tsx +++ b/src/app/master-data/product-category/detail/layout.tsx @@ -1,21 +1,11 @@ -'use client'; +import SuspenseHelper from '@/components/helper/SuspenseHelper'; -import { Suspense } from 'react'; - -export default function ProductCategoryLayout({ +const Layout = ({ children, -}: { +}: Readonly<{ children: React.ReactNode; -}) { - return ( - - - - } - > - {children} - - ); -} +}>) => { + return {children}; +}; + +export default Layout; diff --git a/src/app/master-data/product/detail/layout.tsx b/src/app/master-data/product/detail/layout.tsx index 5a91b249..7220dfa1 100644 --- a/src/app/master-data/product/detail/layout.tsx +++ b/src/app/master-data/product/detail/layout.tsx @@ -1,21 +1,11 @@ -'use client'; +import SuspenseHelper from '@/components/helper/SuspenseHelper'; -import { Suspense } from 'react'; - -export default function ProductLayout({ +const Layout = ({ children, -}: { +}: Readonly<{ children: React.ReactNode; -}) { - return ( - - - - } - > - {children} - - ); -} +}>) => { + return {children}; +}; + +export default Layout; diff --git a/src/app/master-data/uom/detail/layout.tsx b/src/app/master-data/uom/detail/layout.tsx index 1938ec61..7220dfa1 100644 --- a/src/app/master-data/uom/detail/layout.tsx +++ b/src/app/master-data/uom/detail/layout.tsx @@ -1,17 +1,11 @@ -'use client'; +import SuspenseHelper from '@/components/helper/SuspenseHelper'; -import { Suspense } from 'react'; +const Layout = ({ + children, +}: Readonly<{ + children: React.ReactNode; +}>) => { + return {children}; +}; -export default function UomLayout({ children }: { children: React.ReactNode }) { - return ( - - - - } - > - {children} - - ); -} +export default Layout; diff --git a/src/app/master-data/warehouse/detail/layout.tsx b/src/app/master-data/warehouse/detail/layout.tsx index 6b78cf39..7220dfa1 100644 --- a/src/app/master-data/warehouse/detail/layout.tsx +++ b/src/app/master-data/warehouse/detail/layout.tsx @@ -1,21 +1,11 @@ -'use client'; +import SuspenseHelper from '@/components/helper/SuspenseHelper'; -import { Suspense } from 'react'; - -export default function WarehouseLayout({ +const Layout = ({ children, -}: { +}: Readonly<{ children: React.ReactNode; -}) { - return ( - - - - } - > - {children} - - ); -} +}>) => { + return {children}; +}; + +export default Layout; diff --git a/src/components/helper/SuspenseHelper.tsx b/src/components/helper/SuspenseHelper.tsx new file mode 100644 index 00000000..a151cd9d --- /dev/null +++ b/src/components/helper/SuspenseHelper.tsx @@ -0,0 +1,23 @@ +'use client'; + +import { Suspense } from 'react'; + +const SuspenseHelper = ({ + children, +}: Readonly<{ + children: React.ReactNode; +}>) => { + return ( + + + + } + > + {children} + + ); +}; + +export default SuspenseHelper; From b561ed619361461d7b6ed9e8585d14e9974abc89 Mon Sep 17 00:00:00 2001 From: rstubryan Date: Thu, 9 Oct 2025 11:35:22 +0700 Subject: [PATCH 5/6] fix: update dependencies in multiple tables to include updateSortingFilter in effect dependencies --- package.json | 2 ++ .../master-data/kandang/KandangsTable.tsx | 2 +- .../master-data/location/LocationsTable.tsx | 2 +- .../nonstock/form/NonstockForm.tsx | 2 +- .../product-category/ProductCategoryTable.tsx | 35 ++++++++++++++----- .../master-data/product/ProductTable.tsx | 18 ++++++---- .../pages/master-data/uom/UomsTable.tsx | 2 +- .../master-data/warehouse/WarehousesTable.tsx | 2 +- 8 files changed, 46 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 8adf6787..cf7765a2 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,8 @@ "dev": "eslint && next dev --turbopack", "build": "next build --turbopack", "start": "next start", + "start": "npx serve@latest out", + "start:next": "next start", "lint": "eslint" }, "dependencies": { diff --git a/src/components/pages/master-data/kandang/KandangsTable.tsx b/src/components/pages/master-data/kandang/KandangsTable.tsx index c3571452..c51eeb21 100644 --- a/src/components/pages/master-data/kandang/KandangsTable.tsx +++ b/src/components/pages/master-data/kandang/KandangsTable.tsx @@ -231,7 +231,7 @@ const KandangsTable = () => { updateSortingFilter('nameSort', nameSortFilter); updateSortingFilter('locationSort', locationSortFilter); updateSortingFilter('picSort', picSortFilter); - }, [sorting]); + }, [sorting, updateSortingFilter]); return ( <> diff --git a/src/components/pages/master-data/location/LocationsTable.tsx b/src/components/pages/master-data/location/LocationsTable.tsx index ebbb798f..2548fb28 100644 --- a/src/components/pages/master-data/location/LocationsTable.tsx +++ b/src/components/pages/master-data/location/LocationsTable.tsx @@ -230,7 +230,7 @@ const LocationsTable = () => { updateSortingFilter('nameSort', nameSortFilter); updateSortingFilter('addressSort', addressSortFilter); updateSortingFilter('areaSort', areaSortFilter); - }, [sorting]); + }, [sorting, updateSortingFilter]); return ( <> diff --git a/src/components/pages/master-data/nonstock/form/NonstockForm.tsx b/src/components/pages/master-data/nonstock/form/NonstockForm.tsx index 33dcba54..efc1f595 100644 --- a/src/components/pages/master-data/nonstock/form/NonstockForm.tsx +++ b/src/components/pages/master-data/nonstock/form/NonstockForm.tsx @@ -99,7 +99,7 @@ const NonstockForm = ({ type = 'add', initialValues }: NonstockFormProps) => { useEffect(() => { formik.setValues(formikInitialValues); - }, [formikInitialValues]); + }, [formik, formikInitialValues]); return (
diff --git a/src/components/pages/master-data/product-category/ProductCategoryTable.tsx b/src/components/pages/master-data/product-category/ProductCategoryTable.tsx index f8413ab6..63b1c919 100644 --- a/src/components/pages/master-data/product-category/ProductCategoryTable.tsx +++ b/src/components/pages/master-data/product-category/ProductCategoryTable.tsx @@ -66,7 +66,12 @@ const RowOptionsMenu = ({ color='error' className='text-error hover:text-inherit' > - + Delete @@ -96,7 +101,9 @@ const ProductCategoryTable = () => { const deleteModal = useModal(); - const [selectedProductCategory, setSelectedProductCategory] = useState(undefined); + const [selectedProductCategory, setSelectedProductCategory] = useState< + ProductCategory | undefined + >(undefined); const [isDeleteLoading, setIsDeleteLoading] = useState(false); const [sorting, setSorting] = useState([]); @@ -186,7 +193,7 @@ const ProductCategoryTable = () => { } else { updateFilter('nameSort', isNameSorted.desc ? 'desc' : 'asc'); } - }, [sorting]); + }, [sorting, updateFilter]); return ( <> @@ -221,18 +228,30 @@ const ProductCategoryTable = () => { - data={isResponseSuccess(productCategories) ? productCategories?.data : []} + data={ + isResponseSuccess(productCategories) ? productCategories?.data : [] + } columns={productCategoryColumns} pageSize={tableFilterState.pageSize} - page={isResponseSuccess(productCategories) ? productCategories?.meta?.page : 0} - totalItems={isResponseSuccess(productCategories) ? productCategories?.meta?.total_results : 0} + page={ + isResponseSuccess(productCategories) + ? productCategories?.meta?.page + : 0 + } + totalItems={ + isResponseSuccess(productCategories) + ? productCategories?.meta?.total_results + : 0 + } onPageChange={setPage} isLoading={isLoading} sorting={sorting} setSorting={setSorting} className={{ containerClassName: cn({ - 'mb-20': isResponseSuccess(productCategories) && productCategories?.data?.length === 0, + 'mb-20': + isResponseSuccess(productCategories) && + productCategories?.data?.length === 0, }), tableWrapperClassName: 'overflow-x-auto min-h-full!', tableClassName: 'font-inter w-full table-auto min-h-full!', @@ -263,4 +282,4 @@ const ProductCategoryTable = () => { ); }; -export default ProductCategoryTable; \ No newline at end of file +export default ProductCategoryTable; diff --git a/src/components/pages/master-data/product/ProductTable.tsx b/src/components/pages/master-data/product/ProductTable.tsx index ab256548..b38a749a 100644 --- a/src/components/pages/master-data/product/ProductTable.tsx +++ b/src/components/pages/master-data/product/ProductTable.tsx @@ -116,7 +116,9 @@ const ProductsTable = () => { ); const deleteModal = useModal(); - const [selectedProduct, setSelectedProduct] = useState(undefined); + const [selectedProduct, setSelectedProduct] = useState( + undefined + ); const [isDeleteLoading, setIsDeleteLoading] = useState(false); const [sorting, setSorting] = useState([]); @@ -153,12 +155,14 @@ const ProductsTable = () => { { accessorKey: 'product_price', header: 'Harga Produk', - cell: (props) => props.row.original.product_price?.toLocaleString() ?? '-', + cell: (props) => + props.row.original.product_price?.toLocaleString() ?? '-', }, { accessorKey: 'selling_price', header: 'Harga Jual', - cell: (props) => props.row.original.selling_price?.toLocaleString() ?? '-', + cell: (props) => + props.row.original.selling_price?.toLocaleString() ?? '-', }, { accessorKey: 'tax', @@ -261,13 +265,15 @@ const ProductsTable = () => { const nameSortFilter = sorting.find((sortItem) => sortItem.id === 'name'); const skuSortFilter = sorting.find((sortItem) => sortItem.id === 'sku'); const brandSortFilter = sorting.find((sortItem) => sortItem.id === 'brand'); - const categorySortFilter = sorting.find((sortItem) => sortItem.id === 'product_category'); + const categorySortFilter = sorting.find( + (sortItem) => sortItem.id === 'product_category' + ); updateSortingFilter('nameSort', nameSortFilter); updateSortingFilter('skuSort', skuSortFilter); updateSortingFilter('brandSort', brandSortFilter); updateSortingFilter('categorySort', categorySortFilter); - }, [sorting]); + }, [sorting, updateSortingFilter]); return ( <> @@ -347,4 +353,4 @@ const ProductsTable = () => { ); }; -export default ProductsTable; \ No newline at end of file +export default ProductsTable; diff --git a/src/components/pages/master-data/uom/UomsTable.tsx b/src/components/pages/master-data/uom/UomsTable.tsx index 080dfaf8..dcec5fe5 100644 --- a/src/components/pages/master-data/uom/UomsTable.tsx +++ b/src/components/pages/master-data/uom/UomsTable.tsx @@ -192,7 +192,7 @@ const UomsTable = () => { } else { updateFilter('nameSort', isNameSorted.desc ? 'desc' : 'asc'); } - }, [sorting]); + }, [sorting, updateFilter]); return ( <> diff --git a/src/components/pages/master-data/warehouse/WarehousesTable.tsx b/src/components/pages/master-data/warehouse/WarehousesTable.tsx index b3eed86b..f6d2d071 100644 --- a/src/components/pages/master-data/warehouse/WarehousesTable.tsx +++ b/src/components/pages/master-data/warehouse/WarehousesTable.tsx @@ -270,7 +270,7 @@ const WarehousesTable = () => { updateSortingFilter('areaSort', areaSortFilter); updateSortingFilter('locationSort', locationSortFilter); updateSortingFilter('kandangSort', kandangSortFilter); - }, [sorting]); + }, [sorting, updateSortingFilter]); return ( <> From 3f712a638f194dbc2aa8f8863059e2998274372d Mon Sep 17 00:00:00 2001 From: rstubryan Date: Thu, 9 Oct 2025 11:45:27 +0700 Subject: [PATCH 6/6] chore: remove redundant start scripts from package.json --- package.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/package.json b/package.json index cf7765a2..8adf6787 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,6 @@ "dev": "eslint && next dev --turbopack", "build": "next build --turbopack", "start": "next start", - "start": "npx serve@latest out", - "start:next": "next start", "lint": "eslint" }, "dependencies": {