mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-06-21 21:58:44 +00:00
feat: add date range, filter by, and warehouse filter to marketing table
- Add start_date and end_date range inputs to the marketing filter modal with validation that prevents end date from being earlier than start date - Add 'Filter Berdasarkan' single-select radio (so_date / created_at) to let users choose which date field the range applies to - Add single-select Gudang (warehouse) filter backed by WarehouseApi, serialized as warehouse_id query param - Wire all three new filters into useTableFilter (paramMap, persist, excludeKeysFromUrl for label-only fields) and propagate through filterSubmitHandler, filterResetHandler, and marketingFilterInitialValues so filter state survives page refreshes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -203,6 +203,12 @@ const MarketingTable = () => {
|
||||
project_flock_name: '',
|
||||
project_flock_kandang_id: '',
|
||||
project_flock_kandang_name: '',
|
||||
warehouse_id: '',
|
||||
warehouse_name: '',
|
||||
start_date: '',
|
||||
end_date: '',
|
||||
filter_by: '',
|
||||
filter_by_name: '',
|
||||
sort_by: '',
|
||||
order_by: '',
|
||||
},
|
||||
@@ -214,6 +220,10 @@ const MarketingTable = () => {
|
||||
customer_id: 'customer_id',
|
||||
project_flock_id: 'project_flock_id',
|
||||
project_flock_kandang_id: 'project_flock_kandang_id',
|
||||
warehouse_id: 'warehouse_id',
|
||||
start_date: 'start_date',
|
||||
end_date: 'end_date',
|
||||
filter_by: 'filter_by',
|
||||
sort_by: 'sort_by',
|
||||
order_by: 'sort_order',
|
||||
},
|
||||
@@ -223,6 +233,8 @@ const MarketingTable = () => {
|
||||
'customer_name',
|
||||
'project_flock_name',
|
||||
'project_flock_kandang_name',
|
||||
'warehouse_name',
|
||||
'filter_by_name',
|
||||
],
|
||||
|
||||
persist: true,
|
||||
@@ -293,6 +305,16 @@ const MarketingTable = () => {
|
||||
values.project_flock_kandang_name ?? '',
|
||||
true
|
||||
);
|
||||
updateFilter(
|
||||
'warehouse_id',
|
||||
values.warehouse_id ? values.warehouse_id.toString() : '',
|
||||
true
|
||||
);
|
||||
updateFilter('warehouse_name', values.warehouse_name ?? '', true);
|
||||
updateFilter('start_date', values.start_date ?? '', true);
|
||||
updateFilter('end_date', values.end_date ?? '', true);
|
||||
updateFilter('filter_by', values.filter_by ?? '', true);
|
||||
updateFilter('filter_by_name', values.filter_by_name ?? '', true);
|
||||
};
|
||||
|
||||
const [isLoadingExportingToExcel, setIsLoadingExportingToExcel] =
|
||||
@@ -311,6 +333,12 @@ const MarketingTable = () => {
|
||||
updateFilter('project_flock_name', '', true);
|
||||
updateFilter('project_flock_kandang_id', '', true);
|
||||
updateFilter('project_flock_kandang_name', '', true);
|
||||
updateFilter('warehouse_id', '', true);
|
||||
updateFilter('warehouse_name', '', true);
|
||||
updateFilter('start_date', '', true);
|
||||
updateFilter('end_date', '', true);
|
||||
updateFilter('filter_by', '', true);
|
||||
updateFilter('filter_by_name', '', true);
|
||||
};
|
||||
|
||||
const approveClickHandler = () => {
|
||||
@@ -433,6 +461,20 @@ const MarketingTable = () => {
|
||||
label: tableFilterState.project_flock_kandang_name,
|
||||
}
|
||||
: null,
|
||||
warehouse: tableFilterState.warehouse_id
|
||||
? {
|
||||
value: Number(tableFilterState.warehouse_id),
|
||||
label: tableFilterState.warehouse_name,
|
||||
}
|
||||
: null,
|
||||
start_date: tableFilterState.start_date,
|
||||
end_date: tableFilterState.end_date,
|
||||
filter_by: tableFilterState.filter_by
|
||||
? {
|
||||
value: tableFilterState.filter_by,
|
||||
label: tableFilterState.filter_by_name,
|
||||
}
|
||||
: null,
|
||||
};
|
||||
|
||||
const approveMarketingHandler = async (notes: string) => {
|
||||
@@ -707,7 +749,7 @@ const MarketingTable = () => {
|
||||
},
|
||||
{
|
||||
accessorKey: 'so_date',
|
||||
header: 'Tanggal',
|
||||
header: 'Tanggal SO',
|
||||
cell: (props) => {
|
||||
return formatDate(props.row.original.so_date, 'DD MMM yyyy');
|
||||
},
|
||||
@@ -753,18 +795,17 @@ const MarketingTable = () => {
|
||||
cell: (props) => props.row.original.customer.name,
|
||||
},
|
||||
{
|
||||
accessorKey: 'grand_total',
|
||||
accessorFn: (row) =>
|
||||
row.sales_order
|
||||
?.map((product) => product.total_price)
|
||||
.reduce((a, b) => a + b, 0) ?? 0,
|
||||
header: 'Grand Total',
|
||||
accessorKey: 'grand_total_so',
|
||||
header: 'Grand Total SO',
|
||||
cell: (props) => {
|
||||
return formatCurrency(
|
||||
props.row.original?.sales_order
|
||||
?.map((product) => product.total_price)
|
||||
.reduce((a, b) => a + b, 0) ?? 0
|
||||
);
|
||||
return formatCurrency(props.row.original?.grand_total_so);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: 'grand_total_do',
|
||||
header: 'Grand Total DO',
|
||||
cell: (props) => {
|
||||
return formatCurrency(props.row.original?.grand_total_do);
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -911,6 +952,8 @@ const MarketingTable = () => {
|
||||
'customer_name',
|
||||
'project_flock_name',
|
||||
'project_flock_kandang_name',
|
||||
'warehouse_name',
|
||||
'filter_by_name',
|
||||
'sort_by',
|
||||
'order_by',
|
||||
]}
|
||||
|
||||
Reference in New Issue
Block a user