fix
This commit is contained in:
@@ -33,6 +33,20 @@ enum AuthProvider {
|
||||
TWITTER
|
||||
}
|
||||
|
||||
enum FieldType {
|
||||
TEXT // Single line text input
|
||||
TEXTAREA // Multi-line text area
|
||||
CHECKBOX // Single checkbox (Yes/No)
|
||||
CHECKBOX_GROUP // Multiple checkboxes in grid (select multiple)
|
||||
RADIO // Radio buttons (select one)
|
||||
SELECT // Dropdown (select one)
|
||||
MULTI_SELECT // Dropdown with multi-select
|
||||
RANGE // Slider with min/max
|
||||
NUMBER // Number input
|
||||
DATE // Date picker
|
||||
TAG_INPUT // Tag input (add custom tags)
|
||||
}
|
||||
|
||||
|
||||
// ===========================================
|
||||
// USER - Authentication Only
|
||||
@@ -160,6 +174,7 @@ model AgentProfile {
|
||||
// Relations
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
agentType AgentType? @relation(fields: [agentTypeId], references: [id])
|
||||
fieldValues AgentProfileFieldValue[]
|
||||
|
||||
@@index([userId])
|
||||
@@index([agentTypeId])
|
||||
@@ -188,12 +203,130 @@ model AgentType {
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
// Relations
|
||||
agents AgentProfile[]
|
||||
agents AgentProfile[]
|
||||
agentTypeSections AgentTypeSection[]
|
||||
|
||||
@@index([isActive])
|
||||
@@map("agent_types")
|
||||
}
|
||||
|
||||
// ===========================================
|
||||
// DYNAMIC PROFILE FIELD SYSTEM
|
||||
// ===========================================
|
||||
|
||||
// Profile Sections - Groups of related fields
|
||||
model ProfileSection {
|
||||
id String @id @default(uuid())
|
||||
name String // e.g., "Location", "Experience", "Specialization"
|
||||
slug String @unique // URL-friendly identifier
|
||||
description String?
|
||||
icon String? // Icon name or URL
|
||||
sortOrder Int @default(0)
|
||||
isActive Boolean @default(true)
|
||||
isGlobal Boolean @default(false) // If true, applies to ALL agent types
|
||||
|
||||
// Timestamps
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
// Relations
|
||||
fields ProfileField[]
|
||||
agentTypeSections AgentTypeSection[]
|
||||
|
||||
@@index([isActive])
|
||||
@@index([sortOrder])
|
||||
@@map("profile_sections")
|
||||
}
|
||||
|
||||
// Many-to-Many: Which sections belong to which agent types
|
||||
model AgentTypeSection {
|
||||
id String @id @default(uuid())
|
||||
agentTypeId String
|
||||
sectionId String
|
||||
sortOrder Int @default(0) // Order specific to this agent type
|
||||
isRequired Boolean @default(false) // Is this section required for this type
|
||||
|
||||
// Timestamps
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
// Relations
|
||||
agentType AgentType @relation(fields: [agentTypeId], references: [id], onDelete: Cascade)
|
||||
section ProfileSection @relation(fields: [sectionId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([agentTypeId, sectionId])
|
||||
@@index([agentTypeId])
|
||||
@@index([sectionId])
|
||||
@@map("agent_type_sections")
|
||||
}
|
||||
|
||||
// Profile Fields - Individual form fields
|
||||
model ProfileField {
|
||||
id String @id @default(uuid())
|
||||
sectionId String
|
||||
name String // e.g., "State", "Years in Business"
|
||||
slug String // Unique within section: e.g., "state", "years_in_business"
|
||||
fieldType FieldType
|
||||
description String? // Help text shown to user
|
||||
placeholder String? // Placeholder text for input
|
||||
defaultValue String? // Default value (JSON for complex types)
|
||||
sortOrder Int @default(0)
|
||||
isActive Boolean @default(true)
|
||||
isRequired Boolean @default(false)
|
||||
|
||||
// Validation rules (JSON)
|
||||
validation Json? // { min, max, minLength, maxLength, pattern, etc. }
|
||||
|
||||
// For SELECT, RADIO, MULTI_SELECT, CHECKBOX_GROUP
|
||||
options Json? // [{ value: "...", label: "...", sortOrder: 0 }]
|
||||
|
||||
// For RANGE/slider
|
||||
rangeConfig Json? // { min: 0, max: 100, step: 1 }
|
||||
|
||||
// UI Configuration
|
||||
uiConfig Json? // { columns: 2, showInPreview: true, etc. }
|
||||
|
||||
// Timestamps
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
// Relations
|
||||
section ProfileSection @relation(fields: [sectionId], references: [id], onDelete: Cascade)
|
||||
fieldValues AgentProfileFieldValue[]
|
||||
|
||||
@@unique([sectionId, slug])
|
||||
@@index([sectionId])
|
||||
@@index([isActive])
|
||||
@@map("profile_fields")
|
||||
}
|
||||
|
||||
// Agent Profile Field Values - Stores actual agent data
|
||||
model AgentProfileFieldValue {
|
||||
id String @id @default(uuid())
|
||||
agentProfileId String
|
||||
fieldId String
|
||||
|
||||
// Value storage - use appropriate column based on field type
|
||||
textValue String? @db.Text // For TEXT, TEXTAREA
|
||||
numberValue Float? // For NUMBER, RANGE
|
||||
booleanValue Boolean? // For single CHECKBOX
|
||||
jsonValue Json? // For MULTI_SELECT, RADIO, complex data
|
||||
dateValue DateTime? // For DATE
|
||||
|
||||
// Timestamps
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
// Relations
|
||||
agentProfile AgentProfile @relation(fields: [agentProfileId], references: [id], onDelete: Cascade)
|
||||
field ProfileField @relation(fields: [fieldId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([agentProfileId, fieldId])
|
||||
@@index([agentProfileId])
|
||||
@@index([fieldId])
|
||||
@@map("agent_profile_field_values")
|
||||
}
|
||||
|
||||
// ===========================================
|
||||
// SESSION - JWT Token Management
|
||||
// ===========================================
|
||||
|
||||
Reference in New Issue
Block a user