feat: creats frontend for the project
This commit is contained in:
27
frontend/src/api/transactions.ts
Normal file
27
frontend/src/api/transactions.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import type {
|
||||
Transaction,
|
||||
GetTransactionsParams,
|
||||
PaginatedResponse,
|
||||
UpdateTransactionRequest,
|
||||
} from '@family-budget/shared';
|
||||
import { api } from './client';
|
||||
|
||||
export async function getTransactions(
|
||||
params: GetTransactionsParams,
|
||||
): Promise<PaginatedResponse<Transaction>> {
|
||||
const sp = new URLSearchParams();
|
||||
for (const [key, value] of Object.entries(params)) {
|
||||
if (value != null && value !== '') {
|
||||
sp.set(key, String(value));
|
||||
}
|
||||
}
|
||||
const qs = sp.toString();
|
||||
return api.get(`/api/transactions${qs ? `?${qs}` : ''}`);
|
||||
}
|
||||
|
||||
export async function updateTransaction(
|
||||
id: number,
|
||||
data: UpdateTransactionRequest,
|
||||
): Promise<Transaction> {
|
||||
return api.put<Transaction>(`/api/transactions/${id}`, data);
|
||||
}
|
||||
Reference in New Issue
Block a user