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:
chihlasm
2026-02-07 02:39:15 -05:00
parent e0089a9c5a
commit 7a6f839ef4
26 changed files with 786 additions and 38 deletions

View File

@@ -0,0 +1,62 @@
export interface Account {
id: string
name: string
display_code: string
owner_id: string
created_at: string
updated_at: string
}
export interface Subscription {
id: string
account_id: string
plan: 'free' | 'pro' | 'team'
status: 'active' | 'past_due' | 'canceled' | 'trialing' | 'orphaned'
current_period_start: string | null
current_period_end: string | null
created_at: string
updated_at: string
}
export interface PlanLimits {
plan: string
max_trees: number | null
max_sessions_per_month: number | null
max_users: number | null
custom_branding: boolean
priority_support: boolean
export_formats: string[]
}
export interface SubscriptionDetails {
subscription: Subscription
limits: PlanLimits
usage: {
tree_count: number
session_count_this_month: number
user_count: number
}
}
export interface AccountInvite {
id: string
account_id: string
email: string
role: 'engineer' | 'viewer'
code: string
invited_by_id: string
accepted_by_id: string | null
expires_at: string
used_at: string | null
created_at: string
}
export interface AccountMember {
id: string
email: string
name: string
account_role: string
is_active: boolean
created_at: string
last_login: string | null
}

View File

@@ -5,7 +5,7 @@ export interface Category {
name: string
slug: string
description: string | null
team_id: string | null
account_id: string | null
display_order: number
is_active: boolean
created_at: string
@@ -18,7 +18,7 @@ export interface CategoryListItem {
name: string
slug: string
description: string | null
team_id: string | null
account_id: string | null
display_order: number
is_active: boolean
tree_count: number
@@ -27,7 +27,7 @@ export interface CategoryListItem {
export interface CategoryCreate {
name: string
description?: string | null
team_id?: string | null
account_id?: string | null
}
export interface CategoryUpdate {

View File

@@ -7,6 +7,7 @@ export * from './tag'
export * from './category'
export * from './folder'
export * from './step'
export type { Account, Subscription, PlanLimits, SubscriptionDetails, AccountInvite, AccountMember } from './account'
// API response wrapper types
export interface PaginatedResponse<T> {

View File

@@ -56,7 +56,7 @@ export interface StepCategory {
name: string
description?: string
display_order: number
team_id?: string
account_id?: string
is_active: boolean
}

View File

@@ -4,7 +4,7 @@ export interface Tag {
id: string
name: string
slug: string
team_id: string | null
account_id: string | null
usage_count: number
created_at: string
}
@@ -13,13 +13,13 @@ export interface TagListItem {
id: string
name: string
slug: string
team_id: string | null
account_id: string | null
usage_count: number
}
export interface TagCreate {
name: string
team_id?: string | null
account_id?: string | null
}
export interface TagAssignment {

View File

@@ -67,7 +67,7 @@ export interface Tree {
tags: string[]
tree_structure: TreeStructure
author_id: string | null
team_id: string | null
account_id: string | null
is_active: boolean
is_public: boolean
is_default: boolean
@@ -86,7 +86,7 @@ export interface TreeListItem {
category_info: CategoryInfo | null
tags: string[]
author_id: string | null
team_id: string | null
account_id: string | null
is_active: boolean
is_public: boolean
is_default: boolean

View File

@@ -6,8 +6,8 @@ export interface User {
name: string
role: UserRole
is_super_admin: boolean
is_team_admin: boolean
team_id: string | null
account_id: string
account_role: 'owner' | 'engineer' | 'viewer'
created_at: string
last_login: string | null
}