Twilioapp-admin/types/database.ts
mars 211e0306b5 feat: 集成真实数据库连接和API服务
- 更新 .env.local 配置为真实的 Supabase 项目连接
- 创建完整的 API 服务层 (lib/api-service.ts)
- 创建数据库类型定义 (types/database.ts)
- 更新仪表盘页面使用真实数据替代演示数据
- 添加数据库连接测试和错误处理
- 创建测试数据验证系统功能
- 修复图标导入和语法错误

系统现在已连接到真实的 Supabase 数据库,可以正常显示统计数据和最近活动。
2025-07-03 13:12:54 +08:00

508 lines
15 KiB
TypeScript

export type Json =
| string
| number
| boolean
| null
| { [key: string]: Json | undefined }
| Json[]
export interface Database {
public: {
Tables: {
users: {
Row: {
id: string
email: string
name: string
phone: string | null
user_type: 'individual' | 'enterprise'
status: 'active' | 'inactive' | 'suspended'
enterprise_id: string | null
avatar_url: string | null
created_at: string
updated_at: string
}
Insert: {
id?: string
email: string
name: string
phone?: string | null
user_type: 'individual' | 'enterprise'
status?: 'active' | 'inactive' | 'suspended'
enterprise_id?: string | null
avatar_url?: string | null
created_at?: string
updated_at?: string
}
Update: {
id?: string
email?: string
name?: string
phone?: string | null
user_type?: 'individual' | 'enterprise'
status?: 'active' | 'inactive' | 'suspended'
enterprise_id?: string | null
avatar_url?: string | null
created_at?: string
updated_at?: string
}
}
enterprises: {
Row: {
id: string
name: string
contact_person: string
contact_email: string
contact_phone: string | null
address: string | null
tax_number: string | null
status: 'active' | 'inactive' | 'suspended'
created_at: string
updated_at: string
}
Insert: {
id?: string
name: string
contact_person: string
contact_email: string
contact_phone?: string | null
address?: string | null
tax_number?: string | null
status?: 'active' | 'inactive' | 'suspended'
created_at?: string
updated_at?: string
}
Update: {
id?: string
name?: string
contact_person?: string
contact_email?: string
contact_phone?: string | null
address?: string | null
tax_number?: string | null
status?: 'active' | 'inactive' | 'suspended'
created_at?: string
updated_at?: string
}
}
enterprise_contracts: {
Row: {
id: string
enterprise_id: string
contract_number: string
contract_type: 'basic' | 'premium' | 'enterprise'
start_date: string
end_date: string
total_amount: number
currency: string
status: 'active' | 'expired' | 'cancelled'
service_rates: any
created_at: string
updated_at: string
}
Insert: {
id?: string
enterprise_id: string
contract_number: string
contract_type: 'basic' | 'premium' | 'enterprise'
start_date: string
end_date: string
total_amount: number
currency: string
status?: 'active' | 'expired' | 'cancelled'
service_rates: any
created_at?: string
updated_at?: string
}
Update: {
id?: string
enterprise_id?: string
contract_number?: string
contract_type?: 'basic' | 'premium' | 'enterprise'
start_date?: string
end_date?: string
total_amount?: number
currency?: string
status?: 'active' | 'expired' | 'cancelled'
service_rates?: any
created_at?: string
updated_at?: string
}
}
enterprise_bills: {
Row: {
id: string
enterprise_id: string
bill_number: string
billing_period_start: string
billing_period_end: string
total_amount: number
currency: string
status: 'draft' | 'sent' | 'paid' | 'overdue'
items: any[]
created_at: string
updated_at: string
}
Insert: {
id?: string
enterprise_id: string
bill_number: string
billing_period_start: string
billing_period_end: string
total_amount: number
currency: string
status?: 'draft' | 'sent' | 'paid' | 'overdue'
items: any[]
created_at?: string
updated_at?: string
}
Update: {
id?: string
enterprise_id?: string
bill_number?: string
billing_period_start?: string
billing_period_end?: string
total_amount?: number
currency?: string
status?: 'draft' | 'sent' | 'paid' | 'overdue'
items?: any[]
created_at?: string
updated_at?: string
}
}
orders: {
Row: {
id: string
order_number: string
user_id: string
user_name: string
user_email: string
service_type: 'phone' | 'video' | 'document'
service_name: string
source_language: string
target_language: string
duration: number | null
status: 'pending' | 'confirmed' | 'in_progress' | 'completed' | 'cancelled'
priority: 'low' | 'medium' | 'high' | 'urgent'
cost: number
currency: string
scheduled_time: string | null
started_time: string | null
completed_time: string | null
interpreter_id: string | null
interpreter_name: string | null
notes: string | null
created_at: string
updated_at: string
}
Insert: {
id?: string
order_number: string
user_id: string
user_name: string
user_email: string
service_type: 'phone' | 'video' | 'document'
service_name: string
source_language: string
target_language: string
duration?: number | null
status?: 'pending' | 'confirmed' | 'in_progress' | 'completed' | 'cancelled'
priority?: 'low' | 'medium' | 'high' | 'urgent'
cost: number
currency: string
scheduled_time?: string | null
started_time?: string | null
completed_time?: string | null
interpreter_id?: string | null
interpreter_name?: string | null
notes?: string | null
created_at?: string
updated_at?: string
}
Update: {
id?: string
order_number?: string
user_id?: string
user_name?: string
user_email?: string
service_type?: 'phone' | 'video' | 'document'
service_name?: string
source_language?: string
target_language?: string
duration?: number | null
status?: 'pending' | 'confirmed' | 'in_progress' | 'completed' | 'cancelled'
priority?: 'low' | 'medium' | 'high' | 'urgent'
cost?: number
currency?: string
scheduled_time?: string | null
started_time?: string | null
completed_time?: string | null
interpreter_id?: string | null
interpreter_name?: string | null
notes?: string | null
created_at?: string
updated_at?: string
}
}
invoices: {
Row: {
id: string
invoice_number: string
user_id: string
user_name: string
user_email: string
order_id: string | null
invoice_type: 'individual' | 'enterprise'
personal_name: string | null
company_name: string | null
tax_number: string | null
company_address: string | null
subtotal: number
tax_amount: number
total_amount: number
currency: string
status: 'draft' | 'sent' | 'paid' | 'cancelled' | 'overdue'
issue_date: string
due_date: string
paid_date: string | null
items: any[]
created_at: string
updated_at: string
}
Insert: {
id?: string
invoice_number: string
user_id: string
user_name: string
user_email: string
order_id?: string | null
invoice_type: 'individual' | 'enterprise'
personal_name?: string | null
company_name?: string | null
tax_number?: string | null
company_address?: string | null
subtotal: number
tax_amount: number
total_amount: number
currency: string
status?: 'draft' | 'sent' | 'paid' | 'cancelled' | 'overdue'
issue_date: string
due_date: string
paid_date?: string | null
items: any[]
created_at?: string
updated_at?: string
}
Update: {
id?: string
invoice_number?: string
user_id?: string
user_name?: string
user_email?: string
order_id?: string | null
invoice_type?: 'individual' | 'enterprise'
personal_name?: string | null
company_name?: string | null
tax_number?: string | null
company_address?: string | null
subtotal?: number
tax_amount?: number
total_amount?: number
currency?: string
status?: 'draft' | 'sent' | 'paid' | 'cancelled' | 'overdue'
issue_date?: string
due_date?: string
paid_date?: string | null
items?: any[]
created_at?: string
updated_at?: string
}
}
interpreters: {
Row: {
id: string
name: string
email: string
phone: string | null
languages: string[]
specialties: string[]
status: 'active' | 'inactive' | 'busy'
rating: number
total_calls: number
hourly_rate: number
currency: string
avatar_url: string | null
bio: string | null
created_at: string
updated_at: string
}
Insert: {
id?: string
name: string
email: string
phone?: string | null
languages: string[]
specialties: string[]
status?: 'active' | 'inactive' | 'busy'
rating?: number
total_calls?: number
hourly_rate: number
currency: string
avatar_url?: string | null
bio?: string | null
created_at?: string
updated_at?: string
}
Update: {
id?: string
name?: string
email?: string
phone?: string | null
languages?: string[]
specialties?: string[]
status?: 'active' | 'inactive' | 'busy'
rating?: number
total_calls?: number
hourly_rate?: number
currency?: string
avatar_url?: string | null
bio?: string | null
created_at?: string
updated_at?: string
}
}
calls: {
Row: {
id: string
user_id: string
interpreter_id: string
service_type: 'phone' | 'video'
source_language: string
target_language: string
status: 'waiting' | 'connected' | 'ended' | 'cancelled'
duration: number | null
cost: number
currency: string
quality_rating: number | null
started_at: string | null
ended_at: string | null
created_at: string
updated_at: string
}
Insert: {
id?: string
user_id: string
interpreter_id: string
service_type: 'phone' | 'video'
source_language: string
target_language: string
status?: 'waiting' | 'connected' | 'ended' | 'cancelled'
duration?: number | null
cost: number
currency: string
quality_rating?: number | null
started_at?: string | null
ended_at?: string | null
created_at?: string
updated_at?: string
}
Update: {
id?: string
user_id?: string
interpreter_id?: string
service_type?: 'phone' | 'video'
source_language?: string
target_language?: string
status?: 'waiting' | 'connected' | 'ended' | 'cancelled'
duration?: number | null
cost?: number
currency?: string
quality_rating?: number | null
started_at?: string | null
ended_at?: string | null
created_at?: string
updated_at?: string
}
}
documents: {
Row: {
id: string
user_id: string
filename: string
original_name: string
file_size: number
file_type: string
source_language: string | null
target_language: string | null
status: 'pending' | 'processing' | 'completed' | 'failed'
created_at: string
updated_at: string
}
Insert: {
id?: string
user_id: string
filename: string
original_name: string
file_size: number
file_type: string
source_language?: string | null
target_language?: string | null
status?: 'pending' | 'processing' | 'completed' | 'failed'
created_at?: string
updated_at?: string
}
Update: {
id?: string
user_id?: string
filename?: string
original_name?: string
file_size?: number
file_type?: string
source_language?: string | null
target_language?: string | null
status?: 'pending' | 'processing' | 'completed' | 'failed'
created_at?: string
updated_at?: string
}
}
system_settings: {
Row: {
id: string
key: string
value: string
description: string | null
created_at: string
updated_at: string
}
Insert: {
id?: string
key: string
value: string
description?: string | null
created_at?: string
updated_at?: string
}
Update: {
id?: string
key?: string
value?: string
description?: string | null
created_at?: string
updated_at?: string
}
}
}
Views: {
[_ in never]: never
}
Functions: {
[_ in never]: never
}
Enums: {
[_ in never]: never
}
CompositeTypes: {
[_ in never]: never
}
}
}