36 lines
1.0 KiB
Dart
36 lines
1.0 KiB
Dart
import 'package:rasadyar_chicken/data/di/chicken_di.dart';
|
|
import 'package:rasadyar_chicken/features/common/data/repositories/common/common_repository.dart';
|
|
import 'package:rasadyar_core/core.dart';
|
|
|
|
import '../../../features/common/data/model/response/user_profile/user_profile.dart';
|
|
|
|
class ChickenBaseLogic extends BasePageLogic {
|
|
var tokenService = Get.find<TokenStorageService>();
|
|
CommonRepository commonRepository = diChicken.get<CommonRepository>();
|
|
|
|
Rx<Resource<UserProfile>> userProfile = Rx<Resource<UserProfile>>(
|
|
Resource.loading(),
|
|
);
|
|
|
|
@override
|
|
void onInit() {
|
|
super.onInit();
|
|
getUserProfile();
|
|
}
|
|
|
|
Future<void> getUserProfile() async {
|
|
userProfile.value = Resource.loading();
|
|
await safeCall<UserProfile?>(
|
|
call: () async => await commonRepository.getUserProfile(
|
|
token: tokenService.accessToken.value!,
|
|
),
|
|
onSuccess: (result) {
|
|
if (result != null) {
|
|
userProfile.value = Resource.success(result);
|
|
}
|
|
},
|
|
onError: (error, stackTrace) {},
|
|
);
|
|
}
|
|
}
|