From e9238e2bb5ccfb2698763605b7de2d0211bf563d Mon Sep 17 00:00:00 2001 From: rstubryan Date: Mon, 26 Jan 2026 11:45:57 +0700 Subject: [PATCH 01/34] feat(FE): Persist search in UI store and reset on exit --- .../product-category/ProductCategoryTable.tsx | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/components/pages/master-data/product-category/ProductCategoryTable.tsx b/src/components/pages/master-data/product-category/ProductCategoryTable.tsx index e25dfd56..11199c73 100644 --- a/src/components/pages/master-data/product-category/ProductCategoryTable.tsx +++ b/src/components/pages/master-data/product-category/ProductCategoryTable.tsx @@ -1,6 +1,6 @@ 'use client'; -import { ChangeEventHandler, useEffect, useState } from 'react'; +import { ChangeEventHandler, useEffect, useRef, useState } from 'react'; import useSWR from 'swr'; import { CellContext, ColumnDef, SortingState } from '@tanstack/react-table'; import toast from 'react-hot-toast'; @@ -22,6 +22,7 @@ import { ProductCategoryApi } from '@/services/api/master-data'; import { cn } from '@/lib/helper'; import { isResponseError, isResponseSuccess } from '@/lib/api-helper'; import { useTableFilter } from '@/services/hooks/useTableFilter'; +import { useUiStore } from '@/stores/ui/ui.store'; import { ROWS_OPTIONS } from '@/config/constant'; const RowOptionsMenu = ({ @@ -80,6 +81,9 @@ const RowOptionsMenu = ({ }; const ProductCategoryTable = () => { + const { searchValue, setSearchValue, resetSearchValue } = useUiStore(); + const previousPathRef = useRef(null); + const { state: tableFilterState, updateFilter, @@ -87,7 +91,7 @@ const ProductCategoryTable = () => { setPageSize, toQueryString: getTableFilterQueryString, } = useTableFilter({ - initial: { search: '', nameSort: '' }, + initial: { search: searchValue, nameSort: '' }, paramMap: { page: 'page', pageSize: 'limit', nameSort: 'sort_name' }, }); @@ -188,6 +192,7 @@ const ProductCategoryTable = () => { }; const searchChangeHandler: ChangeEventHandler = (e) => { + setSearchValue(e.target.value); updateFilter('search', e.target.value); }; @@ -196,6 +201,28 @@ const ProductCategoryTable = () => { setPageSize(newVal.value as number); }; + useEffect(() => { + // Store current path on mount + previousPathRef.current = window.location.pathname; + + return () => { + const currentPath = window.location.pathname; + + // if both paths are within /master-data/product-category module + const isCurrentPathProductCategory = currentPath.includes( + '/master-data/product-category' + ); + const isPreviousPathProductCategory = previousPathRef.current?.includes( + '/master-data/product-category' + ); + + // reset if we outside product category module entirely + if (isPreviousPathProductCategory && !isCurrentPathProductCategory) { + resetSearchValue(); + } + }; + }, [resetSearchValue]); + useEffect(() => { const isNameSorted = sorting.find((sortItem) => sortItem.id === 'name'); if (!isNameSorted) { From 2a03eae8a2ef61bfa58599ae1c0f34eb22b8e626 Mon Sep 17 00:00:00 2001 From: rstubryan Date: Mon, 26 Jan 2026 13:35:45 +0700 Subject: [PATCH 02/34] refactor(FE): Remove section padding on small+ screens --- src/app/expense/page.tsx | 2 +- src/app/inventory/movement/page.tsx | 2 +- src/app/production/recording/page.tsx | 2 +- src/app/purchase/page.tsx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/expense/page.tsx b/src/app/expense/page.tsx index d6b00286..0bd5d406 100644 --- a/src/app/expense/page.tsx +++ b/src/app/expense/page.tsx @@ -2,7 +2,7 @@ import ExpensesTable from '@/components/pages/expense/ExpensesTable'; const Expense = () => { return ( -
+
); diff --git a/src/app/inventory/movement/page.tsx b/src/app/inventory/movement/page.tsx index a2c25612..10717059 100644 --- a/src/app/inventory/movement/page.tsx +++ b/src/app/inventory/movement/page.tsx @@ -2,7 +2,7 @@ import MovementTable from '@/components/pages/inventory/movement/MovementTable'; const Movement = () => { return ( -
+
); diff --git a/src/app/production/recording/page.tsx b/src/app/production/recording/page.tsx index f31ac19a..471ef648 100644 --- a/src/app/production/recording/page.tsx +++ b/src/app/production/recording/page.tsx @@ -2,7 +2,7 @@ import RecordingTable from '@/components/pages/production/recording/RecordingTab const Recording = () => { return ( -
+
); diff --git a/src/app/purchase/page.tsx b/src/app/purchase/page.tsx index dc25a99d..ea2bb95b 100644 --- a/src/app/purchase/page.tsx +++ b/src/app/purchase/page.tsx @@ -2,7 +2,7 @@ import PurchaseTable from '@/components/pages/purchase/PurchaseTable'; const Purchase = () => { return ( -
+
); From afb0c40fd2b1a6ad622ff6de78f9bd35868a47ed Mon Sep 17 00:00:00 2001 From: rstubryan Date: Mon, 26 Jan 2026 13:37:06 +0700 Subject: [PATCH 03/34] refactor(FE): Add Status Approval column to PurchaseTable --- .../pages/purchase/PurchaseTable.tsx | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/components/pages/purchase/PurchaseTable.tsx b/src/components/pages/purchase/PurchaseTable.tsx index 81f45cc9..9af19b42 100644 --- a/src/components/pages/purchase/PurchaseTable.tsx +++ b/src/components/pages/purchase/PurchaseTable.tsx @@ -16,6 +16,7 @@ import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions'; import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import RequirePermission from '@/components/helper/RequirePermission'; +import Badge from '@/components/Badge'; import { cn, formatDate } from '@/lib/helper'; import { isResponseSuccess } from '@/lib/api-helper'; @@ -153,6 +154,57 @@ const PurchaseTable = () => { return `${diffDays} hari`; }, }, + { + header: 'Status Approval', + cell: (props) => { + const approval = props.row.original.latest_approval; + if (!approval) return '-'; + + const isRejected = approval.action === 'REJECTED'; + + let statusColor: + | 'warning' + | 'success' + | 'neutral' + | 'error' + | 'primary' + | 'info' = 'neutral'; + + switch (approval.step_number) { + case 1: + statusColor = 'neutral'; + break; + case 2: + statusColor = 'primary'; + break; + case 3: + statusColor = 'info'; + break; + case 4: + statusColor = 'warning'; + break; + case 5: + statusColor = 'success'; + break; + } + + if (isRejected) { + statusColor = 'error'; + } + + return ( + + {isRejected ? 'Ditolak' : approval.step_name} + + ); + }, + }, { header: 'Aksi', cell: (props) => { From 4011d261930513723e3313faa016c55d96e69a10 Mon Sep 17 00:00:00 2001 From: rstubryan Date: Mon, 26 Jan 2026 13:45:32 +0700 Subject: [PATCH 04/34] refactor(FE): Make approval and action buttons responsive --- src/components/pages/purchase/order/PurchaseOrderDetail.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/pages/purchase/order/PurchaseOrderDetail.tsx b/src/components/pages/purchase/order/PurchaseOrderDetail.tsx index 47dbc8f0..1f8dd3c9 100644 --- a/src/components/pages/purchase/order/PurchaseOrderDetail.tsx +++ b/src/components/pages/purchase/order/PurchaseOrderDetail.tsx @@ -605,7 +605,7 @@ const PurchaseOrderDetail = ({ return (
{/* Approval and Action Buttons */} -
+
); }; From 98608576b97b34e2ac0cad0388c5a877530dd4e6 Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Tue, 27 Jan 2026 16:53:17 +0700 Subject: [PATCH 11/34] chore: adjust DateInput styling --- src/components/input/DateInput.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/input/DateInput.tsx b/src/components/input/DateInput.tsx index 558779c7..da1a4d81 100644 --- a/src/components/input/DateInput.tsx +++ b/src/components/input/DateInput.tsx @@ -226,7 +226,7 @@ const DateInput = ({
@@ -257,8 +260,8 @@ const DateInput = ({ )} handleClick(e as unknown as React.MouseEvent) From 02fbd677fc48bac975c8ad3e895480c42069f750 Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Tue, 27 Jan 2026 16:54:44 +0700 Subject: [PATCH 12/34] chore: add readOnly prop and adjust SelectInput styling --- src/components/input/SelectInput.tsx | 43 +++++++++++++++++----------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/src/components/input/SelectInput.tsx b/src/components/input/SelectInput.tsx index 1eb3ccd8..419ed314 100644 --- a/src/components/input/SelectInput.tsx +++ b/src/components/input/SelectInput.tsx @@ -42,6 +42,7 @@ interface SelectInputBaseProps { optionComponent?: OptionComponent; components?: Partial; isDisabled?: boolean; + readOnly?: boolean; isLoading?: boolean; isClearable?: boolean; isRtl?: boolean; @@ -156,6 +157,7 @@ const SelectInput = (props: SelectInputProps) => { closeMenuOnSelect, hideSelectedOptions, onMenuScrollToBottom, + readOnly, } = props; const [internalInputValue, setInternalInputValue] = useState(''); @@ -235,7 +237,7 @@ const SelectInput = (props: SelectInputProps) => { onInputChange={internalInputChangeHandler} onMenuClose={() => setInternalInputValue('')} isMulti={isMulti} - isDisabled={isDisabled} + isDisabled={isDisabled || readOnly} isLoading={isLoading} isClearable={isClearable} isRtl={isRtl} @@ -247,30 +249,37 @@ const SelectInput = (props: SelectInputProps) => { classNames={{ ...(!startAdornment && { control: ({ isFocused, isDisabled }) => - cn( - 'w-full min-h-12! rounded-lg! border bg-white transition-shadow cursor-pointer!', - { - 'border-red-500! ring-2 ring-red-200': isError, - 'border-indigo-500 ring-2 ring-indigo-200': isFocused, - 'border-base-content/10!': !isError && !isFocused, - 'bg-gray-100 text-gray-400 cursor-not-allowed': isDisabled, - } - ), - valueContainer: () => cn('flex-1 p-3! py-2! gap-1'), + cn('w-full rounded-lg! border bg-white transition-shadow', { + 'cursor-pointer!': !readOnly && !isDisabled, + 'border-red-500! ring-2 ring-red-200': isError, + 'border-indigo-500 ring-2 ring-indigo-200': isFocused, + 'border-base-content/10!': !isError && !isFocused, + 'bg-gray-100 text-gray-400 cursor-not-allowed': + isDisabled && !readOnly, + 'bg-transparent! cursor-not-allowed!': readOnly, + }), + valueContainer: () => cn('flex-1 px-3! pr-2! py-2.5! gap-1'), }), placeholder: () => - cn({ 'text-gray-400': !isError, 'text-red-300!': isError }), + cn({ + 'text-gray-400 text-sm leading-tight': !isError, + 'text-red-300!': isError, + }), singleValue: () => - cn({ 'text-gray-900': !isError, 'text-error!': isError }), - input: () => cn('text-gray-900 m-0! p-0!'), - indicatorsContainer: () => cn('flex items-center gap-1 pr-2'), + cn({ + 'm-0! text-gray-900 text-sm leading-tight': !isError, + 'text-error!': isError, + 'text-gray-900!': readOnly, + }), + input: () => cn('text-gray-900 m-0! p-0! text-sm leading-tight'), + indicatorsContainer: () => cn('flex items-center gap-1 pr-3 py-2'), dropdownIndicator: ({ isFocused }) => - cn('p-1! rounded hover:bg-gray-100', { + cn('p-0! rounded hover:bg-gray-100', { 'text-gray-900': isFocused, 'text-gray-500': !isFocused, 'text-error!': isError, }), - clearIndicator: () => cn('p-1! rounded hover:bg-gray-100'), + clearIndicator: () => cn('p-0! rounded hover:bg-gray-100'), menu: () => cn( 'border border-base-content/5 rounded-xl! bg-base-100 shadow-lg! my-1.5!' From aa39478318eb54c2ba711bf1e51a60a738ab3d68 Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Tue, 27 Jan 2026 16:56:57 +0700 Subject: [PATCH 13/34] feat: create ApprovalStepsV2 component --- src/components/helper/ApprovalStepsV2.tsx | 201 ++++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 src/components/helper/ApprovalStepsV2.tsx diff --git a/src/components/helper/ApprovalStepsV2.tsx b/src/components/helper/ApprovalStepsV2.tsx new file mode 100644 index 00000000..6b731a72 --- /dev/null +++ b/src/components/helper/ApprovalStepsV2.tsx @@ -0,0 +1,201 @@ +'use client'; + +import { useEffect, useMemo, useState } from 'react'; + +import { Icon } from '@iconify/react'; +import { BaseApproval } from '@/types/api/api-general'; +import Button from '@/components/Button'; + +import { cn, formatDate } from '@/lib/helper'; + +interface ApprovalStepsV2Props { + approvals?: BaseApproval[]; + steps: { + step_number: number; + step_name: string; + }[]; + maxVisibleSteps?: number; + className?: { + wrapper?: string; + stepsWrapper?: string; + stepsContainer?: string; + }; +} + +const ApprovalStepsV2 = ({ + approvals, + steps, + maxVisibleSteps = 2, + className, +}: ApprovalStepsV2Props) => { + const [isSeeAll, setIsSeeAll] = useState(false); + const [formattedApprovals, setFormattedApprovals] = useState< + (BaseApproval & { isActive: boolean })[] + >([]); + + const latestApprovalStepNumber = + approvals?.[approvals.length - 1].step_number ?? 0; + + const lastStepNumber = steps[steps.length - 1].step_number; + + const isLatestApprovalStepNumberLessThanLastStepNumber = + latestApprovalStepNumber < lastStepNumber; + + const slicedFormattedApprovals = useMemo(() => { + return formattedApprovals.slice(0, isSeeAll ? undefined : maxVisibleSteps); + }, [formattedApprovals, isSeeAll]); + + const seeMoreClickHandler = () => { + setIsSeeAll((prevVal) => !prevVal); + }; + + useEffect(() => { + if (approvals) { + const tempFormattedApprovals: (BaseApproval & { isActive: boolean })[] = + []; + + approvals.forEach((approval) => { + tempFormattedApprovals.push({ + ...approval, + isActive: true, + }); + }); + + if (isLatestApprovalStepNumberLessThanLastStepNumber) { + const latestApprovalStepNumberIndexInSteps = steps.findIndex( + (step) => step.step_number === latestApprovalStepNumber + ); + + const slicedSteps = steps.slice( + latestApprovalStepNumberIndexInSteps + 1 + ); + + slicedSteps.forEach((step) => { + tempFormattedApprovals.push({ + action: 'APPROVED', + action_at: new Date().toISOString(), + action_by: { + id: 0, + id_user: 0, + email: '', + name: '', + }, + step_name: step.step_name, + step_number: step.step_number, + isActive: false, + }); + }); + } + + setFormattedApprovals(tempFormattedApprovals); + } + }, [approvals]); + + return ( +
+

+ Progress Details +

+ +
+ {slicedFormattedApprovals.map((approval, idx) => { + const isApprovalActionCreated = approval.action === 'CREATED'; + const isApprovalActionUpdated = approval.action === 'UPDATED'; + const isApprovalActionRejected = approval.action === 'REJECTED'; + const isApprovalActionApproved = approval.action === 'APPROVED'; + + const approvalIcon = + isApprovalActionCreated || isApprovalActionUpdated + ? 'heroicons:clock-solid' + : isApprovalActionRejected + ? 'heroicons:x-circle-solid' + : isApprovalActionApproved + ? 'heroicons:check-badge-solid' + : 'heroicons:check-badge-solid'; + + return ( +
+
+
+ + + {idx < formattedApprovals.length - 1 && ( +
+ )} +
+
+ +
+
+ {approval.step_name} + + {(isApprovalActionCreated || isApprovalActionUpdated) && + 'Diajukan oleh '} + {isApprovalActionRejected && 'Ditolak oleh '} + {isApprovalActionApproved && 'Disetujui oleh '} + {approval.isActive ? approval.action_by.name : '...'} + +
+ + {approval.isActive && ( +

+ Created at :{' '} + {formatDate(approval.action_at, 'DD-MM-YYYY, HH:mm')} +
+ Notes : {approval.notes ?? '-'} +

+ )} +
+
+ ); + })} +
+ + +
+ ); +}; + +export default ApprovalStepsV2; From f6a360ee2bfbbca9d54ea04eb42adb7d586c3a2e Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Tue, 27 Jan 2026 16:57:05 +0700 Subject: [PATCH 14/34] chore: update TextArea styling --- src/components/input/TextArea.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/input/TextArea.tsx b/src/components/input/TextArea.tsx index 65bd57d3..b3dd2663 100644 --- a/src/components/input/TextArea.tsx +++ b/src/components/input/TextArea.tsx @@ -83,7 +83,7 @@ const TextArea = ({