Add accounts UI with list, create, edit, detail tabs for all sub-entities
Accounts list with paginated table, search, sort. Account detail page with tabs for members, payment methods, tax exemptions, and processor links. All sub-entities have create/edit dialogs and delete actions. Forms use shared Zod schemas via react-hook-form.
This commit is contained in:
37
packages/admin/src/api/accounts.ts
Normal file
37
packages/admin/src/api/accounts.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { queryOptions } from '@tanstack/react-query'
|
||||
import { api } from '@/lib/api-client'
|
||||
import type { Account } from '@/types/account'
|
||||
import type { PaginatedResponse, PaginationInput } from '@forte/shared/schemas'
|
||||
|
||||
export const accountKeys = {
|
||||
all: ['accounts'] as const,
|
||||
lists: () => [...accountKeys.all, 'list'] as const,
|
||||
list: (params: PaginationInput) => [...accountKeys.all, 'list', params] as const,
|
||||
details: () => [...accountKeys.all, 'detail'] as const,
|
||||
detail: (id: string) => [...accountKeys.all, 'detail', id] as const,
|
||||
}
|
||||
|
||||
export function accountListOptions(params: PaginationInput) {
|
||||
return queryOptions({
|
||||
queryKey: accountKeys.list(params),
|
||||
queryFn: () => api.get<PaginatedResponse<Account>>('/v1/accounts', params),
|
||||
})
|
||||
}
|
||||
|
||||
export function accountDetailOptions(id: string) {
|
||||
return queryOptions({
|
||||
queryKey: accountKeys.detail(id),
|
||||
queryFn: () => api.get<Account>(`/v1/accounts/${id}`),
|
||||
})
|
||||
}
|
||||
|
||||
export const accountMutations = {
|
||||
create: (data: Record<string, unknown>) =>
|
||||
api.post<Account>('/v1/accounts', data),
|
||||
|
||||
update: (id: string, data: Record<string, unknown>) =>
|
||||
api.patch<Account>(`/v1/accounts/${id}`, data),
|
||||
|
||||
delete: (id: string) =>
|
||||
api.del<Account>(`/v1/accounts/${id}`),
|
||||
}
|
||||
Reference in New Issue
Block a user