Revoke-and-recreate flow for both invite systems with email delivery via Resend API. Includes account invite email template and audit logging. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
import apiClient from './client'
|
|
import type { Account, SubscriptionDetails, AccountMember, AccountInvite } from '@/types'
|
|
|
|
export const accountsApi = {
|
|
async getMyAccount(): Promise<Account> {
|
|
const response = await apiClient.get<Account>('/accounts/me')
|
|
return response.data
|
|
},
|
|
|
|
async getMySubscription(): Promise<SubscriptionDetails> {
|
|
const response = await apiClient.get<SubscriptionDetails>('/accounts/me/subscription')
|
|
return response.data
|
|
},
|
|
|
|
async updateMyAccount(data: { name?: string }): Promise<Account> {
|
|
const response = await apiClient.patch<Account>('/accounts/me', data)
|
|
return response.data
|
|
},
|
|
|
|
async getMembers(): Promise<AccountMember[]> {
|
|
const response = await apiClient.get<AccountMember[]>('/accounts/me/members')
|
|
return response.data
|
|
},
|
|
|
|
async updateMemberRole(userId: string, role: string): Promise<AccountMember> {
|
|
const response = await apiClient.patch<AccountMember>(
|
|
`/accounts/me/members/${userId}/role`,
|
|
{ role }
|
|
)
|
|
return response.data
|
|
},
|
|
|
|
async removeMember(userId: string): Promise<void> {
|
|
await apiClient.delete(`/accounts/me/members/${userId}`)
|
|
},
|
|
|
|
async createInvite(data: { email: string; role: string }): Promise<AccountInvite> {
|
|
const response = await apiClient.post<AccountInvite>('/accounts/me/invites', data)
|
|
return response.data
|
|
},
|
|
|
|
async getInvites(): Promise<AccountInvite[]> {
|
|
const response = await apiClient.get<AccountInvite[]>('/accounts/me/invites')
|
|
return response.data
|
|
},
|
|
|
|
async resendInvite(inviteId: string): Promise<AccountInvite> {
|
|
const response = await apiClient.post<AccountInvite>(`/accounts/me/invites/${inviteId}/resend`)
|
|
return response.data
|
|
},
|
|
}
|
|
|
|
export default accountsApi
|