fixessome
This commit is contained in:
@@ -7,7 +7,7 @@ export const getTransaction = async (transactionId: int) => {
|
||||
return await apiClient.post(`/transactions/${transactionId}`,);
|
||||
}
|
||||
|
||||
export const getTransactions = async (transaction_type = null, category_type = null, category_id = null, user_id = null) => {
|
||||
export const getTransactions = async (transaction_type = null, category_type = null, category_id = null, user_id = null, limit = null, offset = null) => {
|
||||
const params = {};
|
||||
|
||||
// Add the parameters to the params object if they are not null
|
||||
@@ -25,6 +25,12 @@ export const getTransactions = async (transaction_type = null, category_type = n
|
||||
if (user_id) {
|
||||
params.user_id = user_id
|
||||
}
|
||||
if (limit) {
|
||||
params.limit = limit
|
||||
}
|
||||
if (offset) {
|
||||
params.offset = offset
|
||||
}
|
||||
|
||||
// Use axios to make the GET request, passing the params as the second argument
|
||||
return await apiClient.get('/transactions/', {
|
||||
@@ -34,7 +40,10 @@ export const getTransactions = async (transaction_type = null, category_type = n
|
||||
|
||||
export const createTransactionRequest = async (transaction: Transaction) => {
|
||||
transaction.date = format(transaction.date, 'yyyy-MM-dd')
|
||||
return await apiClient.post('/transactions', transaction);
|
||||
let transactionResponse = await apiClient.post('/transactions', transaction);
|
||||
console.log(transaction.date)
|
||||
transaction.date = new Date(transaction.date);
|
||||
return transactionResponse.data
|
||||
};
|
||||
|
||||
export const updateTransactionRequest = async (transaction: Transaction) => {
|
||||
@@ -63,4 +72,9 @@ export const deleteTransactionRequest = async (id: number) => {
|
||||
|
||||
export const getTransactionTypes = async () => {
|
||||
return await apiClient.get('/transactions/types');
|
||||
}
|
||||
|
||||
export const getTransactionCategoriesSums = async () => {
|
||||
let response = await apiClient.get('/transactions/categories/_calc_sums');
|
||||
return response.data;
|
||||
}
|
||||
Reference in New Issue
Block a user