Merge branch 'master' of https://git.shiblysolution.id/TPAY/dashboard
This commit is contained in:
@ -23,6 +23,10 @@ const ListToolbar = () => {
|
|||||||
(table.getState().columnFilters.find(f => f.id === 'kind')?.value as string) ?? ''
|
(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 { GetData } = useCallApi();
|
||||||
const API_URL = apiConfig.transaction;
|
const API_URL = apiConfig.transaction;
|
||||||
|
|
||||||
@ -50,24 +54,25 @@ const ListToolbar = () => {
|
|||||||
table.getColumn('transaction_date')?.setFilterValue(trxDate);
|
table.getColumn('transaction_date')?.setFilterValue(trxDate);
|
||||||
|
|
||||||
table.setColumnFilters((prev) => {
|
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];
|
const filters: any[] = [...others];
|
||||||
|
|
||||||
if (typeValue) filters.push({ id: 'kind', value: typeValue });
|
if (typeValue) filters.push({ id: 'kind', value: typeValue });
|
||||||
if (typeSearchValue) filters.push({ id: 'searchtype', value: typeSearchValue });
|
if (typeSearchValue) filters.push({ id: 'searchtype', value: typeSearchValue });
|
||||||
if (searchValue) filters.push({ id: 'code', value: searchValue });
|
if (searchValue) filters.push({ id: 'code', value: searchValue });
|
||||||
|
if (status) filters.push({ id: 'status', value: status });
|
||||||
return filters;
|
return filters;
|
||||||
});
|
});
|
||||||
|
|
||||||
table.setPageIndex(0);
|
table.setPageIndex(0);
|
||||||
}, [trxDate, typeValue, typeSearchValue, searchValue, table]);
|
}, [trxDate, typeValue, typeSearchValue, searchValue, status, table]);
|
||||||
|
|
||||||
const exporDataToExcel = async (
|
const exporDataToExcel = async (
|
||||||
typeSearchValue: string,
|
typeSearchValue: string,
|
||||||
searchValue: string,
|
searchValue: string,
|
||||||
trxDate: any,
|
trxDate: any,
|
||||||
typeValue: string
|
typeValue: string,
|
||||||
|
status: string
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const formattedFilter: any = {
|
const formattedFilter: any = {
|
||||||
@ -172,6 +177,19 @@ const ListToolbar = () => {
|
|||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</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)}>
|
<Select value={typeSearchValue} onValueChange={(value) => setSearchTypeValue(value)}>
|
||||||
<SelectTrigger className="input input-sm w-[250px] h-[31px]">
|
<SelectTrigger className="input input-sm w-[250px] h-[31px]">
|
||||||
<SelectValue placeholder="Select Search Type" />
|
<SelectValue placeholder="Select Search Type" />
|
||||||
@ -207,7 +225,8 @@ const ListToolbar = () => {
|
|||||||
typeSearchValue || '',
|
typeSearchValue || '',
|
||||||
searchValue || '',
|
searchValue || '',
|
||||||
trxDate || {},
|
trxDate || {},
|
||||||
typeValue || ''
|
typeValue || '',
|
||||||
|
status || ''
|
||||||
);
|
);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
@ -234,6 +253,7 @@ const ListToolbar = () => {
|
|||||||
setSearchValue('');
|
setSearchValue('');
|
||||||
setSearchTypeValue('');
|
setSearchTypeValue('');
|
||||||
setTypeValue('');
|
setTypeValue('');
|
||||||
|
setStatus('');
|
||||||
settrxDate({ from: formatDate(today), to: formatDate(today) });
|
settrxDate({ from: formatDate(today), to: formatDate(today) });
|
||||||
table.setColumnFilters([]);
|
table.setColumnFilters([]);
|
||||||
table.setPageIndex(0);
|
table.setPageIndex(0);
|
||||||
|
|||||||
@ -316,6 +316,7 @@ const TransactionProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
let enddate: string | undefined;
|
let enddate: string | undefined;
|
||||||
let transactioncode = '';
|
let transactioncode = '';
|
||||||
let type = '';
|
let type = '';
|
||||||
|
let status = '';
|
||||||
let searchType = '';
|
let searchType = '';
|
||||||
let codeValue = '';
|
let codeValue = '';
|
||||||
|
|
||||||
@ -338,6 +339,10 @@ const TransactionProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
if (f.id === 'kind' && f.value) {
|
if (f.id === 'kind' && f.value) {
|
||||||
type = f.value;
|
type = f.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (f.id === 'status' && f.value) {
|
||||||
|
status = f.value;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Kalau tidak ada searchType, baru pakai tanggal
|
// Kalau tidak ada searchType, baru pakai tanggal
|
||||||
@ -355,6 +360,10 @@ const TransactionProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
// Build formattedFilter setelah semua nilai diketahui
|
// Build formattedFilter setelah semua nilai diketahui
|
||||||
const formattedFilter: any = {};
|
const formattedFilter: any = {};
|
||||||
|
|
||||||
|
if( status) {
|
||||||
|
formattedFilter["Transactions.status"] = status;
|
||||||
|
}
|
||||||
|
|
||||||
// Tambahkan filter tanggal HANYA jika tidak ada searchType
|
// Tambahkan filter tanggal HANYA jika tidak ada searchType
|
||||||
if (startdate && enddate) {
|
if (startdate && enddate) {
|
||||||
formattedFilter["Transactions.transaction_date"] = {
|
formattedFilter["Transactions.transaction_date"] = {
|
||||||
|
|||||||
Reference in New Issue
Block a user