diff --git a/src/apps/admin/index.tsx b/src/apps/admin/index.tsx index 2009112..503912a 100644 --- a/src/apps/admin/index.tsx +++ b/src/apps/admin/index.tsx @@ -9,13 +9,17 @@ import { v4 } from 'uuid'; export default function Admin() { const [dataItem, setDataItem] = useState([]); - const [dataItemMaster, setDataItemMaster] = useState([]); - const [dataItemKeys, setDataItemKeys] = useState([]); - const [dataItemMasterKeys, setDataItemMasterKeys] = useState([]); - const [loadingDataItem, setLoadingDataItem] = useState(false); + const [dataItemTotalPax, setDataItemTotalPax] = useState(0); + const [dataItemTotalRevenue, setDataItemTotalRevenue] = useState(0); + + const [dataItemMaster, setDataItemMaster] = useState([]); + const [dataItemMasterKeys, setDataItemMasterKeys] = useState([]); const [loadingDataItemMaster, setLoadingDataItemMaster] = useState(false); + const [dataItemMasterTotalPax, setDataItemMasterTotalPax] = useState(0); + const [dataItemMasterTotalRevenue, setDataItemMasterTotalRevenue] = useState(0); + const [filterDate, setFilerDate] = useState(dayjs()); async function getDataItem(params: any) { @@ -44,6 +48,11 @@ export default function Admin() { }; }); + const totalPax = lodash.sumBy(data, (item: any) => Number(item.tr_item__qty)); + const totalRevenue = lodash.sumBy(data, (item: any) => Number(item.tr_item__total_net_price)); + setDataItemTotalPax(totalPax); + setDataItemTotalRevenue(totalRevenue); + setDataItemKeys(groupedData.map((item) => item.key)); setDataItem(groupedData); }) @@ -88,6 +97,11 @@ export default function Admin() { }; }); + const totalPax = lodash.sumBy(data, (item: any) => Number(item.tr_item__qty)); + const totalRevenue = lodash.sumBy(data, (item: any) => Number(item.tr_item_bundling__total_net_price)); + setDataItemMasterTotalPax(totalPax); + setDataItemMasterTotalRevenue(totalRevenue); + setDataItemMasterKeys(groupedData.map((item) => item.key)); setDataItemMaster(groupedData); }) @@ -116,7 +130,7 @@ export default function Admin() {
- -
Pendapatan Per Item
-
{`Laporan pendapatan item per tanggal ${filterDate.format('DD-MM-YYYY')}`}
- - } - > - child.key} // Make sure each child row has a unique key - expandable={{ expandedRowKeys: dataItemKeys, showExpandColumn: false }} - rowClassName={(row) => (row.key ? 'row-group' : '')} - rowHoverable={false} - columns={[ - { key: 'title', dataIndex: 'title', title: 'TITLE', width: 170 }, - { key: 'tr_item__qty', dataIndex: 'tr_item__qty', title: 'PAX', width: 70 }, - { - key: 'tr_item__total_net_price', - dataIndex: 'tr_item__total_net_price', - title: 'REVENUE', - width: 120, - render: (value) => currencyFormatter({ value }), - }, - ]} - /> - -
- -
Pendapatan Per Item Master
-
{`Laporan pendapatan item master per tanggal ${filterDate.format('DD-MM-YYYY')}`}
- - } - > -
child.key} // Make sure each child row has a unique key - expandable={{ expandedRowKeys: dataItemMasterKeys, showExpandColumn: false }} - rowClassName={(row) => (row.key ? 'row-group' : '')} - rowHoverable={false} - columns={[ - { key: 'title', dataIndex: 'title', title: 'TITLE', width: 170 }, + + + +
Pendapatan Per Item
+
{`Laporan pendapatan item per tanggal ${filterDate.format('DD-MM-YYYY')}`}
+ + } + > + +
+ +
+
TOTAL PAX
+
{dataItemTotalPax}
+
+
+ + + +
+
TOTAL REVENUE
+
+ {currencyFormatter({ value: dataItemTotalRevenue })} +
+
+
+ + +
+
child.key} // Make sure each child row has a unique key + expandable={{ expandedRowKeys: dataItemKeys, showExpandColumn: false }} + rowClassName={(row) => (row.key ? 'row-group' : '')} + rowHoverable={false} + columns={[ + { key: 'title', dataIndex: 'title', title: 'TITLE', width: 170 }, + { key: 'tr_item__qty', dataIndex: 'tr_item__qty', title: 'PAX', width: 70 }, + { + key: 'tr_item__total_net_price', + dataIndex: 'tr_item__total_net_price', + title: 'REVENUE', + width: 120, + render: (value) => currencyFormatter({ value }), + }, + ]} + /> + + + + +
Pendapatan Per Item Master
+
{`Laporan pendapatan item master per tanggal ${filterDate.format('DD-MM-YYYY')}`}
+ + } + > + +
+ +
+
TOTAL PAX
+
+ {dataItemMasterTotalPax} +
+
+
+ + + +
+
TOTAL REVENUE
+
+ {currencyFormatter({ value: dataItemMasterTotalRevenue })} +
+
+
+ + +
+
child.key} // Make sure each child row has a unique key + expandable={{ expandedRowKeys: dataItemMasterKeys, showExpandColumn: false }} + rowClassName={(row) => (row.key ? 'row-group' : '')} + rowHoverable={false} + columns={[ + { key: 'title', dataIndex: 'title', title: 'TITLE', width: 170 }, - { key: 'tr_item__qty', dataIndex: 'tr_item__qty', title: 'PAX', width: 70 }, - { - key: 'tr_item_bundling__total_net_price', - dataIndex: 'tr_item_bundling__total_net_price', - title: 'REVENUE', - width: 120, - render: (value) => currencyFormatter({ value }), - }, - ]} - /> - + { key: 'tr_item__qty', dataIndex: 'tr_item__qty', title: 'PAX', width: 70 }, + { + key: 'tr_item_bundling__total_net_price', + dataIndex: 'tr_item_bundling__total_net_price', + title: 'REVENUE', + width: 120, + render: (value) => currencyFormatter({ value }), + }, + ]} + /> + + + ); }