feat: implement dynamic field labels for agent profile sections using backend-provided slugs
This commit is contained in:
@@ -292,6 +292,26 @@ class AgentDetailState {
|
|||||||
return '${'*' * (digits.length - 4)}${digits.substring(digits.length - 4)}';
|
return '${'*' * (digits.length - 4)}${digits.substring(digits.length - 4)}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Dynamic labels (fieldName from backend, with fallback) ──
|
||||||
|
|
||||||
|
String _labelForSlug(String slug, String fallback) {
|
||||||
|
for (final fv in fieldValues) {
|
||||||
|
if (fv.fieldSlug == slug && fv.fieldName.isNotEmpty) {
|
||||||
|
return fv.fieldName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
String get availabilityLabel =>
|
||||||
|
_labelForSlug('availability', 'Availability');
|
||||||
|
|
||||||
|
String get workEnvironmentLabel =>
|
||||||
|
_labelForSlug('preferred_work_environment', 'Preferred Work Environment');
|
||||||
|
|
||||||
|
String get bestExperienceLabel =>
|
||||||
|
_labelForSlug('best_experience', 'Best Experience');
|
||||||
|
|
||||||
// ── Availability ──
|
// ── Availability ──
|
||||||
|
|
||||||
String get availabilityType {
|
String get availabilityType {
|
||||||
|
|||||||
@@ -999,7 +999,7 @@ class _AgentDetailScreenState extends ConsumerState<AgentDetailScreen> {
|
|||||||
// Availability card (always show)
|
// Availability card (always show)
|
||||||
_buildInfoCard(
|
_buildInfoCard(
|
||||||
icon: Icons.access_time_filled,
|
icon: Icons.access_time_filled,
|
||||||
title: 'Availability',
|
title: state.availabilityLabel,
|
||||||
subtitle: state.availabilityType.isNotEmpty
|
subtitle: state.availabilityType.isNotEmpty
|
||||||
? state.availabilityType
|
? state.availabilityType
|
||||||
: 'Not specified',
|
: 'Not specified',
|
||||||
@@ -1012,7 +1012,7 @@ class _AgentDetailScreenState extends ConsumerState<AgentDetailScreen> {
|
|||||||
// Work environment (always show)
|
// Work environment (always show)
|
||||||
_buildInfoCard(
|
_buildInfoCard(
|
||||||
icon: Icons.landscape_outlined,
|
icon: Icons.landscape_outlined,
|
||||||
title: 'Work Environment',
|
title: state.workEnvironmentLabel,
|
||||||
subtitle: '',
|
subtitle: '',
|
||||||
description: workEnv.isNotEmpty ? workEnv : 'Not specified',
|
description: workEnv.isNotEmpty ? workEnv : 'Not specified',
|
||||||
isEmpty: workEnv.isEmpty,
|
isEmpty: workEnv.isEmpty,
|
||||||
@@ -1021,7 +1021,7 @@ class _AgentDetailScreenState extends ConsumerState<AgentDetailScreen> {
|
|||||||
// Best experience (always show)
|
// Best experience (always show)
|
||||||
_buildInfoCard(
|
_buildInfoCard(
|
||||||
icon: Icons.star_rounded,
|
icon: Icons.star_rounded,
|
||||||
title: 'Best Experience',
|
title: state.bestExperienceLabel,
|
||||||
subtitle: '',
|
subtitle: '',
|
||||||
description: bestExp.isNotEmpty ? bestExp : 'Not specified',
|
description: bestExp.isNotEmpty ? bestExp : 'Not specified',
|
||||||
isEmpty: bestExp.isEmpty,
|
isEmpty: bestExp.isEmpty,
|
||||||
|
|||||||
@@ -1052,7 +1052,7 @@ class _AgentHomeContentState extends ConsumerState<_AgentHomeContent> {
|
|||||||
// Availability card (with title — matches web)
|
// Availability card (with title — matches web)
|
||||||
_buildInfoCard(
|
_buildInfoCard(
|
||||||
icon: Icons.access_time_filled,
|
icon: Icons.access_time_filled,
|
||||||
title: 'Availability',
|
title: state.availabilityLabel,
|
||||||
subtitle: state.availabilityType.isNotEmpty
|
subtitle: state.availabilityType.isNotEmpty
|
||||||
? state.availabilityType
|
? state.availabilityType
|
||||||
: 'Not specified',
|
: 'Not specified',
|
||||||
@@ -1062,18 +1062,18 @@ class _AgentHomeContentState extends ConsumerState<_AgentHomeContent> {
|
|||||||
isEmpty: state.availabilityType.isEmpty,
|
isEmpty: state.availabilityType.isEmpty,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
// Work environment (no title — matches web)
|
// Work environment
|
||||||
_buildInfoCard(
|
_buildInfoCard(
|
||||||
icon: Icons.landscape_outlined,
|
icon: Icons.landscape_outlined,
|
||||||
title: '',
|
title: state.workEnvironmentLabel,
|
||||||
subtitle: '',
|
subtitle: '',
|
||||||
description: workEnv,
|
description: workEnv,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
// Testimonial preview (no title — matches web)
|
// Testimonial preview
|
||||||
_buildInfoCard(
|
_buildInfoCard(
|
||||||
icon: Icons.star_rounded,
|
icon: Icons.star_rounded,
|
||||||
title: '',
|
title: state.bestExperienceLabel,
|
||||||
subtitle: '',
|
subtitle: '',
|
||||||
description: testimonialText.isNotEmpty
|
description: testimonialText.isNotEmpty
|
||||||
? '\u201C$testimonialText\u201D'
|
? '\u201C$testimonialText\u201D'
|
||||||
|
|||||||
Reference in New Issue
Block a user