diff options
author | 2025-04-25 02:19:47 +0530 | |
---|---|---|
committer | 2025-04-25 02:19:47 +0530 | |
commit | ff2031f6ff6f4a7e6d441c9ed2372f004ba34499 (patch) | |
tree | f665e59648cbbb74b3d4446270a878a773f26564 /frontend/src | |
parent | 8733795c8449f3514369d7b4220934760e386f1b (diff) | |
download | finance-ff2031f6ff6f4a7e6d441c9ed2372f004ba34499.tar.gz finance-ff2031f6ff6f4a7e6d441c9ed2372f004ba34499.tar.bz2 finance-ff2031f6ff6f4a7e6d441c9ed2372f004ba34499.zip |
finance/backend: feat: added v1/accounts for accounts CRUD
Diffstat (limited to 'frontend/src')
-rw-r--r-- | frontend/src/lib/api.ts | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index 35ef8d6..be77f16 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -75,6 +75,40 @@ export const authApi = { } }; +// Account API +export interface Account { + ID: number; + CreatedAt: string; + UpdatedAt: string; + DeletedAt: string | null; + UserID: number; + Name: string; + Type: string; + Balance: number; +} + +export interface AccountInput { + name: string; + type: string; + balance: number; +} + +export const accountApi = { + getAccounts: () => fetchWithAuth('/accounts'), + getAccount: (id: number) => fetchWithAuth(`/accounts/${id}`), + createAccount: (account: AccountInput) => fetchWithAuth('/accounts', { + method: 'POST', + body: JSON.stringify(account) + }), + updateAccount: (id: number, account: Partial<AccountInput>) => fetchWithAuth(`/accounts/${id}`, { + method: 'PUT', + body: JSON.stringify(account) + }), + deleteAccount: (id: number) => fetchWithAuth(`/accounts/${id}`, { + method: 'DELETE' + }) +}; + // Loan API export interface Loan { ID: number; |