refactor(FE): Enable sales tab and fetch sales data

This commit is contained in:
rstubryan
2026-01-12 14:30:34 +07:00
parent def2167803
commit 90eef08f9b
3 changed files with 34 additions and 34 deletions
+5 -5
View File
@@ -19,10 +19,10 @@ const ClosingDetailPage = () => {
(id: number) => ClosingApi.getGeneralInfo(id) (id: number) => ClosingApi.getGeneralInfo(id)
); );
// const { data: salesData, isLoading: isLoadingSales } = useSWR( const { data: salesData, isLoading: isLoadingSales } = useSWR(
// closingId ? `sales-${closingId}` : null, closingId ? `sales-${closingId}` : null,
// () => ClosingApi.getPenjualan(Number(closingId)) () => ClosingApi.getPenjualan(Number(closingId))
// ); );
const { data: hppEkspedisiData, isLoading: isLoadingHppEkspedisi } = useSWR( const { data: hppEkspedisiData, isLoading: isLoadingHppEkspedisi } = useSWR(
closingId ? `hpp-ekspedisi-${closingId}` : null, closingId ? `hpp-ekspedisi-${closingId}` : null,
@@ -55,7 +55,7 @@ const ClosingDetailPage = () => {
<ClosingDetail <ClosingDetail
id={Number(closingId)} id={Number(closingId)}
initialValue={closing.data} initialValue={closing.data}
// salesData={isResponseSuccess(salesData) ? salesData.data : undefined} salesData={isResponseSuccess(salesData) ? salesData.data : undefined}
hppExpeditionData={ hppExpeditionData={
isResponseSuccess(hppEkspedisiData) isResponseSuccess(hppEkspedisiData)
? hppEkspedisiData.data ? hppEkspedisiData.data
@@ -52,11 +52,11 @@ const ClosingDetail: React.FC<ClosingDetailProps> = ({
/> />
), ),
}, },
// { {
// id: 'penjualan', id: 'penjualan',
// label: 'Penjualan', label: 'Penjualan',
// content: <SalesReportTable initialValues={salesData} />, content: <SalesReportTable initialValues={salesData} />,
// }, },
{ {
id: 'overhead', id: 'overhead',
label: 'Overhead', label: 'Overhead',
@@ -215,31 +215,31 @@ const SalesReportTable = ({
return kandang?.name || '-'; return kandang?.name || '-';
}, },
}, },
{ // {
id: 'payment_status', // id: 'payment_status',
accessorKey: 'payment_status', // accessorKey: 'payment_status',
header: 'Status Pembayaran', // header: 'Status Pembayaran',
cell: (props) => { // cell: (props) => {
const status = props.getValue() as string; // const status = props.getValue() as string;
const getStatusColor = (status: string) => { // const getStatusColor = (status: string) => {
if (!status) return 'neutral'; // if (!status) return 'neutral';
switch (status.toLowerCase()) { // switch (status.toLowerCase()) {
case 'paid': // case 'paid':
return 'success'; // return 'success';
case 'tempo': // case 'tempo':
return 'warning'; // return 'warning';
default: // default:
return 'neutral'; // return 'neutral';
} // }
}; // };
return ( // return (
<Badge variant='soft' size='sm' color={getStatusColor(status)}> // <Badge variant='soft' size='sm' color={getStatusColor(status)}>
{status || '-'} // {status || '-'}
</Badge> // </Badge>
); // );
}, // },
}, // },
], ],
[] []
); );