update for filter transaction
This commit is contained in:
@ -16,7 +16,6 @@ const ListToolbar = () => {
|
||||
|
||||
// Set the initial state for trxDate
|
||||
const [trxDate, settrxDate] = useState({ from: '', to: '' });
|
||||
|
||||
const [statusApproval, setStatusApproval] = useState<string>(
|
||||
(table.getColumn('status_approve')?.getFilterValue() as string) ?? ''
|
||||
);
|
||||
@ -139,7 +138,9 @@ const ListToolbar = () => {
|
||||
const today = new Date();
|
||||
const firstDayOfMonth = new Date(today.getFullYear(), today.getMonth(), 1);
|
||||
|
||||
// Resetting all filters
|
||||
setSearchValue('');
|
||||
setStatusApproval('');
|
||||
settrxDate({
|
||||
from: formatDate(firstDayOfMonth),
|
||||
to: formatDate(today),
|
||||
@ -149,7 +150,7 @@ const ListToolbar = () => {
|
||||
table.getColumn('status_approve')?.setFilterValue('');
|
||||
table.setPageIndex(0);
|
||||
|
||||
reload();
|
||||
reload(); // Reload table data
|
||||
}}
|
||||
>
|
||||
<KeenIcon icon="arrows-circle" />
|
||||
@ -159,7 +160,6 @@ const ListToolbar = () => {
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
export default ListToolbar;
|
||||
|
||||
@ -164,9 +164,11 @@ const ListToolbar = () => {
|
||||
variant="outline"
|
||||
className="h-7.5"
|
||||
onClick={() => {
|
||||
// Preserve trxDate values (from, to) and reset others
|
||||
const today = new Date();
|
||||
const firstDayOfMonth = new Date(today.getFullYear(), today.getMonth(), 1);
|
||||
|
||||
// Only reset filters excluding from and to
|
||||
setSearchValue('');
|
||||
setStatusValue('');
|
||||
setTypeValue('');
|
||||
@ -175,6 +177,7 @@ const ListToolbar = () => {
|
||||
to: formatDate(today),
|
||||
});
|
||||
|
||||
// Reset other filters except for date range
|
||||
table.setColumnFilters([
|
||||
{ id: 'code', value: '' },
|
||||
{ id: 'status', value: '' },
|
||||
|
||||
Reference in New Issue
Block a user