cre-sync/types/admin.ts
BusyBee3333 4e6467ffb0 Add CRESync CRM application with Setup page
- Build complete Next.js CRM for commercial real estate
- Add authentication with JWT sessions and role-based access
- Add GoHighLevel API integration for contacts, conversations, opportunities
- Add AI-powered Control Center with tool calling
- Add Setup page with onboarding checklist (/setup)
- Add sidebar navigation with Setup menu item
- Fix type errors in onboarding API, GHL services, and control center tools
- Add Prisma schema with SQLite for local development
- Add UI components with clay morphism design system

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 17:30:55 -05:00

217 lines
5.2 KiB
TypeScript

/**
* 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<string, any>;
timestamp: Date;
ipAddress?: string;
userAgent?: string;
}
// =============================================================================
// Admin Settings Update Types
// =============================================================================
export interface UpdateSettingsRequest {
settings: Partial<SystemSettings>;
}
export interface SettingsValidationResult {
isValid: boolean;
errors: Record<string, string>;
warnings: Record<string, string>;
}
// =============================================================================
// Admin Action Types
// =============================================================================
export interface AdminAction {
id: string;
adminUserId: string;
action: AdminActionType;
targetUserId?: string;
details?: Record<string, any>;
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<string, any>;
}
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<string, any>;
after: Record<string, any>;
};
ipAddress?: string;
userAgent?: string;
}
export interface AuditLogFilter {
userId?: string;
action?: string;
resource?: string;
dateFrom?: Date;
dateTo?: Date;
}