From 82c1645d923c15e45272912ff45c96e99ea8668a Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Thu, 30 Oct 2025 10:45:41 +0700 Subject: [PATCH 01/18] chore(FE-91): rework ApprovalSteps and create helper function for formatting approval workflow --- src/components/pages/ApprovalSteps.tsx | 169 +++++++++++++++++++++---- 1 file changed, 143 insertions(+), 26 deletions(-) diff --git a/src/components/pages/ApprovalSteps.tsx b/src/components/pages/ApprovalSteps.tsx index 4022e254..184b3f20 100644 --- a/src/components/pages/ApprovalSteps.tsx +++ b/src/components/pages/ApprovalSteps.tsx @@ -3,11 +3,24 @@ import Steps from '@/components/steps/Steps'; import StepItem from '@/components/steps/StepItem'; import Tooltip from '@/components/Tooltip'; -import { formatDate } from '@/lib/helper'; -import { ApprovalsLine } from '@/types/api/api-general'; +import { cn, formatDate } from '@/lib/helper'; +import { BaseApproval, BaseGroupedApproval } from '@/types/api/api-general'; +import { ApprovalLine } from '@/types/config/constant'; + +export type ApprovalStepStatus = 'APPROVED' | 'REJECTED' | 'WAITING' | 'IDLE'; + +export type ApprovalStepLog = { + action_by?: string; + date?: string; + notes?: string | null; +}; interface ApprovalStepsProps { - approvals: ApprovalsLine; + approvals: { + name?: string; + status: ApprovalStepStatus; + logs?: ApprovalStepLog[]; + }[]; } const ApprovalSteps = ({ approvals }: ApprovalStepsProps) => { @@ -15,17 +28,23 @@ const ApprovalSteps = ({ approvals }: ApprovalStepsProps) => { {approvals.map((approval, idx) => { const stepItemColor = - approval.status === 'approved' + approval.status === 'APPROVED' ? 'success' - : approval.status === 'rejected' + : approval.status === 'REJECTED' ? 'error' + : approval.status === 'WAITING' + ? 'warning' : undefined; const stepItemIcon = - approval.status === 'approved' + approval.status === 'APPROVED' ? 'material-symbols:check-rounded' - : approval.status === 'rejected' + : approval.status === 'REJECTED' ? 'material-symbols:close-rounded' + : approval.status === 'WAITING' + ? 'pajamas:dash-circle' + : approval.logs && approval.logs.length > 0 + ? 'material-symbols:info-outline-rounded' : 'bxs:hourglass'; return ( @@ -33,27 +52,53 @@ const ApprovalSteps = ({ approvals }: ApprovalStepsProps) => { key={idx} color={stepItemColor} icon={ - approval.status !== 'waiting' && ( - - {formatDate(approval.date, 'YYYY-MM-DD')} - Oleh: {approval.action_by} - Catatan: {approval.notes} - - } - > - - - ) + + {approval.logs && approval.logs.length > 0 && ( +
+ {approval.logs?.map((approvalLog, logIdx) => ( +
+ {approvalLog.date && ( + + {formatDate( + approvalLog.date, + 'YYYY-MM-DD, HH:mm:ss' + )} + + )} + Oleh: {approvalLog.action_by ?? '-'} + Catatan: {approvalLog.notes ?? '-'} +
+ ))} +
+ )} + + } + > + +
} > - {approval.role} + {approval.name} ); })} @@ -61,4 +106,76 @@ const ApprovalSteps = ({ approvals }: ApprovalStepsProps) => { ); }; +export const formatGroupedApprovalsToApprovalSteps = ( + approvalLine: ApprovalLine, + groupedApprovals: BaseGroupedApproval[], + latestApproval: BaseApproval +): ApprovalStepsProps['approvals'] => { + const formattedApprovalSteps: ApprovalStepsProps['approvals'] = + approvalLine.map((approvalLineItem) => { + const approvalGroup = groupedApprovals.find( + (approvalGroupItem) => + approvalGroupItem.step_number === approvalLineItem.step_number + ); + + const currentStepNumber = approvalLineItem.step_number; + const lastStepNumber = + groupedApprovals[groupedApprovals.length - 1].step_number; + + if (!approvalGroup && currentStepNumber <= lastStepNumber) { + throw new Error( + `Approval dengan ${approvalLineItem.step_name} tidak ditemukan!` + ); + } + + if (!approvalGroup) { + const isWaiting = currentStepNumber === latestApproval.step_number + 1; + + return { + name: approvalLineItem.step_name, + status: isWaiting ? 'WAITING' : 'IDLE', + }; + } + + let approvalStatus: ApprovalStepStatus; + + if (approvalGroup.step_number <= latestApproval.step_number) { + switch (approvalGroup.approvals[0].action) { + case 'CREATED': + case 'APPROVED': + approvalStatus = 'APPROVED'; + break; + + case 'REJECTED': + approvalStatus = 'REJECTED'; + break; + + default: + approvalStatus = 'IDLE'; + break; + } + } else if (approvalGroup.step_number === latestApproval.step_number + 1) { + approvalStatus = 'WAITING'; + } else { + approvalStatus = 'IDLE'; + } + + const approvalLogs: ApprovalStepLog[] = approvalGroup.approvals.map( + (approval) => ({ + action_by: approval.action_by.name, + date: approval.action_at, + notes: approval.notes, + }) + ); + + return { + name: approvalGroup.step_name, + status: approvalStatus, + logs: approvalLogs, + }; + }); + + return formattedApprovalSteps; +}; + export default ApprovalSteps; From b720c1411b15d9ca4ff7e5b0ce7615f2d8a9c0d3 Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Thu, 30 Oct 2025 10:47:29 +0700 Subject: [PATCH 02/18] chore(FE-91): make warning step icon glow --- src/components/steps/StepItem.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/steps/StepItem.tsx b/src/components/steps/StepItem.tsx index 85ec4f3e..26ce1ce8 100644 --- a/src/components/steps/StepItem.tsx +++ b/src/components/steps/StepItem.tsx @@ -24,7 +24,14 @@ const StepItem = ({ children, icon, className, color }: StepItemProps) => { return (
  • - {icon} + + {icon} +
    {children}
  • From bce58c585d89ee15a2ba338a8294e6a594c8c43c Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Thu, 30 Oct 2025 10:47:51 +0700 Subject: [PATCH 03/18] feat(FE-91): create approval-line config file --- src/config/approval-line.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/config/approval-line.ts diff --git a/src/config/approval-line.ts b/src/config/approval-line.ts new file mode 100644 index 00000000..0a02d1f1 --- /dev/null +++ b/src/config/approval-line.ts @@ -0,0 +1,12 @@ +import { ApprovalLine } from '@/types/config/constant'; + +export const PROJECT_FLOCK_APPROVAL_LINE: ApprovalLine = [ + { + step_number: 1, + step_name: 'Pengajuan', + }, + { + step_number: 2, + step_name: 'Aktif', + }, +] as const; From dd3a0079db959d099951939ba5ac00bb2f27453e Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Thu, 30 Oct 2025 10:48:18 +0700 Subject: [PATCH 04/18] chore(FE-91): set formatNumber locale to id-ID as default --- src/lib/helper.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/helper.ts b/src/lib/helper.ts index e3bfda65..002be5a3 100644 --- a/src/lib/helper.ts +++ b/src/lib/helper.ts @@ -19,7 +19,7 @@ export const cn = (...inputs: ClassValue[]) => { export const formatNumber = ( value: number | bigint | Intl.StringNumericLiteral, - locale = 'en-US', + locale = 'id-ID', minimumFractionDigits = 0, maximumFractionDigits = 2 ) => { @@ -29,7 +29,6 @@ export const formatNumber = ( }).format(value); }; - export const formatCurrency = ( value: number | bigint | Intl.StringNumericLiteral, currency = 'USD', From 5c3b1c489f9163fe38276f30621786b72711e256 Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Thu, 30 Oct 2025 10:48:37 +0700 Subject: [PATCH 05/18] chore(FE-91): set color for step-warning --- src/styles/daisyui.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/styles/daisyui.css b/src/styles/daisyui.css index dadaa2fa..fc87399f 100644 --- a/src/styles/daisyui.css +++ b/src/styles/daisyui.css @@ -9,6 +9,11 @@ --step-fg: var(--color-error-content); } + .step.step-warning::before { + --step-bg: var(--color-warning); + --step-fg: var(--color-warning-content); + } + .table :where(th, td) { vertical-align: top; } From c9c343b840093df80e96d9f2f63ced4231956c97 Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Thu, 30 Oct 2025 10:49:36 +0700 Subject: [PATCH 06/18] chore(FE-91): create BaseGroupedApproval, Approvals, and GroupedApprovals api types --- src/types/api/api-general.d.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/types/api/api-general.d.ts b/src/types/api/api-general.d.ts index a42eaa3f..af9144e2 100644 --- a/src/types/api/api-general.d.ts +++ b/src/types/api/api-general.d.ts @@ -97,21 +97,21 @@ export type flags = | 'FINISHER' | 'OVK'; -export type ApprovalsLine = { - action_by?: string; - date?: string; - notes?: string; - role?: string; - status: 'approved' | 'rejected' | 'waiting'; -}[]; - export type BaseApproval = { step_number: number; step_name: string; action: string; - notes: string | null; + notes?: string | null; action_by: CreatedUser; action_at: string; }; -export type ApproveAction = 'APPROVED' | 'REJECTED'; +export type BaseGroupedApproval = { + step_number: number; + step_name: string; + approvals: BaseApproval[]; +}; + +export type Approvals = BaseApiResponse; + +export type GroupedApprovals = BaseApiResponse; From f7eb89c11337eca261eded16e40d83d642dd887a Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Thu, 30 Oct 2025 10:49:50 +0700 Subject: [PATCH 07/18] feat(FE-91): create constant type file --- src/types/config/constant.d.ts | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/types/config/constant.d.ts diff --git a/src/types/config/constant.d.ts b/src/types/config/constant.d.ts new file mode 100644 index 00000000..3e4371be --- /dev/null +++ b/src/types/config/constant.d.ts @@ -0,0 +1,4 @@ +export type ApprovalLine = { + step_number: number; + step_name: string; +}[]; From 79cfcad026f1c0fa5540c95340244b51f7d678d7 Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Thu, 30 Oct 2025 11:03:22 +0700 Subject: [PATCH 08/18] chore(FE-91): set formatCurrency default currency to indonesian currency --- src/lib/helper.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/helper.ts b/src/lib/helper.ts index 002be5a3..aeda46f6 100644 --- a/src/lib/helper.ts +++ b/src/lib/helper.ts @@ -31,8 +31,8 @@ export const formatNumber = ( export const formatCurrency = ( value: number | bigint | Intl.StringNumericLiteral, - currency = 'USD', - locale = 'en-US', + currency = 'IDR', + locale = 'id-ID', minimumFractionDigits = 0, maximumFractionDigits = 2 ) => { From bba8fb15e58c2e01946594f4be62f1cc88057f1b Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Sat, 1 Nov 2025 15:24:52 +0700 Subject: [PATCH 09/18] chore: change a element to button --- src/components/menu/MenuItem.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/menu/MenuItem.tsx b/src/components/menu/MenuItem.tsx index 5046f8ff..dce81dac 100644 --- a/src/components/menu/MenuItem.tsx +++ b/src/components/menu/MenuItem.tsx @@ -49,14 +49,18 @@ const MenuItem = ({ ); return ( -
  • +
  • {href && ( {menuItemContent} )} - {!href && {menuItemContent}} + {!href && ( + + )}
  • ); }; From e6187555ced2cc4efec99d98be3180207254734d Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Sat, 1 Nov 2025 15:26:25 +0700 Subject: [PATCH 10/18] chore: create RowOptionsMenuWrapper component --- .../table/RowOptionsMenuWrapper.tsx | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/components/table/RowOptionsMenuWrapper.tsx diff --git a/src/components/table/RowOptionsMenuWrapper.tsx b/src/components/table/RowOptionsMenuWrapper.tsx new file mode 100644 index 00000000..53a8ecf1 --- /dev/null +++ b/src/components/table/RowOptionsMenuWrapper.tsx @@ -0,0 +1,29 @@ +import { ReactNode } from 'react'; +import { cn } from '@/lib/helper'; + +interface RowOptionsMenuWrapperProps { + children?: ReactNode; + type: 'dropdown' | 'collapse'; +} + +const RowOptionsMenuWrapper = ({ + children, + type, +}: RowOptionsMenuWrapperProps) => { + return ( +
    +
    {children}
    +
    + ); +}; + +export default RowOptionsMenuWrapper; From d853b43e175d4d59d58612f3897e82680cf7d91d Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Sat, 1 Nov 2025 15:31:11 +0700 Subject: [PATCH 11/18] fix: use RowOptionsMenuWrapper component for RowOptionsMenu --- .../pages/master-data/area/AreasTable.tsx | 27 +++++------ .../pages/master-data/bank/BanksTable.tsx | 29 ++++++------ .../master-data/customer/CustomersTable.tsx | 38 +++++++-------- .../pages/master-data/fcr/FcrsTable.tsx | 29 ++++++------ .../pages/master-data/flock/FlocksTable.tsx | 32 ++++++------- .../master-data/kandang/KandangsTable.tsx | 29 ++++++------ .../master-data/location/LocationsTable.tsx | 29 ++++++------ .../master-data/nonstock/NonstocksTable.tsx | 29 ++++++------ .../product-category/ProductCategoryTable.tsx | 29 ++++++------ .../master-data/product/ProductTable.tsx | 29 ++++++------ .../master-data/supplier/SupplierTable.tsx | 27 +++++------ .../pages/master-data/uom/UomsTable.tsx | 29 ++++++------ .../master-data/warehouse/WarehousesTable.tsx | 27 +++++------ .../pages/production/chickin/ChickinTable.tsx | 46 +++++++++---------- .../project-flock/ProjectFlockTable.tsx | 27 ++++------- .../production/recording/RecordingTable.tsx | 18 ++------ .../TransferToLayingsTable.tsx | 21 +++------ 17 files changed, 216 insertions(+), 279 deletions(-) diff --git a/src/components/pages/master-data/area/AreasTable.tsx b/src/components/pages/master-data/area/AreasTable.tsx index c1ec1ef5..207fb8a6 100644 --- a/src/components/pages/master-data/area/AreasTable.tsx +++ b/src/components/pages/master-data/area/AreasTable.tsx @@ -14,6 +14,7 @@ import ConfirmationModal from '@/components/modal/ConfirmationModal'; import SelectInput, { OptionType } from '@/components/input/SelectInput'; import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions'; +import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import { Area } from '@/types/api/master-data/area'; import { AreaApi } from '@/services/api/master-data'; @@ -32,16 +33,7 @@ const RowOptionsMenu = ({ deleteClickHandler: () => void; }) => { return ( -
    + -
    + ); }; @@ -150,7 +142,7 @@ const AreasTable = () => { {currentPageSize <= 2 && ( @@ -199,10 +191,15 @@ const AreasTable = () => {
    -
    -
    diff --git a/src/components/pages/master-data/bank/BanksTable.tsx b/src/components/pages/master-data/bank/BanksTable.tsx index 0d084491..58b09ef8 100644 --- a/src/components/pages/master-data/bank/BanksTable.tsx +++ b/src/components/pages/master-data/bank/BanksTable.tsx @@ -14,6 +14,7 @@ import ConfirmationModal from '@/components/modal/ConfirmationModal'; import SelectInput, { OptionType } from '@/components/input/SelectInput'; import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions'; +import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import { Bank } from '@/types/api/master-data/bank'; import { BankApi } from '@/services/api/master-data'; @@ -32,16 +33,7 @@ const RowOptionsMenu = ({ deleteClickHandler: () => void; }) => { return ( -
    + -
    + ); }; @@ -163,7 +155,7 @@ const BanksTable = () => { {currentPageSize <= 2 && ( @@ -212,10 +204,15 @@ const BanksTable = () => {
    -
    -
    diff --git a/src/components/pages/master-data/customer/CustomersTable.tsx b/src/components/pages/master-data/customer/CustomersTable.tsx index d3fde60b..89401638 100644 --- a/src/components/pages/master-data/customer/CustomersTable.tsx +++ b/src/components/pages/master-data/customer/CustomersTable.tsx @@ -8,6 +8,7 @@ import ConfirmationModal from '@/components/modal/ConfirmationModal'; import Table from '@/components/Table'; import RowCollapseOptions from '@/components/table/RowCollapseOptions'; import RowDropdownOptions from '@/components/table/RowDropdownOptions'; +import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import { ROWS_OPTIONS } from '@/config/constant'; import { isResponseSuccess } from '@/lib/api-helper'; import { cn } from '@/lib/helper'; @@ -15,10 +16,7 @@ import { CustomerApi } from '@/services/api/master-data'; import { useTableFilter } from '@/services/hooks/useTableFilter'; import { Customer } from '@/types/api/master-data/customer'; import { Icon } from '@iconify/react'; -import { - CellContext, - ColumnDef, -} from '@tanstack/react-table'; +import { CellContext, ColumnDef } from '@tanstack/react-table'; import { useState } from 'react'; import toast from 'react-hot-toast'; import useSWR from 'swr'; @@ -33,16 +31,7 @@ const RowOptionsMenu = ({ deleteClickHandler: () => void; }) => { return ( -
    + -
    + ); }; @@ -174,7 +163,7 @@ const CustomersTable = () => { {currentPageSize <= 2 && ( @@ -210,10 +199,15 @@ const CustomersTable = () => {
    -
    -
    @@ -285,4 +279,4 @@ const CustomersTable = () => { ); }; -export default CustomersTable; \ No newline at end of file +export default CustomersTable; diff --git a/src/components/pages/master-data/fcr/FcrsTable.tsx b/src/components/pages/master-data/fcr/FcrsTable.tsx index 5f0285bb..b582222e 100644 --- a/src/components/pages/master-data/fcr/FcrsTable.tsx +++ b/src/components/pages/master-data/fcr/FcrsTable.tsx @@ -14,6 +14,7 @@ import ConfirmationModal from '@/components/modal/ConfirmationModal'; import SelectInput, { OptionType } from '@/components/input/SelectInput'; import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions'; +import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import { Fcr } from '@/types/api/master-data/fcr'; import { FcrApi } from '@/services/api/master-data'; @@ -32,16 +33,7 @@ const RowOptionsMenu = ({ deleteClickHandler: () => void; }) => { return ( -
    + -
    + ); }; @@ -150,7 +142,7 @@ const FcrsTable = () => { {currentPageSize <= 2 && ( @@ -199,10 +191,15 @@ const FcrsTable = () => {
    -
    -
    diff --git a/src/components/pages/master-data/flock/FlocksTable.tsx b/src/components/pages/master-data/flock/FlocksTable.tsx index b0684a1a..5350c518 100644 --- a/src/components/pages/master-data/flock/FlocksTable.tsx +++ b/src/components/pages/master-data/flock/FlocksTable.tsx @@ -12,6 +12,7 @@ import { FlockApi } from '@/services/api/master-data'; import { useModal } from '@/components/Modal'; import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions'; +import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import toast from 'react-hot-toast'; import DebouncedTextInput from '@/components/input/DebouncedTextInput'; import SelectInput, { OptionType } from '@/components/input/SelectInput'; @@ -30,16 +31,7 @@ const RowsOptions = ({ deleteClickHandler: () => void; }) => { return ( -
    + - -
    + ); }; @@ -203,9 +195,15 @@ const FlockTable = () => {
    -
    -
    @@ -275,4 +273,4 @@ const FlockTable = () => { ); }; -export default FlockTable; \ No newline at end of file +export default FlockTable; diff --git a/src/components/pages/master-data/kandang/KandangsTable.tsx b/src/components/pages/master-data/kandang/KandangsTable.tsx index c51eeb21..45c981e1 100644 --- a/src/components/pages/master-data/kandang/KandangsTable.tsx +++ b/src/components/pages/master-data/kandang/KandangsTable.tsx @@ -19,6 +19,7 @@ import ConfirmationModal from '@/components/modal/ConfirmationModal'; import SelectInput, { OptionType } from '@/components/input/SelectInput'; import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions'; +import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import { Kandang } from '@/types/api/master-data/kandang'; import { KandangApi } from '@/services/api/master-data'; @@ -37,16 +38,7 @@ const RowOptionsMenu = ({ deleteClickHandler: () => void; }) => { return ( -
    + -
    + ); }; @@ -173,7 +165,7 @@ const KandangsTable = () => { {currentPageSize <= 2 && ( @@ -238,10 +230,15 @@ const KandangsTable = () => {
    -
    -
    diff --git a/src/components/pages/master-data/location/LocationsTable.tsx b/src/components/pages/master-data/location/LocationsTable.tsx index 2548fb28..19f11298 100644 --- a/src/components/pages/master-data/location/LocationsTable.tsx +++ b/src/components/pages/master-data/location/LocationsTable.tsx @@ -19,6 +19,7 @@ import ConfirmationModal from '@/components/modal/ConfirmationModal'; import SelectInput, { OptionType } from '@/components/input/SelectInput'; import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions'; +import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import { Location } from '@/types/api/master-data/location'; import { LocationApi } from '@/services/api/master-data'; @@ -37,16 +38,7 @@ const RowOptionsMenu = ({ deleteClickHandler: () => void; }) => { return ( -
    + -
    + ); }; @@ -172,7 +164,7 @@ const LocationsTable = () => { {currentPageSize <= 2 && ( @@ -237,10 +229,15 @@ const LocationsTable = () => {
    -
    -
    diff --git a/src/components/pages/master-data/nonstock/NonstocksTable.tsx b/src/components/pages/master-data/nonstock/NonstocksTable.tsx index 462b3488..ae38c573 100644 --- a/src/components/pages/master-data/nonstock/NonstocksTable.tsx +++ b/src/components/pages/master-data/nonstock/NonstocksTable.tsx @@ -19,6 +19,7 @@ import ConfirmationModal from '@/components/modal/ConfirmationModal'; import SelectInput, { OptionType } from '@/components/input/SelectInput'; import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions'; +import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import { Nonstock } from '@/types/api/master-data/nonstock'; import { NonstockApi } from '@/services/api/master-data'; @@ -37,16 +38,7 @@ const RowOptionsMenu = ({ deleteClickHandler: () => void; }) => { return ( -
    + -
    + ); }; @@ -184,7 +176,7 @@ const NonstocksTable = () => { {currentPageSize <= 2 && ( @@ -249,10 +241,15 @@ const NonstocksTable = () => {
    -
    -
    diff --git a/src/components/pages/master-data/product-category/ProductCategoryTable.tsx b/src/components/pages/master-data/product-category/ProductCategoryTable.tsx index 63b1c919..1a6e641c 100644 --- a/src/components/pages/master-data/product-category/ProductCategoryTable.tsx +++ b/src/components/pages/master-data/product-category/ProductCategoryTable.tsx @@ -14,6 +14,7 @@ import ConfirmationModal from '@/components/modal/ConfirmationModal'; import SelectInput, { OptionType } from '@/components/input/SelectInput'; import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions'; +import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import { ProductCategory } from '@/types/api/master-data/product-category'; import { ProductCategoryApi } from '@/services/api/master-data'; @@ -32,16 +33,7 @@ const RowOptionsMenu = ({ deleteClickHandler: () => void; }) => { return ( -
    + -
    + ); }; @@ -154,7 +146,7 @@ const ProductCategoryTable = () => { {currentPageSize <= 2 && ( @@ -200,10 +192,15 @@ const ProductCategoryTable = () => {
    -
    -
    ; deleteClickHandler: () => void; }) => ( -
    + -
    + ); const ProductsTable = () => { @@ -217,7 +209,7 @@ const ProductsTable = () => { {currentPageSize <= 2 && ( @@ -280,10 +272,15 @@ const ProductsTable = () => {
    -
    -
    void; }) => { return ( -
    + -
    + ); }; @@ -226,10 +218,15 @@ const SuppliersTable = () => {
    -
    -
    diff --git a/src/components/pages/master-data/uom/UomsTable.tsx b/src/components/pages/master-data/uom/UomsTable.tsx index dcec5fe5..edf67f34 100644 --- a/src/components/pages/master-data/uom/UomsTable.tsx +++ b/src/components/pages/master-data/uom/UomsTable.tsx @@ -14,6 +14,7 @@ import ConfirmationModal from '@/components/modal/ConfirmationModal'; import SelectInput, { OptionType } from '@/components/input/SelectInput'; import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions'; +import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import { Uom } from '@/types/api/master-data/uom'; import { UomApi } from '@/services/api/master-data'; @@ -32,16 +33,7 @@ const RowOptionsMenu = ({ deleteClickHandler: () => void; }) => { return ( -
    + -
    + ); }; @@ -150,7 +142,7 @@ const UomsTable = () => { {currentPageSize <= 2 && ( @@ -199,10 +191,15 @@ const UomsTable = () => {
    -
    -
    diff --git a/src/components/pages/master-data/warehouse/WarehousesTable.tsx b/src/components/pages/master-data/warehouse/WarehousesTable.tsx index f6d2d071..a61f6f5b 100644 --- a/src/components/pages/master-data/warehouse/WarehousesTable.tsx +++ b/src/components/pages/master-data/warehouse/WarehousesTable.tsx @@ -19,6 +19,7 @@ import ConfirmationModal from '@/components/modal/ConfirmationModal'; import SelectInput, { OptionType } from '@/components/input/SelectInput'; import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions'; +import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import { Warehouse } from '@/types/api/master-data/warehouse'; import { WarehouseApi } from '@/services/api/master-data'; @@ -37,16 +38,7 @@ const RowOptionsMenu = ({ deleteClickHandler: () => void; }) => { return ( -
    + -
    + ); }; @@ -206,7 +198,7 @@ const WarehousesTable = () => { {currentPageSize <= 2 && ( @@ -277,10 +269,15 @@ const WarehousesTable = () => {
    -
    -
    diff --git a/src/components/pages/production/chickin/ChickinTable.tsx b/src/components/pages/production/chickin/ChickinTable.tsx index 65ab3c16..cd52c154 100644 --- a/src/components/pages/production/chickin/ChickinTable.tsx +++ b/src/components/pages/production/chickin/ChickinTable.tsx @@ -8,6 +8,7 @@ import ConfirmationModal from '@/components/modal/ConfirmationModal'; import Table from '@/components/Table'; import RowCollapseOptions from '@/components/table/RowCollapseOptions'; import RowDropdownOptions from '@/components/table/RowDropdownOptions'; +import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import { TableRowSizeSelector } from '@/components/table/TableRowSizeSelector'; import { ROWS_OPTIONS } from '@/config/constant'; import { isResponseSuccess } from '@/lib/api-helper'; @@ -87,7 +88,9 @@ const ChickinTable = () => {
    - { - refreshChickins() - chickinModal.closeModal() - }}/> + { + refreshChickins(); + chickinModal.closeModal(); + }} + /> ); @@ -276,16 +285,7 @@ const RowOptionsMenu = ({ deleteClickHandler: () => void; }) => { return ( -
    + -
    + ); }; diff --git a/src/components/pages/production/project-flock/ProjectFlockTable.tsx b/src/components/pages/production/project-flock/ProjectFlockTable.tsx index 99f26721..56e3d4df 100644 --- a/src/components/pages/production/project-flock/ProjectFlockTable.tsx +++ b/src/components/pages/production/project-flock/ProjectFlockTable.tsx @@ -9,6 +9,7 @@ import ConfirmationModal from '@/components/modal/ConfirmationModal'; import Table from '@/components/Table'; import RowCollapseOptions from '@/components/table/RowCollapseOptions'; import RowDropdownOptions from '@/components/table/RowDropdownOptions'; +import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import { ROWS_OPTIONS } from '@/config/constant'; import { isResponseError, isResponseSuccess } from '@/lib/api-helper'; import { cn } from '@/lib/helper'; @@ -37,16 +38,7 @@ const RowOptionsMenu = ({ deleteClickHandler: () => void; }) => { return ( -
    + -
    + ); }; @@ -259,6 +251,7 @@ const ProjectFlockTable = () => {
    -
    + ); }; @@ -255,7 +247,7 @@ const RecordingTable = () => { void; }) => { return ( -
    + -
    + ); }; @@ -291,7 +283,7 @@ const TransferToLayingsTable = () => { {currentPageSize <= 2 && ( {
    {selectedRowIds.length > 0 && ( From 8a3c7d35ec566d03ce843241d14f20d07feecefd Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Sat, 1 Nov 2025 15:35:34 +0700 Subject: [PATCH 12/18] chore: update add button styling and copywriting --- .../adjustment/InventoryAdjustmentTable.tsx | 22 +++++++++---------- .../inventory/movement/MovementTable.tsx | 2 +- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/components/pages/inventory/adjustment/InventoryAdjustmentTable.tsx b/src/components/pages/inventory/adjustment/InventoryAdjustmentTable.tsx index 45cfd3f3..caa4aee4 100644 --- a/src/components/pages/inventory/adjustment/InventoryAdjustmentTable.tsx +++ b/src/components/pages/inventory/adjustment/InventoryAdjustmentTable.tsx @@ -10,11 +10,7 @@ import { inventoryAdjustmentApi } from '@/services/api/inventory'; import { useTableFilter } from '@/services/hooks/useTableFilter'; import { InventoryAdjustment } from '@/types/api/inventory/adjustment'; import { Icon } from '@iconify/react'; -import { - ColumnDef, - ColumnSort, - SortingState, -} from '@tanstack/react-table'; +import { ColumnDef, ColumnSort, SortingState } from '@tanstack/react-table'; import { useCallback, useEffect, useState } from 'react'; import useSWR from 'swr'; @@ -44,10 +40,7 @@ const InventoryAdjustmentTable = () => { }); // Fetch Data - const { - data: inventoryAdjustments, - isLoading, - } = useSWR( + const { data: inventoryAdjustments, isLoading } = useSWR( `${inventoryAdjustmentApi.basePath}${getTableFilterQueryString()}`, inventoryAdjustmentApi.getAllFetcher ); @@ -187,8 +180,13 @@ const InventoryAdjustmentTable = () => {
    -
    - @@ -211,7 +209,7 @@ const InventoryAdjustmentTable = () => { value: tableFilterState.pageSize, }} onChange={pageSizeChangeHandler} - className={{ wrapper: 'max-w-28' }} + className={{ wrapper: 'min-w-28' }} />
    diff --git a/src/components/pages/inventory/movement/MovementTable.tsx b/src/components/pages/inventory/movement/MovementTable.tsx index 61be40f8..6926ce4e 100644 --- a/src/components/pages/inventory/movement/MovementTable.tsx +++ b/src/components/pages/inventory/movement/MovementTable.tsx @@ -77,7 +77,7 @@ const MovementTable = () => { Date: Sat, 1 Nov 2025 15:35:49 +0700 Subject: [PATCH 13/18] chore: set min width for RowCollapseOptions --- src/components/table/RowCollapseOptions.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/table/RowCollapseOptions.tsx b/src/components/table/RowCollapseOptions.tsx index 42f9720a..ce90314c 100644 --- a/src/components/table/RowCollapseOptions.tsx +++ b/src/components/table/RowCollapseOptions.tsx @@ -16,7 +16,7 @@ const RowCollapseOptions = ({ children }: RowCollapseOptionsProps) => { } - className='w-fit' + className='w-fit min-w-36' titleClassName='p-0! justify-self-end' > {children} From b2540f1d43e5488944496bf12babf9817c12f67c Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Sat, 1 Nov 2025 15:36:11 +0700 Subject: [PATCH 14/18] chore: use RowOptionsMenuWrapper --- src/components/table/TableRowOptions.tsx | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/components/table/TableRowOptions.tsx b/src/components/table/TableRowOptions.tsx index 4e2e2c93..6c92c928 100644 --- a/src/components/table/TableRowOptions.tsx +++ b/src/components/table/TableRowOptions.tsx @@ -1,6 +1,6 @@ import { Icon } from '@iconify/react'; import Button from '../Button'; -import { cn } from '@/lib/helper'; +import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; interface TableRowOptionsProps { type?: 'dropdown' | 'collapse'; @@ -21,16 +21,7 @@ export const TableRowOptions = ({ showEdit = true, showDelete = true, }: TableRowOptionsProps) => ( -
    +
    + ); From 46572fd992430bb2b764abb9eb89a1bd37c57467 Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Sat, 1 Nov 2025 15:36:21 +0700 Subject: [PATCH 15/18] chore: update add button styling --- src/components/table/TableToolbar.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/table/TableToolbar.tsx b/src/components/table/TableToolbar.tsx index e3b385b1..4ec76931 100644 --- a/src/components/table/TableToolbar.tsx +++ b/src/components/table/TableToolbar.tsx @@ -18,8 +18,13 @@ export const TableToolbar = ({ addButton, search }: TableToolbarProps) => { return (
    {addButton && ( -
    - From 42b4206e6605ae8423eb2cd9da1193bd75065fa6 Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Sat, 1 Nov 2025 15:53:37 +0700 Subject: [PATCH 16/18] chore: install prettier --- package-lock.json | 17 +++++++++++++++++ package.json | 1 + 2 files changed, 18 insertions(+) diff --git a/package-lock.json b/package-lock.json index e1f28d3e..33b7c640 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,6 +39,7 @@ "eslint": "^9", "eslint-config-next": "15.5.3", "husky": "^9.1.7", + "prettier": "^3.6.2", "tailwindcss": "^4", "typescript": "^5" } @@ -5669,6 +5670,22 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz", + "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/prop-types": { "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", diff --git a/package.json b/package.json index b371e4e7..8250d68f 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "eslint": "^9", "eslint-config-next": "15.5.3", "husky": "^9.1.7", + "prettier": "^3.6.2", "tailwindcss": "^4", "typescript": "^5" } From f01dae5f97e88b1a6c83c6843674cf8f440bf405 Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Sat, 1 Nov 2025 15:58:03 +0700 Subject: [PATCH 17/18] chore: add format script --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 8250d68f..10fe9598 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "build": "next build --turbopack", "start": "next start", "lint": "eslint", - "prepare": "husky" + "prepare": "husky", + "format": "prettier --write ." }, "dependencies": { "@tanstack/match-sorter-utils": "^8.19.4", From 0ae4fe083127d55f65d92a43a8091f10b24a3859 Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Sat, 1 Nov 2025 15:58:47 +0700 Subject: [PATCH 18/18] chore: format code using prettier --- eslint.config.mjs | 18 +- postcss.config.mjs | 2 +- src/app/globals.css | 6 +- src/app/inventory/adjustment/add/page.tsx | 10 +- .../inventory/adjustment/detail/layout.tsx | 12 +- src/app/inventory/adjustment/detail/page.tsx | 15 +- src/app/master-data/customer/add/page.tsx | 10 +- src/app/master-data/customer/detail/page.tsx | 32 +- src/app/master-data/customer/page.tsx | 8 +- src/app/master-data/flock/add/page.tsx | 6 +- .../master-data/flock/detail/edit/page.tsx | 16 +- src/app/master-data/flock/detail/layout.tsx | 12 +- src/app/master-data/flock/detail/page.tsx | 35 +- src/app/master-data/flock/page.tsx | 10 +- .../master-data/product-category/add/page.tsx | 6 +- .../product-category/detail/edit/page.tsx | 63 +- .../product-category/detail/page.tsx | 14 +- src/app/master-data/product-category/page.tsx | 6 +- src/app/master-data/product/add/page.tsx | 4 +- .../master-data/product/detail/edit/page.tsx | 7 +- src/app/master-data/product/detail/page.tsx | 7 +- src/app/master-data/product/page.tsx | 8 +- src/app/master-data/supplier/add/page.tsx | 2 +- src/app/master-data/supplier/detail/page.tsx | 2 +- src/app/master-data/supplier/page.tsx | 2 +- src/app/production/chickin/add/layout.tsx | 12 +- src/app/production/chickin/detail/layout.tsx | 12 +- src/app/production/chickin/detail/page.tsx | 10 +- src/app/production/chickin/page.tsx | 10 +- src/app/production/project-flock/add/page.tsx | 12 +- .../project-flock/detail/edit/page.tsx | 39 +- .../project-flock/detail/layout.tsx | 12 +- .../production/project-flock/detail/page.tsx | 6 +- src/app/production/project-flock/page.tsx | 8 +- src/components/Card.tsx | 28 +- src/components/Pagination.tsx | 20 +- src/components/input/DateInput.tsx | 11 +- src/components/input/FileInput.tsx | 5 +- src/components/input/NumberInput.tsx | 16 +- src/components/pages/ApprovalSteps.tsx | 20 +- .../adjustment/InventoryAdjustmentTable.tsx | 4 +- .../form/InventoryAdjustmentForm.schema.ts | 9 +- .../form/InventoryAdjustmentForm.tsx | 45 +- .../customer/form/CustomerForm.tsx | 9 +- .../flock/form/FlockForm.schema.ts | 5 +- .../master-data/flock/form/FlockForm.tsx | 11 +- .../form/ProductCategoryForm.schema.ts | 8 +- .../form/ProductCategoryForm.tsx | 17 +- .../product/form/ProductForm.schema.ts | 65 +- .../master-data/product/form/ProductForm.tsx | 134 +- .../supplier/form/SupplierForm.schema.ts | 67 +- .../supplier/form/SupplierForm.tsx | 16 +- .../chickin/form/ChickinForm.schema.ts | 8 +- .../form/ProjectFlockForm.schema.ts | 3 +- .../project-flock/form/ProjectFlockForm.tsx | 19 +- .../form/ProjectFlockKandangTable.tsx | 7 +- .../recording/form/RecordingForm.tsx | 1403 +++++++++-------- .../TransferToLayingsTable.tsx | 18 +- src/services/api/base.ts | 11 +- src/services/api/master-data.ts | 2 +- src/services/api/production.ts | 2 +- src/types/api/master-data/customer.d.ts | 40 +- src/types/api/master-data/product.d.ts | 2 +- src/types/api/master-data/supplier.d.ts | 60 +- src/types/api/production/chickin.d.ts | 10 +- .../api/production/project-flock-kandang.d.ts | 8 +- 66 files changed, 1319 insertions(+), 1198 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 719cea2b..fa167c8d 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,6 +1,6 @@ -import { dirname } from "path"; -import { fileURLToPath } from "url"; -import { FlatCompat } from "@eslint/eslintrc"; +import { dirname } from 'path'; +import { fileURLToPath } from 'url'; +import { FlatCompat } from '@eslint/eslintrc'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); @@ -10,14 +10,14 @@ const compat = new FlatCompat({ }); const eslintConfig = [ - ...compat.extends("next/core-web-vitals", "next/typescript"), + ...compat.extends('next/core-web-vitals', 'next/typescript'), { ignores: [ - "node_modules/**", - ".next/**", - "out/**", - "build/**", - "next-env.d.ts", + 'node_modules/**', + '.next/**', + 'out/**', + 'build/**', + 'next-env.d.ts', ], }, ]; diff --git a/postcss.config.mjs b/postcss.config.mjs index c7bcb4b1..ba720fe5 100644 --- a/postcss.config.mjs +++ b/postcss.config.mjs @@ -1,5 +1,5 @@ const config = { - plugins: ["@tailwindcss/postcss"], + plugins: ['@tailwindcss/postcss'], }; export default config; diff --git a/src/app/globals.css b/src/app/globals.css index 97be6978..c3d05c67 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -3,10 +3,10 @@ @import '../styles/daisyui.css'; @plugin "daisyui/theme" { - name: "lti"; + name: 'lti'; default: false; prefersdark: false; - color-scheme: "light"; + color-scheme: 'light'; --color-base-100: oklch(98% 0.001 106.423); --color-base-200: oklch(97% 0.001 106.424); --color-base-300: oklch(92% 0.003 48.717); @@ -37,8 +37,6 @@ --noise: 0; } - - :root { --color-primary: #1f74bf; } diff --git a/src/app/inventory/adjustment/add/page.tsx b/src/app/inventory/adjustment/add/page.tsx index 3bd64573..e20eedfc 100644 --- a/src/app/inventory/adjustment/add/page.tsx +++ b/src/app/inventory/adjustment/add/page.tsx @@ -1,11 +1,11 @@ -import InventoryAdjustmentForm from "@/components/pages/inventory/adjustment/form/InventoryAdjustmentForm"; +import InventoryAdjustmentForm from '@/components/pages/inventory/adjustment/form/InventoryAdjustmentForm'; const CreateInventoryAdjustment = () => { return ( -
    - +
    +
    ); -} +}; -export default CreateInventoryAdjustment; \ No newline at end of file +export default CreateInventoryAdjustment; diff --git a/src/app/inventory/adjustment/detail/layout.tsx b/src/app/inventory/adjustment/detail/layout.tsx index b41c70f9..7220dfa1 100644 --- a/src/app/inventory/adjustment/detail/layout.tsx +++ b/src/app/inventory/adjustment/detail/layout.tsx @@ -1,11 +1,11 @@ -import SuspenseHelper from "@/components/helper/SuspenseHelper" +import SuspenseHelper from '@/components/helper/SuspenseHelper'; const Layout = ({ - children + children, }: Readonly<{ - children: React.ReactNode + children: React.ReactNode; }>) => { - return {children} -} + return {children}; +}; -export default Layout; \ No newline at end of file +export default Layout; diff --git a/src/app/inventory/adjustment/detail/page.tsx b/src/app/inventory/adjustment/detail/page.tsx index 5e96c86a..acb9f8db 100644 --- a/src/app/inventory/adjustment/detail/page.tsx +++ b/src/app/inventory/adjustment/detail/page.tsx @@ -7,11 +7,12 @@ import type { InventoryAdjustment } from '@/types/api/inventory/adjustment'; const DetailInventoryAdjustment = () => { const router = useRouter(); - const [inventoryAdjustment, setInventoryAdjustment] = useState(null); + const [inventoryAdjustment, setInventoryAdjustment] = + useState(null); // Ambil data dari router state useEffect(() => { - console.log("Router State"); + console.log('Router State'); console.log(window.history.state); const state = window.history.state?.usr as | { inventoryAdjustment?: InventoryAdjustment } @@ -24,20 +25,20 @@ const DetailInventoryAdjustment = () => { }, [router]); const finalData = inventoryAdjustment; - - console.log("Final Data"); + + console.log('Final Data'); console.log(finalData); if (!finalData) { return ( -
    - +
    +
    ); } return ( -
    +
    ); diff --git a/src/app/master-data/customer/add/page.tsx b/src/app/master-data/customer/add/page.tsx index a1096f02..dd75c679 100644 --- a/src/app/master-data/customer/add/page.tsx +++ b/src/app/master-data/customer/add/page.tsx @@ -1,11 +1,11 @@ -import CustomerForm from "@/components/pages/master-data/customer/form/CustomerForm"; +import CustomerForm from '@/components/pages/master-data/customer/form/CustomerForm'; const AddCustomer = () => { return ( -
    - +
    +
    ); -} +}; -export default AddCustomer; \ No newline at end of file +export default AddCustomer; diff --git a/src/app/master-data/customer/detail/page.tsx b/src/app/master-data/customer/detail/page.tsx index 263458c2..d778f83b 100644 --- a/src/app/master-data/customer/detail/page.tsx +++ b/src/app/master-data/customer/detail/page.tsx @@ -1,45 +1,47 @@ -'use client' +'use client'; -import { useRouter, useSearchParams } from "next/navigation"; -import useSWR from "swr"; +import { useRouter, useSearchParams } from 'next/navigation'; +import useSWR from 'swr'; import { CustomerApi } from '@/services/api/master-data'; -import { isResponseError, isResponseSuccess } from "@/lib/api-helper"; -import CustomerForm from "@/components/pages/master-data/customer/form/CustomerForm"; +import { isResponseError, isResponseSuccess } from '@/lib/api-helper'; +import CustomerForm from '@/components/pages/master-data/customer/form/CustomerForm'; const CustomerDetail = () => { const router = useRouter(); const searchParams = useSearchParams(); - const costumerId = searchParams.get("customerId"); + const costumerId = searchParams.get('customerId'); const { data: costumer, isLoading: isLoadingCostumer } = useSWR( costumerId, (id: number) => CustomerApi.getSingle(id) ); - if(!costumerId){ + if (!costumerId) { router.back(); return ( -
    - +
    +
    ); } - if(!isLoadingCostumer && (!costumer || isResponseError(costumer))){ - router.replace("/404"); + if (!isLoadingCostumer && (!costumer || isResponseError(costumer))) { + router.replace('/404'); return; } return ( -
    - {isLoadingCostumer && } +
    + {isLoadingCostumer && ( + + )} {!isLoadingCostumer && isResponseSuccess(costumer) && ( - + )}
    - ) + ); }; export default CustomerDetail; diff --git a/src/app/master-data/customer/page.tsx b/src/app/master-data/customer/page.tsx index b80401f1..8aec1088 100644 --- a/src/app/master-data/customer/page.tsx +++ b/src/app/master-data/customer/page.tsx @@ -1,11 +1,11 @@ -import CustomersTable from "@/components/pages/master-data/customer/CustomersTable"; +import CustomersTable from '@/components/pages/master-data/customer/CustomersTable'; const Customer = () => { return ( -
    +
    - ) + ); }; -export default Customer; \ No newline at end of file +export default Customer; diff --git a/src/app/master-data/flock/add/page.tsx b/src/app/master-data/flock/add/page.tsx index 5ee3958e..d038d414 100644 --- a/src/app/master-data/flock/add/page.tsx +++ b/src/app/master-data/flock/add/page.tsx @@ -1,11 +1,11 @@ -import FlockForm from "@/components/pages/master-data/flock/form/FlockForm"; +import FlockForm from '@/components/pages/master-data/flock/form/FlockForm'; const AddFlock = () => { return ( -
    +
    ); -} +}; export default AddFlock; diff --git a/src/app/master-data/flock/detail/edit/page.tsx b/src/app/master-data/flock/detail/edit/page.tsx index c9651727..babc6653 100644 --- a/src/app/master-data/flock/detail/edit/page.tsx +++ b/src/app/master-data/flock/detail/edit/page.tsx @@ -1,10 +1,10 @@ -'use client' +'use client'; -import FlockForm from "@/components/pages/master-data/flock/form/FlockForm"; -import { isResponseError, isResponseSuccess } from "@/lib/api-helper"; -import { FlockApi } from "@/services/api/master-data"; -import { useRouter, useSearchParams } from "next/navigation"; -import useSWR from "swr"; +import FlockForm from '@/components/pages/master-data/flock/form/FlockForm'; +import { isResponseError, isResponseSuccess } from '@/lib/api-helper'; +import { FlockApi } from '@/services/api/master-data'; +import { useRouter, useSearchParams } from 'next/navigation'; +import useSWR from 'swr'; const FlockEdit = () => { const router = useRouter(); @@ -44,6 +44,6 @@ const FlockEdit = () => { )}
    ); -} +}; -export default FlockEdit; \ No newline at end of file +export default FlockEdit; diff --git a/src/app/master-data/flock/detail/layout.tsx b/src/app/master-data/flock/detail/layout.tsx index b41c70f9..7220dfa1 100644 --- a/src/app/master-data/flock/detail/layout.tsx +++ b/src/app/master-data/flock/detail/layout.tsx @@ -1,11 +1,11 @@ -import SuspenseHelper from "@/components/helper/SuspenseHelper" +import SuspenseHelper from '@/components/helper/SuspenseHelper'; const Layout = ({ - children + children, }: Readonly<{ - children: React.ReactNode + children: React.ReactNode; }>) => { - return {children} -} + return {children}; +}; -export default Layout; \ No newline at end of file +export default Layout; diff --git a/src/app/master-data/flock/detail/page.tsx b/src/app/master-data/flock/detail/page.tsx index 8a805911..e9620d33 100644 --- a/src/app/master-data/flock/detail/page.tsx +++ b/src/app/master-data/flock/detail/page.tsx @@ -1,10 +1,10 @@ -'use client' +'use client'; -import FlockForm from "@/components/pages/master-data/flock/form/FlockForm"; -import { isResponseError, isResponseSuccess } from "@/lib/api-helper"; -import { FlockApi } from "@/services/api/master-data"; -import { useRouter, useSearchParams } from "next/navigation"; -import useSWR from "swr"; +import FlockForm from '@/components/pages/master-data/flock/form/FlockForm'; +import { isResponseError, isResponseSuccess } from '@/lib/api-helper'; +import { FlockApi } from '@/services/api/master-data'; +import { useRouter, useSearchParams } from 'next/navigation'; +import useSWR from 'swr'; const FlockDetail = () => { const router = useRouter(); @@ -14,33 +14,36 @@ const FlockDetail = () => { const flockId = searchParams.get('flockId'); // Fetch Data - const { data: flock, isLoading: isLoadingFlock } = useSWR(flockId, (id: number) => FlockApi.getSingle(id)); + const { data: flock, isLoading: isLoadingFlock } = useSWR( + flockId, + (id: number) => FlockApi.getSingle(id) + ); - if(!flockId){ + if (!flockId) { router.back(); return ( -
    - +
    +
    ); } - if(!isLoadingFlock && (!flock || isResponseError(flock))){ + if (!isLoadingFlock && (!flock || isResponseError(flock))) { router.replace('/404'); return; } return ( -
    +
    {isLoadingFlock && ( - + )} {!isLoadingFlock && isResponseSuccess(flock) && ( - + )}
    ); -} +}; -export default FlockDetail; \ No newline at end of file +export default FlockDetail; diff --git a/src/app/master-data/flock/page.tsx b/src/app/master-data/flock/page.tsx index b317091a..76cc32c1 100644 --- a/src/app/master-data/flock/page.tsx +++ b/src/app/master-data/flock/page.tsx @@ -1,11 +1,11 @@ -import FlockTable from "@/components/pages/master-data/flock/FlocksTable"; +import FlockTable from '@/components/pages/master-data/flock/FlocksTable'; const Flock = () => { return ( -
    - +
    +
    - ); -} + ); +}; export default Flock; diff --git a/src/app/master-data/product-category/add/page.tsx b/src/app/master-data/product-category/add/page.tsx index 0993ba7a..2331159e 100644 --- a/src/app/master-data/product-category/add/page.tsx +++ b/src/app/master-data/product-category/add/page.tsx @@ -1,11 +1,11 @@ -import ProductCategoryForm from "@/components/pages/master-data/product-category/form/ProductCategoryForm"; +import ProductCategoryForm from '@/components/pages/master-data/product-category/form/ProductCategoryForm'; const AddProductCategory = () => { return ( -
    +
    ); }; -export default AddProductCategory; \ No newline at end of file +export default AddProductCategory; diff --git a/src/app/master-data/product-category/detail/edit/page.tsx b/src/app/master-data/product-category/detail/edit/page.tsx index 6bc10644..4cb7eb5a 100644 --- a/src/app/master-data/product-category/detail/edit/page.tsx +++ b/src/app/master-data/product-category/detail/edit/page.tsx @@ -9,39 +9,44 @@ import { ProductCategoryApi } from '@/services/api/master-data'; import { isResponseError, isResponseSuccess } from '@/lib/api-helper'; const ProductCategoryEdit = () => { - const router = useRouter(); - const searchParams = useSearchParams(); + const router = useRouter(); + const searchParams = useSearchParams(); - const productCategoryId = searchParams.get('productCategoryId'); + const productCategoryId = searchParams.get('productCategoryId'); - const { data: productCategory, isLoading: isLoadingProductCategory } = useSWR( - productCategoryId, - (id: number) => ProductCategoryApi.getSingle(id) - ); + const { data: productCategory, isLoading: isLoadingProductCategory } = useSWR( + productCategoryId, + (id: number) => ProductCategoryApi.getSingle(id) + ); - if (!productCategoryId) { - router.back(); - - return ( -
    - -
    - ); - } - - if (!isLoadingProductCategory && (!productCategory || isResponseError(productCategory))) { - router.replace('/404'); - return; - } + if (!productCategoryId) { + router.back(); return ( -
    - {isLoadingProductCategory && } - {!isLoadingProductCategory && isResponseSuccess(productCategory) && ( - - )} -
    +
    + +
    ); -} + } -export default ProductCategoryEdit; \ No newline at end of file + if ( + !isLoadingProductCategory && + (!productCategory || isResponseError(productCategory)) + ) { + router.replace('/404'); + return; + } + + return ( +
    + {isLoadingProductCategory && ( + + )} + {!isLoadingProductCategory && isResponseSuccess(productCategory) && ( + + )} +
    + ); +}; + +export default ProductCategoryEdit; diff --git a/src/app/master-data/product-category/detail/page.tsx b/src/app/master-data/product-category/detail/page.tsx index cba06fdb..c1a21aaf 100644 --- a/src/app/master-data/product-category/detail/page.tsx +++ b/src/app/master-data/product-category/detail/page.tsx @@ -29,16 +29,24 @@ const ProductCategoryDetail = () => { ); } - if (!isLoadingProductCategory && (!productCategory || isResponseError(productCategory))) { + if ( + !isLoadingProductCategory && + (!productCategory || isResponseError(productCategory)) + ) { router.replace('/404'); return; } return (
    - {isLoadingProductCategory && } + {isLoadingProductCategory && ( + + )} {!isLoadingProductCategory && isResponseSuccess(productCategory) && ( - + )}
    ); diff --git a/src/app/master-data/product-category/page.tsx b/src/app/master-data/product-category/page.tsx index 5ec6d555..78a4fda3 100644 --- a/src/app/master-data/product-category/page.tsx +++ b/src/app/master-data/product-category/page.tsx @@ -1,11 +1,11 @@ -import ProductCategoryTable from "@/components/pages/master-data/product-category/ProductCategoryTable"; +import ProductCategoryTable from '@/components/pages/master-data/product-category/ProductCategoryTable'; const ProductCategory = () => { return ( -
    +
    ); }; -export default ProductCategory; \ No newline at end of file +export default ProductCategory; diff --git a/src/app/master-data/product/add/page.tsx b/src/app/master-data/product/add/page.tsx index 7cc995b6..37f42691 100644 --- a/src/app/master-data/product/add/page.tsx +++ b/src/app/master-data/product/add/page.tsx @@ -2,10 +2,10 @@ import ProductForm from '@/components/pages/master-data/product/form/ProductForm const AddProduct = () => { return ( -
    +
    ); }; -export default AddProduct; \ No newline at end of file +export default AddProduct; diff --git a/src/app/master-data/product/detail/edit/page.tsx b/src/app/master-data/product/detail/edit/page.tsx index 96cfdc42..8916a98e 100644 --- a/src/app/master-data/product/detail/edit/page.tsx +++ b/src/app/master-data/product/detail/edit/page.tsx @@ -13,9 +13,8 @@ const ProductEdit = () => { const productId = searchParams.get('productId'); - const { data: product, isLoading } = useSWR( - productId, - (id: number) => ProductApi.getSingle(id) + const { data: product, isLoading } = useSWR(productId, (id: number) => + ProductApi.getSingle(id) ); if (!productId) { @@ -42,4 +41,4 @@ const ProductEdit = () => { ); }; -export default ProductEdit; \ No newline at end of file +export default ProductEdit; diff --git a/src/app/master-data/product/detail/page.tsx b/src/app/master-data/product/detail/page.tsx index 916a44d0..34743e1f 100644 --- a/src/app/master-data/product/detail/page.tsx +++ b/src/app/master-data/product/detail/page.tsx @@ -13,9 +13,8 @@ const ProductDetail = () => { const productId = searchParams.get('productId'); - const { data: product, isLoading } = useSWR( - productId, - (id: number) => ProductApi.getSingle(id) + const { data: product, isLoading } = useSWR(productId, (id: number) => + ProductApi.getSingle(id) ); if (!productId) { @@ -42,4 +41,4 @@ const ProductDetail = () => { ); }; -export default ProductDetail; \ No newline at end of file +export default ProductDetail; diff --git a/src/app/master-data/product/page.tsx b/src/app/master-data/product/page.tsx index 6014aeb9..a385d411 100644 --- a/src/app/master-data/product/page.tsx +++ b/src/app/master-data/product/page.tsx @@ -1,11 +1,11 @@ -import ProductsTable from "@/components/pages/master-data/product/ProductTable"; +import ProductsTable from '@/components/pages/master-data/product/ProductTable'; const Product = () => { return ( -
    - +
    +
    ); }; -export default Product; \ No newline at end of file +export default Product; diff --git a/src/app/master-data/supplier/add/page.tsx b/src/app/master-data/supplier/add/page.tsx index 8a95c3c6..37df33b0 100644 --- a/src/app/master-data/supplier/add/page.tsx +++ b/src/app/master-data/supplier/add/page.tsx @@ -8,4 +8,4 @@ const AddSupplier = () => { ); }; -export default AddSupplier; \ No newline at end of file +export default AddSupplier; diff --git a/src/app/master-data/supplier/detail/page.tsx b/src/app/master-data/supplier/detail/page.tsx index 433fa043..a34ad72e 100644 --- a/src/app/master-data/supplier/detail/page.tsx +++ b/src/app/master-data/supplier/detail/page.tsx @@ -46,4 +46,4 @@ const SupplierDetail = () => { ); }; -export default SupplierDetail; \ No newline at end of file +export default SupplierDetail; diff --git a/src/app/master-data/supplier/page.tsx b/src/app/master-data/supplier/page.tsx index 1f54bd0d..8000be0a 100644 --- a/src/app/master-data/supplier/page.tsx +++ b/src/app/master-data/supplier/page.tsx @@ -1,4 +1,4 @@ -import SuppliersTable from "@/components/pages/master-data/supplier/SupplierTable"; +import SuppliersTable from '@/components/pages/master-data/supplier/SupplierTable'; const Supplier = () => { return ( diff --git a/src/app/production/chickin/add/layout.tsx b/src/app/production/chickin/add/layout.tsx index b41c70f9..7220dfa1 100644 --- a/src/app/production/chickin/add/layout.tsx +++ b/src/app/production/chickin/add/layout.tsx @@ -1,11 +1,11 @@ -import SuspenseHelper from "@/components/helper/SuspenseHelper" +import SuspenseHelper from '@/components/helper/SuspenseHelper'; const Layout = ({ - children + children, }: Readonly<{ - children: React.ReactNode + children: React.ReactNode; }>) => { - return {children} -} + return {children}; +}; -export default Layout; \ No newline at end of file +export default Layout; diff --git a/src/app/production/chickin/detail/layout.tsx b/src/app/production/chickin/detail/layout.tsx index b41c70f9..7220dfa1 100644 --- a/src/app/production/chickin/detail/layout.tsx +++ b/src/app/production/chickin/detail/layout.tsx @@ -1,11 +1,11 @@ -import SuspenseHelper from "@/components/helper/SuspenseHelper" +import SuspenseHelper from '@/components/helper/SuspenseHelper'; const Layout = ({ - children + children, }: Readonly<{ - children: React.ReactNode + children: React.ReactNode; }>) => { - return {children} -} + return {children}; +}; -export default Layout; \ No newline at end of file +export default Layout; diff --git a/src/app/production/chickin/detail/page.tsx b/src/app/production/chickin/detail/page.tsx index 96647c55..be8c5332 100644 --- a/src/app/production/chickin/detail/page.tsx +++ b/src/app/production/chickin/detail/page.tsx @@ -20,7 +20,7 @@ import useSWR from 'swr'; /** * TODO: Refactor code - pindahin detail ke reuseable component - * setelah implement approval and reject + * setelah implement approval and reject */ const DetailChickin = () => { @@ -43,9 +43,8 @@ const DetailChickin = () => { // chickin.data?.approval.step_number == 1 ? false : true true ); - const [isRejectedDisabled, setIsRejectedDisabled] = useState( - !isApprovedDisabled - ); + const [isRejectedDisabled, setIsRejectedDisabled] = + useState(!isApprovedDisabled); const [approvalAction, setApprovalAction] = useState<'APPROVED' | 'REJECTED'>( !isApprovedDisabled ? 'APPROVED' : 'REJECTED' ); @@ -264,7 +263,8 @@ const DetailChickin = () => { Delete -