update mobile design
This commit is contained in:
@@ -8,12 +8,6 @@ final agentsRepositoryProvider = Provider<AgentsRepository>((ref) {
|
||||
return AgentsRepository();
|
||||
});
|
||||
|
||||
// Agent types provider
|
||||
final agentTypesProvider = FutureProvider<List<AgentType>>((ref) async {
|
||||
final repository = ref.watch(agentsRepositoryProvider);
|
||||
return repository.getAgentTypes();
|
||||
});
|
||||
|
||||
// Top professionals state
|
||||
class TopProfessionalsState {
|
||||
final List<AgentProfile> agents;
|
||||
@@ -70,16 +64,30 @@ class TopProfessionalsNotifier extends StateNotifier<TopProfessionalsState> {
|
||||
final agentTypes = await _repository.getAgentTypes();
|
||||
state = state.copyWith(agentTypes: agentTypes);
|
||||
|
||||
// Find agent and lender type IDs
|
||||
// Find agent and lender type IDs by name
|
||||
String? agentTypeId;
|
||||
String? lenderTypeId;
|
||||
|
||||
for (final type in agentTypes) {
|
||||
final slug = type.slug.toLowerCase();
|
||||
if (slug.contains('agent')) {
|
||||
agentTypeId = type.id;
|
||||
} else if (slug.contains('lender')) {
|
||||
final name = type.name.toLowerCase();
|
||||
if (name.contains('lender') || name.contains('lending')) {
|
||||
lenderTypeId = type.id;
|
||||
} else if (name.contains('agent') ||
|
||||
name.contains('realtor') ||
|
||||
name.contains('broker')) {
|
||||
agentTypeId = type.id;
|
||||
}
|
||||
}
|
||||
|
||||
// If no specific agent type found, use first type as agents
|
||||
if (agentTypeId == null && agentTypes.isNotEmpty) {
|
||||
agentTypeId = agentTypes.first.id;
|
||||
// Look for lender in remaining
|
||||
for (final type in agentTypes) {
|
||||
if (type.id != agentTypeId) {
|
||||
lenderTypeId = type.id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,23 +99,24 @@ class TopProfessionalsNotifier extends StateNotifier<TopProfessionalsState> {
|
||||
sortBy: 'averageRating',
|
||||
sortOrder: 'desc',
|
||||
),
|
||||
_repository.searchAgents(
|
||||
agentTypeId: lenderTypeId,
|
||||
limit: 10,
|
||||
sortBy: 'averageRating',
|
||||
sortOrder: 'desc',
|
||||
),
|
||||
if (lenderTypeId != null)
|
||||
_repository.searchAgents(
|
||||
agentTypeId: lenderTypeId,
|
||||
limit: 10,
|
||||
sortBy: 'averageRating',
|
||||
sortOrder: 'desc',
|
||||
),
|
||||
]);
|
||||
|
||||
state = state.copyWith(
|
||||
agents: results[0].data,
|
||||
lenders: results[1].data,
|
||||
lenders: results.length > 1 ? results[1].data : [],
|
||||
isLoading: false,
|
||||
);
|
||||
} catch (e) {
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
error: 'Failed to load professionals',
|
||||
error: e.toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user