diff options
Diffstat (limited to 'frontend/src/lib/api.ts')
-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; |