mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-23 23:05:46 +00:00
feat(FE-334): Use column footers and fix closing loading check
This commit is contained in:
@@ -51,11 +51,9 @@ const ClosingDetailPage = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!isLoading ||
|
!isLoadingClosing &&
|
||||||
!closing ||
|
(!closing || isResponseError(closing)) &&
|
||||||
isResponseError(closing) ||
|
(!hpp_ekspedisi || isResponseError(hpp_ekspedisi))
|
||||||
!hpp_ekspedisi ||
|
|
||||||
isResponseError(hpp_ekspedisi)
|
|
||||||
) {
|
) {
|
||||||
router.replace('/404');
|
router.replace('/404');
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -15,10 +15,6 @@ interface CosExpeditionReportTableProps {
|
|||||||
initialValues?: BaseClosingCosExpedition;
|
initialValues?: BaseClosingCosExpedition;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface FooterCosExpeditionRow extends BaseCosExpedition {
|
|
||||||
_isFooter: true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const CosExpeditionReportTable = ({
|
const CosExpeditionReportTable = ({
|
||||||
type = 'detail',
|
type = 'detail',
|
||||||
initialValues,
|
initialValues,
|
||||||
@@ -44,19 +40,6 @@ const CosExpeditionReportTable = ({
|
|||||||
};
|
};
|
||||||
}, [cosExpeditionData]);
|
}, [cosExpeditionData]);
|
||||||
|
|
||||||
const footerData = useMemo((): FooterCosExpeditionRow[] => {
|
|
||||||
if (cosExpeditionData.length === 0) return [];
|
|
||||||
|
|
||||||
const footerRow: FooterCosExpeditionRow = {
|
|
||||||
id: -999,
|
|
||||||
expedition_name: 'Total HPP Ekspedisi',
|
|
||||||
hpp: totals.totalHpp,
|
|
||||||
_isFooter: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
return [footerRow];
|
|
||||||
}, [cosExpeditionData, totals]);
|
|
||||||
|
|
||||||
const cosExpeditionColumns: ColumnDef<BaseCosExpedition>[] = useMemo(
|
const cosExpeditionColumns: ColumnDef<BaseCosExpedition>[] = useMemo(
|
||||||
() => [
|
() => [
|
||||||
{
|
{
|
||||||
@@ -64,28 +47,17 @@ const CosExpeditionReportTable = ({
|
|||||||
accessorKey: 'id',
|
accessorKey: 'id',
|
||||||
header: 'No',
|
header: 'No',
|
||||||
cell: (props) => {
|
cell: (props) => {
|
||||||
const isFooter = '_isFooter' in props.row.original;
|
return <div>{props.row.index + 1}</div>;
|
||||||
if (isFooter) {
|
|
||||||
return (
|
|
||||||
<div className='font-semibold text-gray-900 col-span-2'>
|
|
||||||
{props.row.original.expedition_name}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return props.getValue() || '-';
|
|
||||||
},
|
},
|
||||||
|
footer: () => (
|
||||||
|
<div className='font-semibold text-gray-900'>Total HPP Ekspedisi</div>
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'expedition_name',
|
id: 'expedition_name',
|
||||||
accessorKey: 'expedition_name',
|
accessorKey: 'expedition_name',
|
||||||
header: 'Nama Ekspedisi',
|
header: 'Nama Ekspedisi',
|
||||||
cell: (props) => {
|
cell: (props) => props.getValue() || '-',
|
||||||
const isFooter = '_isFooter' in props.row.original;
|
|
||||||
if (isFooter) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return props.getValue() || '-';
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'hpp',
|
id: 'hpp',
|
||||||
@@ -93,22 +65,16 @@ const CosExpeditionReportTable = ({
|
|||||||
header: 'HPP Ekspedisi',
|
header: 'HPP Ekspedisi',
|
||||||
cell: (props) => {
|
cell: (props) => {
|
||||||
const value = props.getValue() as number;
|
const value = props.getValue() as number;
|
||||||
const isFooter = '_isFooter' in props.row.original;
|
return <div className='text-right'>{formatCurrency(value)}</div>;
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className={
|
|
||||||
isFooter
|
|
||||||
? 'text-right font-semibold text-gray-900'
|
|
||||||
: 'text-right'
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{formatCurrency(value)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
footer: () => (
|
||||||
|
<div className='text-right font-semibold text-gray-900'>
|
||||||
|
{formatCurrency(totals.totalHpp)}
|
||||||
|
</div>
|
||||||
|
),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[]
|
[totals]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -125,7 +91,6 @@ const CosExpeditionReportTable = ({
|
|||||||
<Table
|
<Table
|
||||||
data={cosExpeditionData}
|
data={cosExpeditionData}
|
||||||
columns={cosExpeditionColumns}
|
columns={cosExpeditionColumns}
|
||||||
footerData={footerData}
|
|
||||||
renderFooter={cosExpeditionData.length > 0}
|
renderFooter={cosExpeditionData.length > 0}
|
||||||
className={{
|
className={{
|
||||||
tableWrapperClassName: 'overflow-x-auto',
|
tableWrapperClassName: 'overflow-x-auto',
|
||||||
|
|||||||
Reference in New Issue
Block a user