/** * Admin Settings Types * CRESyncFlow - Commercial Real Estate CRM * * Types for admin panel and system configuration */ // ============================================================================= // System Settings Types // ============================================================================= export interface SystemSettings { // GHL Configuration ghlAgencyApiKey?: string; ghlAgencyId?: string; ghlPrivateToken?: string; ghlWebhookSecret?: string; ghlOwnerLocationId?: string; // Henry's main account for tagging // Tag Configuration (for syncing to owner account) tagHighGCI?: string; // Tag to add when GCI > 100k tagOnboardingComplete?: string; tagDFYRequested?: string; tagActiveUser?: string; tagChurnRisk?: string; // Integrations stripeSecretKey?: string; stripePublishableKey?: string; stripeWebhookSecret?: string; clickupApiKey?: string; clickupListId?: string; clickupSpaceId?: string; // Business Settings dfyPriceFullSetup?: number; // In cents dfyPriceSmsSetup?: number; dfyPriceEmailSetup?: number; dfyPriceCampaignSetup?: number; // Calendly calendlyCoachingLink?: string; calendlyTeamLink?: string; calendlyOnboardingLink?: string; // Notifications notificationEmail?: string; slackWebhookUrl?: string; // Feature Flags enableDFYServices?: boolean; enableLeadGeneration?: boolean; enableMarketplace?: boolean; enableLeaderboard?: boolean; // Limits maxContactsPerLocation?: number; maxConversationsPerDay?: number; } // ============================================================================= // Admin Dashboard Types // ============================================================================= export interface AdminDashboardStats { totalUsers: number; activeUsers: number; highGCIUsers: number; incompleteSetup: number; dfyRequestsPending: number; recentSignups: number; // Last 7 days monthlyRecurringRevenue?: number; churnRate?: number; } export interface UserGrowthData { date: string; totalUsers: number; newUsers: number; activeUsers: number; } export interface RevenueData { date: string; revenue: number; dfyRevenue: number; subscriptionRevenue: number; } // ============================================================================= // Admin User Management Types // ============================================================================= export interface AdminUserView { id: string; email: string; firstName?: string; lastName?: string; brokerage?: string; gciRange?: string; role: string; createdAt: Date; lastLoginAt?: Date; onboardingComplete: boolean; setupStatus: { smsConfigured: boolean; emailConfigured: boolean; contactsImported: boolean; campaignsSetup: boolean; }; contactCount?: number; conversationCount?: number; tags?: string[]; } export interface UserActivity { userId: string; action: string; details?: Record; timestamp: Date; ipAddress?: string; userAgent?: string; } // ============================================================================= // Admin Settings Update Types // ============================================================================= export interface UpdateSettingsRequest { settings: Partial; } export interface SettingsValidationResult { isValid: boolean; errors: Record; warnings: Record; } // ============================================================================= // Admin Action Types // ============================================================================= export interface AdminAction { id: string; adminUserId: string; action: AdminActionType; targetUserId?: string; details?: Record; timestamp: Date; } export type AdminActionType = | 'USER_CREATED' | 'USER_DELETED' | 'USER_ROLE_CHANGED' | 'USER_SUSPENDED' | 'USER_REACTIVATED' | 'SETTINGS_UPDATED' | 'DFY_STATUS_UPDATED' | 'TAG_SYNCED' | 'LOCATION_CREATED' | 'LOCATION_DELETED' | 'BULK_ACTION'; // ============================================================================= // Admin Notification Types // ============================================================================= export interface AdminNotification { id: string; type: AdminNotificationType; title: string; message: string; priority: 'low' | 'medium' | 'high' | 'urgent'; isRead: boolean; createdAt: Date; data?: Record; } export type AdminNotificationType = | 'NEW_USER_SIGNUP' | 'HIGH_GCI_USER' | 'DFY_REQUEST' | 'INTEGRATION_ERROR' | 'PAYMENT_RECEIVED' | 'PAYMENT_FAILED' | 'CHURN_RISK' | 'SYSTEM_ALERT'; // ============================================================================= // Audit Log Types // ============================================================================= export interface AuditLogEntry { id: string; timestamp: Date; userId: string; userEmail: string; action: string; resource: string; resourceId?: string; changes?: { before: Record; after: Record; }; ipAddress?: string; userAgent?: string; } export interface AuditLogFilter { userId?: string; action?: string; resource?: string; dateFrom?: Date; dateTo?: Date; }