feat: update frontend for account-based subscriptions
Replace all team_id/team_admin references with account_id/owner across types, store, hooks, API clients, components, and pages. Add new AccountSettingsPage, UpgradePrompt, CheckoutButton, useSubscription hook, and accounts API client. AuthStore now parallel-fetches account and subscription data alongside user profile. Also fix folder sidebar not refreshing after tree deletion by dispatching the folder-changed event in handleDeleteTree. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
48
frontend/src/api/accounts.ts
Normal file
48
frontend/src/api/accounts.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
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
|
||||
},
|
||||
}
|
||||
|
||||
export default accountsApi
|
||||
@@ -2,9 +2,9 @@ import apiClient from './client'
|
||||
import type { Category, CategoryListItem, CategoryCreate, CategoryUpdate } from '@/types'
|
||||
|
||||
export const categoriesApi = {
|
||||
async list(includeInactive = false, teamOnly = false): Promise<CategoryListItem[]> {
|
||||
async list(includeInactive = false, accountOnly = false): Promise<CategoryListItem[]> {
|
||||
const response = await apiClient.get<CategoryListItem[]>('/categories', {
|
||||
params: { include_inactive: includeInactive, team_only: teamOnly },
|
||||
params: { include_inactive: includeInactive, account_only: accountOnly },
|
||||
})
|
||||
return response.data
|
||||
},
|
||||
|
||||
@@ -8,3 +8,4 @@ export { default as categoriesApi } from './categories'
|
||||
export { default as foldersApi } from './folders'
|
||||
export { default as stepsApi } from './steps'
|
||||
export { default as stepCategoriesApi } from './stepCategories'
|
||||
export { default as accountsApi } from './accounts'
|
||||
|
||||
@@ -2,16 +2,16 @@ import apiClient from './client'
|
||||
import type { Tag, TagListItem, TagCreate, TagAssignment } from '@/types'
|
||||
|
||||
export const tagsApi = {
|
||||
async list(includeTeam = true): Promise<TagListItem[]> {
|
||||
async list(includeAccount = true): Promise<TagListItem[]> {
|
||||
const response = await apiClient.get<TagListItem[]>('/tags', {
|
||||
params: { include_team: includeTeam },
|
||||
params: { include_account: includeAccount },
|
||||
})
|
||||
return response.data
|
||||
},
|
||||
|
||||
async search(query: string, limit = 10, includeTeam = true): Promise<TagListItem[]> {
|
||||
async search(query: string, limit = 10, includeAccount = true): Promise<TagListItem[]> {
|
||||
const response = await apiClient.get<TagListItem[]>('/tags/search', {
|
||||
params: { q: query, limit, include_team: includeTeam },
|
||||
params: { q: query, limit, include_account: includeAccount },
|
||||
})
|
||||
return response.data
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user