Rebrand from Forte (music-store-specific) to LunarFront (any small business): - Package namespace @forte/* → @lunarfront/* - Database forte/forte_test → lunarfront/lunarfront_test - Docker containers, volumes, connection strings - UI branding, localStorage keys, test emails - All documentation and planning docs Generalize music-specific terminology: - instrumentDescription → itemDescription - instrumentCount → itemCount - instrumentType → itemCategory (on service templates) - New migration 0027_generalize_terminology for column renames - Seed data updated with generic examples - RBAC descriptions updated
46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
import { queryOptions } from '@tanstack/react-query'
|
|
import { api } from '@/lib/api-client'
|
|
import type { Member } from '@/types/account'
|
|
import type { PaginatedResponse, PaginationInput } from '@lunarfront/shared/schemas'
|
|
|
|
interface MemberWithAccount extends Member {
|
|
accountName: string | null
|
|
}
|
|
|
|
export const memberKeys = {
|
|
all: (accountId: string) => ['accounts', accountId, 'members'] as const,
|
|
list: (accountId: string, params: PaginationInput) => [...memberKeys.all(accountId), params] as const,
|
|
globalAll: ['members'] as const,
|
|
globalList: (params: PaginationInput) => ['members', 'list', params] as const,
|
|
}
|
|
|
|
export function memberListOptions(accountId: string, params: PaginationInput) {
|
|
return queryOptions({
|
|
queryKey: memberKeys.list(accountId, params),
|
|
queryFn: () => api.get<PaginatedResponse<Member>>(`/v1/accounts/${accountId}/members`, params),
|
|
})
|
|
}
|
|
|
|
export function globalMemberListOptions(params: PaginationInput) {
|
|
return queryOptions({
|
|
queryKey: memberKeys.globalList(params),
|
|
queryFn: () => api.get<PaginatedResponse<MemberWithAccount>>('/v1/members', params),
|
|
})
|
|
}
|
|
|
|
export const memberMutations = {
|
|
create: (accountId: string, data: Record<string, unknown>) =>
|
|
api.post<Member>(`/v1/accounts/${accountId}/members`, data),
|
|
|
|
update: (id: string, data: Record<string, unknown>) =>
|
|
api.patch<Member>(`/v1/members/${id}`, data),
|
|
|
|
delete: (id: string) =>
|
|
api.del<Member>(`/v1/members/${id}`),
|
|
|
|
move: (id: string, accountId?: string) =>
|
|
api.post<Member>(`/v1/members/${id}/move`, accountId ? { accountId } : {}),
|
|
}
|
|
|
|
export type { MemberWithAccount }
|