feat: Implement messaging functionality with conversation and chat screens, and enhance agent detail views.
This commit is contained in:
@@ -19,6 +19,8 @@ class AgentProfile {
|
||||
final bool isVerified;
|
||||
final bool isFeatured;
|
||||
final bool isActive;
|
||||
final bool isAvailable;
|
||||
final String? email;
|
||||
final AgentType? agentType;
|
||||
final AgentUser? user;
|
||||
final List<AgentFieldValue> fieldValues;
|
||||
@@ -46,6 +48,8 @@ class AgentProfile {
|
||||
this.isVerified = false,
|
||||
this.isFeatured = false,
|
||||
this.isActive = true,
|
||||
this.isAvailable = false,
|
||||
this.email,
|
||||
this.agentType,
|
||||
this.user,
|
||||
this.fieldValues = const [],
|
||||
@@ -212,6 +216,8 @@ class AgentProfile {
|
||||
isVerified: json['isVerified'] as bool? ?? false,
|
||||
isFeatured: json['isFeatured'] as bool? ?? false,
|
||||
isActive: json['isActive'] as bool? ?? true,
|
||||
isAvailable: json['isAvailable'] as bool? ?? false,
|
||||
email: json['email'] as String?,
|
||||
agentType: json['agentType'] != null
|
||||
? AgentType.fromJson(json['agentType'] as Map<String, dynamic>)
|
||||
: null,
|
||||
@@ -264,6 +270,8 @@ class AgentFieldValue {
|
||||
final String fieldSlug;
|
||||
final String fieldName;
|
||||
final String fieldType;
|
||||
final String? sectionSlug;
|
||||
final String? sectionName;
|
||||
final String? textValue;
|
||||
final num? numberValue;
|
||||
final bool? booleanValue;
|
||||
@@ -275,6 +283,8 @@ class AgentFieldValue {
|
||||
required this.fieldSlug,
|
||||
required this.fieldName,
|
||||
required this.fieldType,
|
||||
this.sectionSlug,
|
||||
this.sectionName,
|
||||
this.textValue,
|
||||
this.numberValue,
|
||||
this.booleanValue,
|
||||
@@ -282,6 +292,39 @@ class AgentFieldValue {
|
||||
this.dateValue,
|
||||
});
|
||||
|
||||
/// Parse from the /agents/{id}/field-values endpoint format
|
||||
/// which has { fieldSlug, fieldName, fieldType, sectionSlug, value }
|
||||
factory AgentFieldValue.fromFieldValueResponse(Map<String, dynamic> json) {
|
||||
final value = json['value'];
|
||||
String? textValue;
|
||||
num? numberValue;
|
||||
bool? booleanValue;
|
||||
dynamic jsonValue;
|
||||
|
||||
if (value is String) {
|
||||
textValue = value;
|
||||
} else if (value is num) {
|
||||
numberValue = value;
|
||||
} else if (value is bool) {
|
||||
booleanValue = value;
|
||||
} else if (value is List || value is Map) {
|
||||
jsonValue = value;
|
||||
}
|
||||
|
||||
return AgentFieldValue(
|
||||
id: '',
|
||||
fieldSlug: json['fieldSlug'] as String? ?? '',
|
||||
fieldName: json['fieldName'] as String? ?? '',
|
||||
fieldType: json['fieldType'] as String? ?? '',
|
||||
sectionSlug: json['sectionSlug'] as String?,
|
||||
sectionName: json['sectionName'] as String?,
|
||||
textValue: textValue,
|
||||
numberValue: numberValue,
|
||||
booleanValue: booleanValue,
|
||||
jsonValue: jsonValue,
|
||||
);
|
||||
}
|
||||
|
||||
factory AgentFieldValue.fromJson(Map<String, dynamic> json) {
|
||||
// API returns field info nested: { field: { slug, name, fieldType } }
|
||||
// Fallback to top-level fieldSlug/fieldName/fieldType for compatibility
|
||||
|
||||
Reference in New Issue
Block a user