ADD: Transactions List Page
FIX: Dates
This commit is contained in:
@@ -1,6 +1,16 @@
|
||||
import axios from 'axios';
|
||||
|
||||
export const TransactionService = {
|
||||
_getAuthHeader: () => {
|
||||
const bmToken = document.cookie
|
||||
.split('; ')
|
||||
.find((row) => row.startsWith('bm-token='))
|
||||
?.split('=')[1];
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${bmToken}`
|
||||
};
|
||||
},
|
||||
/**
|
||||
* Get a single transaction by ID
|
||||
* @param {string} transactionId - The transaction ID
|
||||
@@ -143,5 +153,36 @@ export const TransactionService = {
|
||||
console.log(err);
|
||||
return err.response?.data?.message || 'Error deleting transaction';
|
||||
}
|
||||
},
|
||||
|
||||
searchTransactions: async (query) => {
|
||||
const config = {
|
||||
method: 'get',
|
||||
url: '/api/transactions/admin/search',
|
||||
withCredentials: true,
|
||||
params: query,
|
||||
headers: TransactionService._getAuthHeader()
|
||||
};
|
||||
try {
|
||||
const response = await axios(config);
|
||||
return response.data;
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
},
|
||||
|
||||
indexTransactions: async () => {
|
||||
const config = {
|
||||
method: 'post',
|
||||
url: '/api/transactions/admin/index-all',
|
||||
withCredentials: true,
|
||||
headers: TransactionService._getAuthHeader()
|
||||
};
|
||||
try {
|
||||
const response = await axios(config);
|
||||
return response.data;
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user