This commit is contained in:
unknown
2025-06-02 17:36:53 +07:00
2 changed files with 34 additions and 5 deletions

View File

@ -23,6 +23,10 @@ const ListToolbar = () => {
(table.getState().columnFilters.find(f => f.id === 'kind')?.value as string) ?? ''
);
const [status, setStatus] = useState<string>(
(table.getState().columnFilters.find(f => f.id === 'status')?.value as string) ?? ''
);
const { GetData } = useCallApi();
const API_URL = apiConfig.transaction;
@ -50,24 +54,25 @@ const ListToolbar = () => {
table.getColumn('transaction_date')?.setFilterValue(trxDate);
table.setColumnFilters((prev) => {
const others = prev.filter(f => f.id !== 'kind' && f.id !== 'searchtype' && f.id !== 'code');
const others = prev.filter(f => f.id !== 'kind' && f.id !== 'searchtype' && f.id !== 'code' && f.id !== 'status');
const filters: any[] = [...others];
if (typeValue) filters.push({ id: 'kind', value: typeValue });
if (typeSearchValue) filters.push({ id: 'searchtype', value: typeSearchValue });
if (searchValue) filters.push({ id: 'code', value: searchValue });
if (status) filters.push({ id: 'status', value: status });
return filters;
});
table.setPageIndex(0);
}, [trxDate, typeValue, typeSearchValue, searchValue, table]);
}, [trxDate, typeValue, typeSearchValue, searchValue, status, table]);
const exporDataToExcel = async (
typeSearchValue: string,
searchValue: string,
trxDate: any,
typeValue: string
typeValue: string,
status: string
) => {
try {
const formattedFilter: any = {
@ -172,6 +177,19 @@ const ListToolbar = () => {
</SelectContent>
</Select>
<Select value={status} onValueChange={(value) => setStatus(value)}>
<SelectTrigger className="input input-sm w-[250px] h-[31px]">
<SelectValue placeholder="Select Transaction Status" />
</SelectTrigger>
<SelectContent>
<SelectItem value="P">PENDING</SelectItem>
<SelectItem value="O">ON PROCESS</SelectItem>
<SelectItem value="F">FAILED</SelectItem>
<SelectItem value="C">COMPLETE</SelectItem>
<SelectItem value="R">ROLLBACK</SelectItem>
</SelectContent>
</Select>
<Select value={typeSearchValue} onValueChange={(value) => setSearchTypeValue(value)}>
<SelectTrigger className="input input-sm w-[250px] h-[31px]">
<SelectValue placeholder="Select Search Type" />
@ -207,7 +225,8 @@ const ListToolbar = () => {
typeSearchValue || '',
searchValue || '',
trxDate || {},
typeValue || ''
typeValue || '',
status || ''
);
if (result) {
@ -234,6 +253,7 @@ const ListToolbar = () => {
setSearchValue('');
setSearchTypeValue('');
setTypeValue('');
setStatus('');
settrxDate({ from: formatDate(today), to: formatDate(today) });
table.setColumnFilters([]);
table.setPageIndex(0);

View File

@ -316,6 +316,7 @@ const TransactionProvider = ({ children }: { children: React.ReactNode }) => {
let enddate: string | undefined;
let transactioncode = '';
let type = '';
let status = '';
let searchType = '';
let codeValue = '';
@ -338,6 +339,10 @@ const TransactionProvider = ({ children }: { children: React.ReactNode }) => {
if (f.id === 'kind' && f.value) {
type = f.value;
}
if (f.id === 'status' && f.value) {
status = f.value;
}
});
// Kalau tidak ada searchType, baru pakai tanggal
@ -355,6 +360,10 @@ const TransactionProvider = ({ children }: { children: React.ReactNode }) => {
// Build formattedFilter setelah semua nilai diketahui
const formattedFilter: any = {};
if( status) {
formattedFilter["Transactions.status"] = status;
}
// Tambahkan filter tanggal HANYA jika tidak ada searchType
if (startdate && enddate) {
formattedFilter["Transactions.transaction_date"] = {