feat: add AI recommendations flow for tenders
Implement company AI onboarding/recommendation models, services, repository, and tender UI integration with supporting tests. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tm_app/data/repositories/auth_repository.dart';
|
||||
import 'package:tm_app/data/repositories/company_ai_repository.dart';
|
||||
import 'package:tm_app/data/services/model/company_profile_data/company_profile_data.dart';
|
||||
import 'package:tm_app/data/services/model/company_profile_response/company_profile_response.dart';
|
||||
import 'package:tm_app/data/services/model/profile_data/profile_data.dart';
|
||||
@@ -12,12 +15,15 @@ import '../data/services/model/profile_response/profile_response.dart';
|
||||
class ProfileViewModel with ChangeNotifier {
|
||||
final ProfileRepository _profileRepository;
|
||||
final AuthRepository _authRepository;
|
||||
final CompanyAiRepository _companyAiRepository;
|
||||
|
||||
ProfileViewModel({
|
||||
required ProfileRepository profileRepository,
|
||||
required AuthRepository authRepository,
|
||||
required CompanyAiRepository companyAiRepository,
|
||||
}) : _profileRepository = profileRepository,
|
||||
_authRepository = authRepository;
|
||||
_authRepository = authRepository,
|
||||
_companyAiRepository = companyAiRepository;
|
||||
|
||||
bool _isLoading = false;
|
||||
String? _errorMessage;
|
||||
@@ -62,6 +68,7 @@ class ProfileViewModel with ChangeNotifier {
|
||||
switch (result) {
|
||||
case Ok<CompanyProfileResponse>():
|
||||
_companyProfileData = result.value.data;
|
||||
_maybeStartAiOnboarding(_companyProfileData);
|
||||
break;
|
||||
case Error<CompanyProfileResponse>():
|
||||
_errorMessage = result.error.toString();
|
||||
@@ -73,6 +80,22 @@ class ProfileViewModel with ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// Best-effort AI onboarding once the company profile is ready. Fire-and-
|
||||
/// forget: onboarding is asynchronous on the AI side and the fingerprint
|
||||
/// guard in [CompanyAiRepository] keeps it from re-running unnecessarily, so
|
||||
/// the profile screen never blocks or surfaces errors for it.
|
||||
void _maybeStartAiOnboarding(CompanyProfileData? company) {
|
||||
if (company == null) {
|
||||
return;
|
||||
}
|
||||
unawaited(
|
||||
_companyAiRepository.maybeStartOnboarding(
|
||||
documentFileIds: company.documentFileIds ?? const [],
|
||||
website: company.website,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> logout() async {
|
||||
_errorMessage = null;
|
||||
notifyListeners();
|
||||
|
||||
Reference in New Issue
Block a user