managarten/apps-archived/finance/apps/web/src/lib/api/accounts.ts
Till-JS ace7fa8f7f chore: archive finance, mail, moodlit apps and rename voxel-lava
- Move finance, mail, moodlit to apps-archived for later development
- Rename games/voxel-lava to games/voxelava

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 13:13:15 +01:00

25 lines
1,000 B
TypeScript

import { apiClient } from './client';
import type { Account, CreateAccountInput, UpdateAccountInput } from '@finance/shared';
export const accountsApi = {
getAll: () => apiClient.get<Account[]>('/accounts'),
getAllIncludingArchived: () => apiClient.get<Account[]>('/accounts/all'),
getOne: (id: string) => apiClient.get<Account>(`/accounts/${id}`),
getTotals: () =>
apiClient.get<{ currency: string; total: number; count: number }[]>('/accounts/totals'),
create: (data: CreateAccountInput) => apiClient.post<Account>('/accounts', data),
update: (id: string, data: UpdateAccountInput) => apiClient.put<Account>(`/accounts/${id}`, data),
delete: (id: string) => apiClient.delete<{ success: boolean }>(`/accounts/${id}`),
archive: (id: string) => apiClient.post<Account>(`/accounts/${id}/archive`),
unarchive: (id: string) => apiClient.post<Account>(`/accounts/${id}/unarchive`),
reorder: (accountIds: string[]) => apiClient.put<Account[]>('/accounts/reorder', { accountIds }),
};