From 69d7f65b7628dc4a273ca9330134ef3927b60166 Mon Sep 17 00:00:00 2001 From: rstubryan Date: Fri, 9 Jan 2026 12:31:53 +0700 Subject: [PATCH 1/4] refactor(FE): Disable sales tab and related data fetching --- src/app/closing/detail/page.tsx | 13 +++++++------ src/components/pages/closing/ClosingDetail.tsx | 10 +++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/app/closing/detail/page.tsx b/src/app/closing/detail/page.tsx index 62f3fa20..f3a78d9d 100644 --- a/src/app/closing/detail/page.tsx +++ b/src/app/closing/detail/page.tsx @@ -19,10 +19,10 @@ const ClosingDetailPage = () => { (id: number) => ClosingApi.getGeneralInfo(id) ); - const { data: salesData, isLoading: isLoadingSales } = useSWR( - closingId ? `sales-${closingId}` : null, - () => ClosingApi.getPenjualan(Number(closingId)) - ); + // const { data: salesData, isLoading: isLoadingSales } = useSWR( + // closingId ? `sales-${closingId}` : null, + // () => ClosingApi.getPenjualan(Number(closingId)) + // ); const { data: hppEkspedisiData, isLoading: isLoadingHppEkspedisi } = useSWR( closingId ? `hpp-ekspedisi-${closingId}` : null, @@ -44,7 +44,8 @@ const ClosingDetailPage = () => { return; } - const isLoading = isLoadingClosing || isLoadingSales || isLoadingHppEkspedisi; + const isLoading = isLoadingClosing || isLoadingHppEkspedisi; + // const isLoading = isLoadingClosing || isLoadingSales || isLoadingHppEkspedisi; return (
@@ -54,7 +55,7 @@ const ClosingDetailPage = () => { = ({ /> ), }, - { - id: 'penjualan', - label: 'Penjualan', - content: , - }, + // { + // id: 'penjualan', + // label: 'Penjualan', + // content: , + // }, { id: 'overhead', label: 'Overhead', From 4fc689898f826caae9ad9cde94d6f5e51fc735d2 Mon Sep 17 00:00:00 2001 From: rstubryan Date: Fri, 9 Jan 2026 12:33:21 +0700 Subject: [PATCH 2/4] refactor(FE): Use optional chaining for summary_hpp fields --- .../pages/closing/ClosingFinanceTable.tsx | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/components/pages/closing/ClosingFinanceTable.tsx b/src/components/pages/closing/ClosingFinanceTable.tsx index 9d0c92d6..b0b22a08 100644 --- a/src/components/pages/closing/ClosingFinanceTable.tsx +++ b/src/components/pages/closing/ClosingFinanceTable.tsx @@ -217,8 +217,8 @@ const ClosingFinanceTable = ({ return props.column.id === 'budgeting_rp_per_bird' && isResponseSuccess(finance) ? formatCurrency( - finance.data.hpp_purchases.summary_hpp.budgeting - .rp_per_bird || 0 + finance.data.hpp_purchases.summary_hpp?.budgeting + ?.rp_per_bird || 0 ) : '-'; }, @@ -233,8 +233,8 @@ const ClosingFinanceTable = ({ return props.column.id === 'budgeting_rp_per_kg' && isResponseSuccess(finance) ? formatCurrency( - finance.data.hpp_purchases.summary_hpp.budgeting - .rp_per_kg || 0 + finance.data.hpp_purchases.summary_hpp?.budgeting + ?.rp_per_kg || 0 ) : '-'; }, @@ -249,8 +249,8 @@ const ClosingFinanceTable = ({ return props.column.id === 'budgeting_amount' && isResponseSuccess(finance) ? formatCurrency( - finance.data.hpp_purchases.summary_hpp.budgeting - .amount || 0 + finance.data.hpp_purchases.summary_hpp?.budgeting + ?.amount || 0 ) : '-'; }, @@ -271,8 +271,8 @@ const ClosingFinanceTable = ({ return props.column.id === 'realization_rp_per_bird' && isResponseSuccess(finance) ? formatCurrency( - finance.data.hpp_purchases.summary_hpp.realization - .rp_per_bird || 0 + finance.data.hpp_purchases.summary_hpp + ?.realization?.rp_per_bird || 0 ) : '-'; }, @@ -287,8 +287,8 @@ const ClosingFinanceTable = ({ return props.column.id === 'realization_rp_per_kg' && isResponseSuccess(finance) ? formatCurrency( - finance.data.hpp_purchases.summary_hpp.realization - .rp_per_kg || 0 + finance.data.hpp_purchases.summary_hpp + ?.realization?.rp_per_kg || 0 ) : '-'; }, @@ -303,8 +303,8 @@ const ClosingFinanceTable = ({ return props.column.id === 'realization_amount' && isResponseSuccess(finance) ? formatCurrency( - finance.data.hpp_purchases.summary_hpp.realization - .amount || 0 + finance.data.hpp_purchases.summary_hpp + ?.realization?.amount || 0 ) : '-'; }, From 7951754722d9e66195de90ec4ff0dc91823daac1 Mon Sep 17 00:00:00 2001 From: rstubryan Date: Fri, 9 Jan 2026 12:46:19 +0700 Subject: [PATCH 3/4] refactor(FE): Generate HPP table from static rows with defaults --- .../pages/closing/ClosingFinanceTable.tsx | 136 +++++++++++++++--- 1 file changed, 118 insertions(+), 18 deletions(-) diff --git a/src/components/pages/closing/ClosingFinanceTable.tsx b/src/components/pages/closing/ClosingFinanceTable.tsx index b0b22a08..8c39b3fb 100644 --- a/src/components/pages/closing/ClosingFinanceTable.tsx +++ b/src/components/pages/closing/ClosingFinanceTable.tsx @@ -23,6 +23,14 @@ type HppTableRow = type?: never; budgeting?: never; realization?: never; + } + | { + type: string; + group_name: string; + group_index: number; + isGroupHeader: false; + budgeting?: { rp_per_bird: number; rp_per_kg: number; amount: number }; + realization?: { rp_per_bird: number; rp_per_kg: number; amount: number }; }; type ProfitLossTableRow = @@ -52,25 +60,117 @@ const ClosingFinanceTable = ({ () => ClosingApi.getFinance(projectFlockId) ); - const hppTableData: HppTableRow[] = isResponseSuccess(finance) - ? finance.data.hpp_purchases.hpp.flatMap((hpp, groupIndex) => [ - // Group header row - { - group_name: hpp.group_name, - group_index: groupIndex, - isGroupHeader: true as const, - }, - // Data rows - ...hpp.data.map((item) => ({ - group_name: hpp.group_name, - group_index: groupIndex, - type: item.type, - budgeting: item.budgeting, - realization: item.realization, + const staticHppRows: Array<{ + group_name: string; + type: string; + group_index: number; + }> = [ + { + group_name: 'HPP dan Pengeluaran', + type: 'Pembelian PAKAN', + group_index: 0, + }, + { + group_name: 'HPP dan Pengeluaran', + type: 'Pembelian STARTER', + group_index: 0, + }, + { + group_name: 'HPP dan Pengeluaran', + type: 'Pembelian DOC', + group_index: 0, + }, + { + group_name: 'HPP dan Pengeluaran', + type: 'Pembelian PULLET', + group_index: 0, + }, + { + group_name: 'HPP dan Pengeluaran', + type: 'Pembelian LAYER', + group_index: 0, + }, + { + group_name: 'HPP dan Bahan Baku', + type: 'Pengeluaran Overhead', + group_index: 1, + }, + { + group_name: 'HPP dan Bahan Baku', + type: 'Beban Ekspedisi', + group_index: 1, + }, + ]; + + const hppTableData: HppTableRow[] = [ + { + group_name: 'HPP dan Pengeluaran', + group_index: 0, + isGroupHeader: true as const, + }, + ...staticHppRows + .filter((row) => row.group_index === 0) + .map((staticRow) => { + const apiData = isResponseSuccess(finance) + ? finance.data.hpp_purchases.hpp + .find((g) => g.group_name === staticRow.group_name) + ?.data.find((d) => d.type === staticRow.type) + : null; + + return { + group_name: staticRow.group_name, + group_index: staticRow.group_index, + type: staticRow.type, + budgeting: apiData?.budgeting || { + rp_per_bird: 0, + rp_per_kg: 0, + amount: 0, + }, + realization: apiData?.realization || { + rp_per_bird: 0, + rp_per_kg: 0, + amount: 0, + }, isGroupHeader: false as const, - })), - ]) - : []; + }; + }), + { + group_name: 'HPP dan Bahan Baku', + group_index: 1, + isGroupHeader: true as const, + }, + ...staticHppRows + .filter((row) => row.group_index === 1) + .map((staticRow) => { + const apiData = isResponseSuccess(finance) + ? finance.data.hpp_purchases.hpp + .find((g) => g.group_name === staticRow.group_name) + ?.data.find((d) => d.type === staticRow.type) + : null; + + return { + group_name: staticRow.group_name, + group_index: staticRow.group_index, + type: staticRow.type, + budgeting: apiData?.budgeting || { + rp_per_bird: 0, + rp_per_kg: 0, + amount: 0, + }, + realization: apiData?.realization || { + rp_per_bird: 0, + rp_per_kg: 0, + amount: 0, + }, + isGroupHeader: false as const, + }; + }), + { + group_name: 'HPP', + group_index: 2, + isGroupHeader: true as const, + }, + ]; const profitLossTableData: ProfitLossTableRow[] = isResponseSuccess(finance) ? [ From f38cebc0d9ca66ae95991ad6985e44c077124288 Mon Sep 17 00:00:00 2001 From: rstubryan Date: Fri, 9 Jan 2026 13:02:20 +0700 Subject: [PATCH 4/4] refactor(FE): Limit Location select options to 100 --- .../pages/production/uniformity/UniformityTable.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/pages/production/uniformity/UniformityTable.tsx b/src/components/pages/production/uniformity/UniformityTable.tsx index 6afba6dc..63c446ac 100644 --- a/src/components/pages/production/uniformity/UniformityTable.tsx +++ b/src/components/pages/production/uniformity/UniformityTable.tsx @@ -236,7 +236,9 @@ const UniformityTable = () => { setInputValue: setFilterLocationInputValue, options: filterLocationOptions, isLoadingOptions: isLoadingFilterLocations, - } = useSelect(LocationApi.basePath, 'id', 'name', 'search'); + } = useSelect(LocationApi.basePath, 'id', 'name', 'search', { + limit: '100', + }); // ===== FETCH PROJECT FLOCKS DATA FOR FILTER ===== const filterProjectFlocksUrl = useMemo(() => { @@ -308,6 +310,7 @@ const UniformityTable = () => { project_flock_id: filterProjectFlock.value.toString(), kandang_id: filterKandang.value.toString(), withpopulation: Boolean(true).toString(), + limit: '100', }); return `${ProjectFlockApi.basePath}/kandangs/lookup?${params.toString()}`; }, [filterProjectFlock, filterKandang]);