Compare commits
No commits in common. "003c8b7c0d7e9450d17a5d1e6121fef9c1e3c703" and "f19a316be86aa3157612d3d5a81c6a49a827b489" have entirely different histories.
003c8b7c0d
...
f19a316be8
19 changed files with 150 additions and 423 deletions
|
|
@ -12,7 +12,6 @@ import 'package:mzansi_innovation_hub/mih_config/mih_go_router.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_hive/hive_registrar.g.dart';
|
import 'package:mzansi_innovation_hub/mih_hive/hive_registrar.g.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/app_user.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/app_user.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/business.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/business.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/business_employee.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/business_user.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/business_user.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/profile_link.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/profile_link.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/user_consent.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/user_consent.dart';
|
||||||
|
|
@ -37,8 +36,6 @@ void main() async {
|
||||||
await Hive.openBox<UserConsent>('user_consent_box');
|
await Hive.openBox<UserConsent>('user_consent_box');
|
||||||
await Hive.openBox<String>('image_urls_box');
|
await Hive.openBox<String>('image_urls_box');
|
||||||
await Hive.openBox<ProfileLink>('personal_profile_links_box');
|
await Hive.openBox<ProfileLink>('personal_profile_links_box');
|
||||||
await Hive.openBox<ProfileLink>('business_profile_links_box');
|
|
||||||
await Hive.openBox<BusinessEmployee>('business_employees_box');
|
|
||||||
|
|
||||||
// await Firebase.initializeApp(
|
// await Firebase.initializeApp(
|
||||||
// // options: DefaultFirebaseOptions.currentPlatform,
|
// // options: DefaultFirebaseOptions.currentPlatform,
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,9 @@ class MihGoRouter {
|
||||||
path: MihGoRouterPaths.mihHome,
|
path: MihGoRouterPaths.mihHome,
|
||||||
builder: (BuildContext context, GoRouterState state) {
|
builder: (BuildContext context, GoRouterState state) {
|
||||||
KenLogger.success("MihGoRouter: mihHome");
|
KenLogger.success("MihGoRouter: mihHome");
|
||||||
return MihHome();
|
return MihHome(
|
||||||
|
key: UniqueKey(),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
routes: [
|
routes: [
|
||||||
// ========================== About MIH ==================================
|
// ========================== About MIH ==================================
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
import 'package:hive_ce/hive_ce.dart';
|
import 'package:hive_ce/hive_ce.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/app_user.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/app_user.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/business.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/business.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/business_employee.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/business_user.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/business_user.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/profile_link.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/profile_link.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/user_consent.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/user_consent.dart';
|
||||||
|
|
@ -13,6 +12,5 @@ import 'package:mzansi_innovation_hub/mih_objects/user_consent.dart';
|
||||||
AdapterSpec<BusinessUser>(),
|
AdapterSpec<BusinessUser>(),
|
||||||
AdapterSpec<UserConsent>(),
|
AdapterSpec<UserConsent>(),
|
||||||
AdapterSpec<ProfileLink>(),
|
AdapterSpec<ProfileLink>(),
|
||||||
AdapterSpec<BusinessEmployee>(),
|
|
||||||
])
|
])
|
||||||
part 'hive_adapters.g.dart';
|
part 'hive_adapters.g.dart';
|
||||||
|
|
|
||||||
|
|
@ -283,58 +283,3 @@ class ProfileLinkAdapter extends TypeAdapter<ProfileLink> {
|
||||||
runtimeType == other.runtimeType &&
|
runtimeType == other.runtimeType &&
|
||||||
typeId == other.typeId;
|
typeId == other.typeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
class BusinessEmployeeAdapter extends TypeAdapter<BusinessEmployee> {
|
|
||||||
@override
|
|
||||||
final typeId = 5;
|
|
||||||
|
|
||||||
@override
|
|
||||||
BusinessEmployee read(BinaryReader reader) {
|
|
||||||
final numOfFields = reader.readByte();
|
|
||||||
final fields = <int, dynamic>{
|
|
||||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
|
||||||
};
|
|
||||||
return BusinessEmployee(
|
|
||||||
fields[0] as String,
|
|
||||||
fields[1] as String,
|
|
||||||
fields[2] as String,
|
|
||||||
fields[3] as String,
|
|
||||||
fields[4] as String,
|
|
||||||
fields[5] as String,
|
|
||||||
fields[6] as String,
|
|
||||||
fields[7] as String,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void write(BinaryWriter writer, BusinessEmployee obj) {
|
|
||||||
writer
|
|
||||||
..writeByte(8)
|
|
||||||
..writeByte(0)
|
|
||||||
..write(obj.business_id)
|
|
||||||
..writeByte(1)
|
|
||||||
..write(obj.app_id)
|
|
||||||
..writeByte(2)
|
|
||||||
..write(obj.title)
|
|
||||||
..writeByte(3)
|
|
||||||
..write(obj.access)
|
|
||||||
..writeByte(4)
|
|
||||||
..write(obj.fname)
|
|
||||||
..writeByte(5)
|
|
||||||
..write(obj.lname)
|
|
||||||
..writeByte(6)
|
|
||||||
..write(obj.email)
|
|
||||||
..writeByte(7)
|
|
||||||
..write(obj.username);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => typeId.hashCode;
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) =>
|
|
||||||
identical(this, other) ||
|
|
||||||
other is BusinessEmployeeAdapter &&
|
|
||||||
runtimeType == other.runtimeType &&
|
|
||||||
typeId == other.typeId;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# Generated by Hive CE
|
# Generated by Hive CE
|
||||||
# Manual modifications may be necessary for certain migrations
|
# Manual modifications may be necessary for certain migrations
|
||||||
# Check in to version control
|
# Check in to version control
|
||||||
nextTypeId: 6
|
nextTypeId: 5
|
||||||
types:
|
types:
|
||||||
AppUser:
|
AppUser:
|
||||||
typeId: 0
|
typeId: 0
|
||||||
|
|
@ -105,23 +105,3 @@ types:
|
||||||
index: 5
|
index: 5
|
||||||
order:
|
order:
|
||||||
index: 6
|
index: 6
|
||||||
BusinessEmployee:
|
|
||||||
typeId: 5
|
|
||||||
nextIndex: 8
|
|
||||||
fields:
|
|
||||||
business_id:
|
|
||||||
index: 0
|
|
||||||
app_id:
|
|
||||||
index: 1
|
|
||||||
title:
|
|
||||||
index: 2
|
|
||||||
access:
|
|
||||||
index: 3
|
|
||||||
fname:
|
|
||||||
index: 4
|
|
||||||
lname:
|
|
||||||
index: 5
|
|
||||||
email:
|
|
||||||
index: 6
|
|
||||||
username:
|
|
||||||
index: 7
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ extension HiveRegistrar on HiveInterface {
|
||||||
void registerAdapters() {
|
void registerAdapters() {
|
||||||
registerAdapter(AppUserAdapter());
|
registerAdapter(AppUserAdapter());
|
||||||
registerAdapter(BusinessAdapter());
|
registerAdapter(BusinessAdapter());
|
||||||
registerAdapter(BusinessEmployeeAdapter());
|
|
||||||
registerAdapter(BusinessUserAdapter());
|
registerAdapter(BusinessUserAdapter());
|
||||||
registerAdapter(ProfileLinkAdapter());
|
registerAdapter(ProfileLinkAdapter());
|
||||||
registerAdapter(UserConsentAdapter());
|
registerAdapter(UserConsentAdapter());
|
||||||
|
|
@ -20,7 +19,6 @@ extension IsolatedHiveRegistrar on IsolatedHiveInterface {
|
||||||
void registerAdapters() {
|
void registerAdapters() {
|
||||||
registerAdapter(AppUserAdapter());
|
registerAdapter(AppUserAdapter());
|
||||||
registerAdapter(BusinessAdapter());
|
registerAdapter(BusinessAdapter());
|
||||||
registerAdapter(BusinessEmployeeAdapter());
|
|
||||||
registerAdapter(BusinessUserAdapter());
|
registerAdapter(BusinessUserAdapter());
|
||||||
registerAdapter(ProfileLinkAdapter());
|
registerAdapter(ProfileLinkAdapter());
|
||||||
registerAdapter(UserConsentAdapter());
|
registerAdapter(UserConsentAdapter());
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,10 @@ import 'package:hive_ce_flutter/hive_ce_flutter.dart';
|
||||||
import 'package:ken_logger/ken_logger.dart';
|
import 'package:ken_logger/ken_logger.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/app_user.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/app_user.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/business.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/business.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/business_employee.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/business_user.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/business_user.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/profile_link.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/profile_link.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/user_consent.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/user_consent.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_business_details_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_business_details_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_business_employee_services.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_my_business_user_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_my_business_user_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_profile_links_service.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_profile_links_service.dart';
|
||||||
|
|
@ -23,10 +21,7 @@ class MzansiProfileHiveData {
|
||||||
Hive.box<UserConsent>('user_consent_box');
|
Hive.box<UserConsent>('user_consent_box');
|
||||||
final Box<ProfileLink> _personalProfileLinksBox =
|
final Box<ProfileLink> _personalProfileLinksBox =
|
||||||
Hive.box<ProfileLink>('personal_profile_links_box');
|
Hive.box<ProfileLink>('personal_profile_links_box');
|
||||||
final Box<ProfileLink> _businessProfileLinksBox =
|
|
||||||
Hive.box<ProfileLink>('business_profile_links_box');
|
|
||||||
final Box<BusinessEmployee> _businessEmployeesBox =
|
|
||||||
Hive.box<BusinessEmployee>('business_Employees_box');
|
|
||||||
final Box<String> _resolvedUrlsBox = Hive.box<String>('image_urls_box');
|
final Box<String> _resolvedUrlsBox = Hive.box<String>('image_urls_box');
|
||||||
|
|
||||||
static const String kUserKey = 'current_user';
|
static const String kUserKey = 'current_user';
|
||||||
|
|
@ -37,7 +32,6 @@ class MzansiProfileHiveData {
|
||||||
static const String kBusinessPicUrlKey = 'business_pic_url';
|
static const String kBusinessPicUrlKey = 'business_pic_url';
|
||||||
static const String kSignatureUrlKey = 'signature_url';
|
static const String kSignatureUrlKey = 'signature_url';
|
||||||
|
|
||||||
// Get Data from local storage
|
|
||||||
AppUser? getCachedUser() => _userBox.get(kUserKey);
|
AppUser? getCachedUser() => _userBox.get(kUserKey);
|
||||||
Business? getCachedBusiness() => _businessBox.get(kBusinessKey);
|
Business? getCachedBusiness() => _businessBox.get(kBusinessKey);
|
||||||
BusinessUser? getCachedBusinessUser() =>
|
BusinessUser? getCachedBusinessUser() =>
|
||||||
|
|
@ -46,26 +40,12 @@ class MzansiProfileHiveData {
|
||||||
String? getCachedUserPicUrl() => _resolvedUrlsBox.get(kUserPicUrlKey);
|
String? getCachedUserPicUrl() => _resolvedUrlsBox.get(kUserPicUrlKey);
|
||||||
String? getCachedBusinessPicUrl() => _resolvedUrlsBox.get(kBusinessPicUrlKey);
|
String? getCachedBusinessPicUrl() => _resolvedUrlsBox.get(kBusinessPicUrlKey);
|
||||||
String? getCachedSignatureUrl() => _resolvedUrlsBox.get(kSignatureUrlKey);
|
String? getCachedSignatureUrl() => _resolvedUrlsBox.get(kSignatureUrlKey);
|
||||||
|
|
||||||
List<ProfileLink> getCachedPersonalProfileLinks() {
|
List<ProfileLink> getCachedPersonalProfileLinks() {
|
||||||
final links = _personalProfileLinksBox.values.toList();
|
final links = _personalProfileLinksBox.values.toList();
|
||||||
links.sort((a, b) => a.order.compareTo(b.order));
|
links.sort((a, b) => a.order.compareTo(b.order));
|
||||||
return links;
|
return links;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ProfileLink> getCachedBusinessProfileLinks() {
|
|
||||||
final links = _businessProfileLinksBox.values.toList();
|
|
||||||
links.sort((a, b) => a.order.compareTo(b.order));
|
|
||||||
return links;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<BusinessEmployee> getCachedBusinessEmployees() {
|
|
||||||
final employees = _businessEmployeesBox.values.toList();
|
|
||||||
employees.sort((a, b) => a.fname.compareTo(b.fname));
|
|
||||||
return employees;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Caching Data to local storage
|
|
||||||
Future<void> cacheUserData(AppUser remoteUser) async {
|
Future<void> cacheUserData(AppUser remoteUser) async {
|
||||||
await _userBox.put(kUserKey, remoteUser);
|
await _userBox.put(kUserKey, remoteUser);
|
||||||
if (remoteUser.pro_pic_path.isNotEmpty) {
|
if (remoteUser.pro_pic_path.isNotEmpty) {
|
||||||
|
|
@ -73,12 +53,10 @@ class MzansiProfileHiveData {
|
||||||
await MihFileApi.getMinioFileUrl(remoteUser.pro_pic_path);
|
await MihFileApi.getMinioFileUrl(remoteUser.pro_pic_path);
|
||||||
await _resolvedUrlsBox.put(kUserPicUrlKey, userPicUrl);
|
await _resolvedUrlsBox.put(kUserPicUrlKey, userPicUrl);
|
||||||
}
|
}
|
||||||
KenLogger.success("User Profile Cached");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> cacheUserConsentData(UserConsent remoteConsent) async {
|
Future<void> cacheUserConsentData(UserConsent remoteConsent) async {
|
||||||
await _userConsentBox.put(kConsentKey, remoteConsent);
|
await _userConsentBox.put(kConsentKey, remoteConsent);
|
||||||
KenLogger.success("User Consent Cached");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> cacheBusinessData(Business remoteBusiness) async {
|
Future<void> cacheBusinessData(Business remoteBusiness) async {
|
||||||
|
|
@ -93,7 +71,6 @@ class MzansiProfileHiveData {
|
||||||
if (remoteBizUser != null) {
|
if (remoteBizUser != null) {
|
||||||
cacheBusinessUserData(remoteBizUser);
|
cacheBusinessUserData(remoteBizUser);
|
||||||
}
|
}
|
||||||
KenLogger.success("Busines Profile Cached");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> cacheBusinessUserData(BusinessUser remoteBizUser) async {
|
Future<void> cacheBusinessUserData(BusinessUser remoteBizUser) async {
|
||||||
|
|
@ -103,64 +80,36 @@ class MzansiProfileHiveData {
|
||||||
await MihFileApi.getMinioFileUrl(remoteBizUser.sig_path);
|
await MihFileApi.getMinioFileUrl(remoteBizUser.sig_path);
|
||||||
await _resolvedUrlsBox.put(kSignatureUrlKey, signatureUrl);
|
await _resolvedUrlsBox.put(kSignatureUrlKey, signatureUrl);
|
||||||
}
|
}
|
||||||
KenLogger.success("Busines User Profile Cached");
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> cacheBusinessEmployeesData(
|
|
||||||
List<BusinessEmployee> remoteBusinessEmployeeList) async {
|
|
||||||
await _businessEmployeesBox.clear();
|
|
||||||
await _businessEmployeesBox.addAll(remoteBusinessEmployeeList);
|
|
||||||
KenLogger.success("Business Employees Cached");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> cachePersonalProfileLinksData(
|
Future<void> cachePersonalProfileLinksData(
|
||||||
List<ProfileLink> remotePersonalLinks) async {
|
List<ProfileLink> remoteLinks) async {
|
||||||
await _personalProfileLinksBox.clear();
|
await _personalProfileLinksBox.clear();
|
||||||
await _personalProfileLinksBox.addAll(remotePersonalLinks);
|
await _personalProfileLinksBox.addAll(remoteLinks);
|
||||||
KenLogger.success("Personal Profile Links Cached");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> cacheBusinessProfileLinksData(
|
Future<void> syncProfileDataWithServer() async {
|
||||||
List<ProfileLink> remoteBusinessLinks) async {
|
|
||||||
await _businessProfileLinksBox.clear();
|
|
||||||
await _businessProfileLinksBox.addAll(remoteBusinessLinks);
|
|
||||||
KenLogger.success("Personal Profile Links Cached");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sync Local Data from data from MIH Server
|
|
||||||
Future<bool> syncProfileDataWithServer() async {
|
|
||||||
try {
|
try {
|
||||||
AppUser? remoteUser = await MihUserServices().getMyUserDetailsV2();
|
AppUser? remoteUser = await MihUserServices().getMyUserDetailsV2();
|
||||||
if (remoteUser != null) {
|
if (remoteUser != null) {
|
||||||
cacheUserData(remoteUser);
|
cacheUserData(remoteUser);
|
||||||
|
|
||||||
UserConsent? remoteConsent =
|
UserConsent? remoteConsent =
|
||||||
await MihUserConsentServices().getUserConsentStatusV2();
|
await MihUserConsentServices().getUserConsentStatusV2();
|
||||||
if (remoteConsent != null) {
|
if (remoteConsent != null) {
|
||||||
cacheUserConsentData(remoteConsent);
|
cacheUserConsentData(remoteConsent);
|
||||||
}
|
}
|
||||||
final remotePersonalLinks =
|
final remoteLinks = await MihProfileLinksServices.getUserProfileLinksV2(
|
||||||
await MihProfileLinksServices.getUserProfileLinksV2(
|
|
||||||
remoteUser.app_id);
|
remoteUser.app_id);
|
||||||
cachePersonalProfileLinksData(remotePersonalLinks);
|
await cachePersonalProfileLinksData(remoteLinks);
|
||||||
}
|
}
|
||||||
Business? remoteBusiness =
|
Business? remoteBusiness =
|
||||||
await MihBusinessDetailsServices().getBusinessDetailsByUserV2();
|
await MihBusinessDetailsServices().getBusinessDetailsByUserV2();
|
||||||
if (remoteBusiness != null) {
|
if (remoteBusiness != null) {
|
||||||
cacheBusinessData(remoteBusiness);
|
cacheBusinessData(remoteBusiness);
|
||||||
|
|
||||||
final remoteBusinessEmployeeList = await MihBusinessEmployeeServices()
|
|
||||||
.fetchEmployeesV2(remoteBusiness.business_id);
|
|
||||||
cacheBusinessEmployeesData(remoteBusinessEmployeeList);
|
|
||||||
|
|
||||||
final remoteBusinessLinks =
|
|
||||||
await MihProfileLinksServices.getBusinessProfileLinksV2(
|
|
||||||
remoteBusiness.business_id);
|
|
||||||
cacheBusinessProfileLinksData(remoteBusinessLinks);
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
KenLogger.warning("App Operating in Offline Mode. Sync Paused");
|
KenLogger.warning("App operating offline mode. Sync paused");
|
||||||
return false;
|
|
||||||
// KenLogger.warning("App operating offline mode. Sync paused: $error");
|
// KenLogger.warning("App operating offline mode. Sync paused: $error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,7 @@ class _MihHomeState extends State<MihHome> {
|
||||||
context.read<MzansiProfileProvider>();
|
context.read<MzansiProfileProvider>();
|
||||||
mzansiProfileProvider.loadCachedProfileState();
|
mzansiProfileProvider.loadCachedProfileState();
|
||||||
if (mzansiProfileProvider.user == null) {
|
if (mzansiProfileProvider.user == null) {
|
||||||
await mzansiProfileProvider.syncWithMihServerData();
|
await mzansiProfileProvider.syncWithCloudPipeline();
|
||||||
} else {
|
|
||||||
mzansiProfileProvider.syncWithMihServerData();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,22 +84,8 @@ class _MihHomeState extends State<MihHome> {
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
RefreshIndicator(
|
RefreshIndicator(
|
||||||
key: mzansiProfileProvider.refreshIndicatorKey,
|
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
bool success =
|
await mzansiProfileProvider.syncWithCloudPipeline();
|
||||||
await mzansiProfileProvider.syncWithMihServerData();
|
|
||||||
if (context.mounted) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
MihSnackBar(
|
|
||||||
child: Text(
|
|
||||||
success
|
|
||||||
? "Data Synced with MIH Server."
|
|
||||||
: "MIH App operation in Offline Mode",
|
|
||||||
),
|
|
||||||
// backgroundColor: success ? null : MihColors.red(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
|
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:mih_package_toolkit/mih_package_toolkit.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
class MihHomeRefreshTile extends StatefulWidget {
|
|
||||||
final double packageSize;
|
|
||||||
const MihHomeRefreshTile({
|
|
||||||
super.key,
|
|
||||||
required this.packageSize,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<MihHomeRefreshTile> createState() => _MihHomeRefreshTileState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MihHomeRefreshTileState extends State<MihHomeRefreshTile> {
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Consumer<MzansiProfileProvider>(
|
|
||||||
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
|
||||||
Widget? child) {
|
|
||||||
return MihPackageTile(
|
|
||||||
onTap: profileProvider.triggerRefresh,
|
|
||||||
packageName: "Sync Data",
|
|
||||||
packageIcon: Stack(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
MihIcons.mihRing,
|
|
||||||
color: MihColors.secondary(),
|
|
||||||
),
|
|
||||||
Center(
|
|
||||||
child: Transform.scale(
|
|
||||||
scale: 0.75,
|
|
||||||
origin: Offset(-4, 0),
|
|
||||||
child: Icon(
|
|
||||||
Icons.cloud_sync_rounded,
|
|
||||||
color: MihColors.secondary(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
iconSize: widget.packageSize,
|
|
||||||
textColor: MihColors.secondary(),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -2,7 +2,6 @@ import 'package:go_router/go_router.dart';
|
||||||
import 'package:mih_package_toolkit/mih_package_toolkit.dart';
|
import 'package:mih_package_toolkit/mih_package_toolkit.dart';
|
||||||
import 'package:mzansi_innovation_hub/main.dart';
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/arguments.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/arguments.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mih_home/package_tile/mih_home_refresh_tile.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_ai_provider.dart';
|
import 'package:mzansi_innovation_hub/mih_providers/mzansi_ai_provider.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/about_mih/package_tile/about_mih_tile.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/about_mih/package_tile/about_mih_tile.dart';
|
||||||
|
|
@ -130,12 +129,6 @@ class _MihBusinessHomeState extends State<MihBusinessHome>
|
||||||
packageSize: packageSize,
|
packageSize: packageSize,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
//=============== About MIH ===============
|
|
||||||
temp.add({
|
|
||||||
"Sync Data": MihHomeRefreshTile(
|
|
||||||
packageSize: packageSize,
|
|
||||||
)
|
|
||||||
});
|
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import 'package:mih_package_toolkit/mih_package_toolkit.dart';
|
||||||
import 'package:mzansi_innovation_hub/main.dart';
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_package_components/Example/package_tiles/test_package_tile.dart';
|
import 'package:mzansi_innovation_hub/mih_package_components/Example/package_tiles/test_package_tile.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mih_home/package_tile/mih_home_refresh_tile.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tiles/mzansi_setup_business_profile_tile.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tiles/mzansi_setup_business_profile_tile.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_ai_provider.dart';
|
import 'package:mzansi_innovation_hub/mih_providers/mzansi_ai_provider.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/about_mih/package_tile/about_mih_tile.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/about_mih/package_tile/about_mih_tile.dart';
|
||||||
|
|
@ -139,12 +138,6 @@ class _MihPersonalHomeState extends State<MihPersonalHome>
|
||||||
packageSize: packageSize,
|
packageSize: packageSize,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
//=============== About MIH ===============
|
|
||||||
temp.add({
|
|
||||||
"Sync Data": MihHomeRefreshTile(
|
|
||||||
packageSize: packageSize,
|
|
||||||
)
|
|
||||||
});
|
|
||||||
//=============== Dev ===============
|
//=============== Dev ===============
|
||||||
if (AppEnviroment.getEnv() == "Dev") {
|
if (AppEnviroment.getEnv() == "Dev") {
|
||||||
temp.add({
|
temp.add({
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ class BusinesProfile extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _BusinesProfileState extends State<BusinesProfile> {
|
class _BusinesProfileState extends State<BusinesProfile> {
|
||||||
// bool _isLoadingInitialData = true;
|
bool _isLoadingInitialData = true;
|
||||||
late final MihBusinessDetails _businessDetails;
|
late final MihBusinessDetails _businessDetails;
|
||||||
late final MihMyBusinessUser _businessUser;
|
late final MihMyBusinessUser _businessUser;
|
||||||
late final MihMyBusinessTeam _businessTeam;
|
late final MihMyBusinessTeam _businessTeam;
|
||||||
|
|
@ -31,18 +31,26 @@ class _BusinesProfileState extends State<BusinesProfile> {
|
||||||
late final MihBusinessQrCode _businessQrCode;
|
late final MihBusinessQrCode _businessQrCode;
|
||||||
late final MihBusinessLinks _businessLinks;
|
late final MihBusinessLinks _businessLinks;
|
||||||
|
|
||||||
// Future<void> _loadInitialData() async {
|
Future<void> _loadInitialData() async {
|
||||||
// MzansiProfileProvider mzansiProfileProvider =
|
setState(() {
|
||||||
// context.read<MzansiProfileProvider>();
|
_isLoadingInitialData = true;
|
||||||
// mzansiProfileProvider.loadCachedProfileState();
|
});
|
||||||
// if (mzansiProfileProvider.user == null) {
|
MzansiProfileProvider mzansiProfileProvider =
|
||||||
// mzansiProfileProvider.syncWithMihServerData();
|
context.read<MzansiProfileProvider>();
|
||||||
// }
|
if (mzansiProfileProvider.user == null) {
|
||||||
// setState(() {
|
await MihDataHelperServices().loadUserDataWithBusinessesData(
|
||||||
// _isLoadingInitialData = false;
|
mzansiProfileProvider,
|
||||||
// });
|
);
|
||||||
// }
|
}
|
||||||
//
|
await MihProfileLinksServices.getBusinessProfileLinks(
|
||||||
|
mzansiProfileProvider, mzansiProfileProvider.business!.business_id);
|
||||||
|
await MihBusinessEmployeeServices()
|
||||||
|
.fetchEmployees(mzansiProfileProvider, context);
|
||||||
|
setState(() {
|
||||||
|
_isLoadingInitialData = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
@ -53,7 +61,7 @@ class _BusinesProfileState extends State<BusinesProfile> {
|
||||||
_businessReviews = MihBusinessReviews(business: null);
|
_businessReviews = MihBusinessReviews(business: null);
|
||||||
_businessLinks = MihBusinessLinks(viewMode: false);
|
_businessLinks = MihBusinessLinks(viewMode: false);
|
||||||
_businessQrCode = MihBusinessQrCode(business: null);
|
_businessQrCode = MihBusinessQrCode(business: null);
|
||||||
// _loadInitialData();
|
_loadInitialData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -61,13 +69,13 @@ class _BusinesProfileState extends State<BusinesProfile> {
|
||||||
return Consumer<MzansiProfileProvider>(
|
return Consumer<MzansiProfileProvider>(
|
||||||
builder: (BuildContext context,
|
builder: (BuildContext context,
|
||||||
MzansiProfileProvider mzansiProfileProvider, Widget? child) {
|
MzansiProfileProvider mzansiProfileProvider, Widget? child) {
|
||||||
// if (_isLoadingInitialData) {
|
if (_isLoadingInitialData) {
|
||||||
// return Scaffold(
|
return Scaffold(
|
||||||
// body: Center(
|
body: Center(
|
||||||
// child: Mihloadingcircle(),
|
child: Mihloadingcircle(),
|
||||||
// ),
|
),
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
return MihPackage(
|
return MihPackage(
|
||||||
packageActionButton: getAction(),
|
packageActionButton: getAction(),
|
||||||
packageTools: getTools(),
|
packageTools: getTools(),
|
||||||
|
|
|
||||||
|
|
@ -175,8 +175,6 @@ class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget displayBusinessQRCode(double profilePictureWidth) {
|
Widget displayBusinessQRCode(double profilePictureWidth) {
|
||||||
MzansiProfileProvider profileprovider =
|
|
||||||
context.read<MzansiProfileProvider>();
|
|
||||||
return Screenshot(
|
return Screenshot(
|
||||||
controller: screenshotController,
|
controller: screenshotController,
|
||||||
child: Material(
|
child: Material(
|
||||||
|
|
@ -195,19 +193,7 @@ class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
widget.business == null
|
FutureBuilder(
|
||||||
? MihCircleAvatar(
|
|
||||||
imageFile: profileprovider.businessProfilePicture,
|
|
||||||
width: profilePictureWidth,
|
|
||||||
expandable: true,
|
|
||||||
editable: false,
|
|
||||||
fileNameController: TextEditingController(),
|
|
||||||
userSelectedfile: file,
|
|
||||||
frameColor: MihColors.primary(),
|
|
||||||
backgroundColor: MihColors.secondary(),
|
|
||||||
onChange: () {},
|
|
||||||
)
|
|
||||||
: FutureBuilder(
|
|
||||||
future: futureImageUrl,
|
future: futureImageUrl,
|
||||||
builder: (context, asyncSnapshot) {
|
builder: (context, asyncSnapshot) {
|
||||||
if (asyncSnapshot.connectionState ==
|
if (asyncSnapshot.connectionState ==
|
||||||
|
|
|
||||||
|
|
@ -231,7 +231,7 @@ class _MihBusinessReviewsState extends State<MihBusinessReviews> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Center(child: Text('Error: MIH in Offline Mode'));
|
return Center(child: Text('Error'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,32 +17,32 @@ class MzansiProfile extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MzansiProfileState extends State<MzansiProfile> {
|
class _MzansiProfileState extends State<MzansiProfile> {
|
||||||
// bool _isLoadingInitialData = true;
|
bool _isLoadingInitialData = true;
|
||||||
late final MihPersonalProfile _personalProfile;
|
late final MihPersonalProfile _personalProfile;
|
||||||
late final MihPersonalQrCode _personalQrCode;
|
late final MihPersonalQrCode _personalQrCode;
|
||||||
late final MihPersonalSettings _personalSettings;
|
late final MihPersonalSettings _personalSettings;
|
||||||
|
|
||||||
// Future<void> _loadInitialData() async {
|
Future<void> _loadInitialData() async {
|
||||||
// MzansiProfileProvider mzansiProfileProvider =
|
MzansiProfileProvider mzansiProfileProvider =
|
||||||
// context.read<MzansiProfileProvider>();
|
context.read<MzansiProfileProvider>();
|
||||||
// if (mzansiProfileProvider.user == null) {
|
mzansiProfileProvider.loadCachedProfileState();
|
||||||
// mzansiProfileProvider.loadCachedProfileState();
|
if (mzansiProfileProvider.user == null) {
|
||||||
// mzansiProfileProvider.syncWithMihServerData();
|
mzansiProfileProvider.syncWithCloudPipeline();
|
||||||
// }
|
}
|
||||||
// setState(() {
|
setState(() {
|
||||||
// _isLoadingInitialData = false;
|
_isLoadingInitialData = false;
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_personalProfile = const MihPersonalProfile();
|
_personalProfile = const MihPersonalProfile();
|
||||||
_personalQrCode = const MihPersonalQrCode(user: null);
|
_personalQrCode = const MihPersonalQrCode(user: null);
|
||||||
_personalSettings = const MihPersonalSettings();
|
_personalSettings = const MihPersonalSettings();
|
||||||
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
// _loadInitialData();
|
_loadInitialData();
|
||||||
// });
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -50,13 +50,13 @@ class _MzansiProfileState extends State<MzansiProfile> {
|
||||||
return Consumer<MzansiProfileProvider>(
|
return Consumer<MzansiProfileProvider>(
|
||||||
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||||
Widget? child) {
|
Widget? child) {
|
||||||
// if (_isLoadingInitialData) {
|
if (_isLoadingInitialData) {
|
||||||
// return Scaffold(
|
return Scaffold(
|
||||||
// body: Center(
|
body: Center(
|
||||||
// child: Mihloadingcircle(),
|
child: Mihloadingcircle(),
|
||||||
// ),
|
),
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
return MihPackage(
|
return MihPackage(
|
||||||
packageActionButton: getAction(),
|
packageActionButton: getAction(),
|
||||||
packageTools: getTools(),
|
packageTools: getTools(),
|
||||||
|
|
|
||||||
|
|
@ -174,8 +174,6 @@ class _MihPersonalQrCodeState extends State<MihPersonalQrCode> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget displayPersonalQRCode(double profilePictureWidth) {
|
Widget displayPersonalQRCode(double profilePictureWidth) {
|
||||||
MzansiProfileProvider profileProvider =
|
|
||||||
context.read<MzansiProfileProvider>();
|
|
||||||
return Screenshot(
|
return Screenshot(
|
||||||
controller: screenshotController,
|
controller: screenshotController,
|
||||||
child: Material(
|
child: Material(
|
||||||
|
|
@ -194,19 +192,7 @@ class _MihPersonalQrCodeState extends State<MihPersonalQrCode> {
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
widget.user == null
|
FutureBuilder(
|
||||||
? MihCircleAvatar(
|
|
||||||
imageFile: profileProvider.userProfilePicture,
|
|
||||||
width: profilePictureWidth,
|
|
||||||
expandable: true,
|
|
||||||
editable: false,
|
|
||||||
fileNameController: TextEditingController(),
|
|
||||||
userSelectedfile: file,
|
|
||||||
frameColor: MihColors.primary(),
|
|
||||||
backgroundColor: MihColors.secondary(),
|
|
||||||
onChange: () {},
|
|
||||||
)
|
|
||||||
: FutureBuilder(
|
|
||||||
future: futureImageUrl,
|
future: futureImageUrl,
|
||||||
builder: (context, asyncSnapshot) {
|
builder: (context, asyncSnapshot) {
|
||||||
if (asyncSnapshot.connectionState ==
|
if (asyncSnapshot.connectionState ==
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:ken_logger/ken_logger.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_hive/mzansi_profile_hive_data.dart';
|
import 'package:mzansi_innovation_hub/mih_hive/mzansi_profile_hive_data.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/app_user.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/app_user.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/business.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/business.dart';
|
||||||
|
|
@ -30,8 +29,6 @@ class MzansiProfileProvider extends ChangeNotifier {
|
||||||
bool hideBusinessUserDetails;
|
bool hideBusinessUserDetails;
|
||||||
List<ProfileLink> personalLinks = [];
|
List<ProfileLink> personalLinks = [];
|
||||||
List<ProfileLink> businessLinks = [];
|
List<ProfileLink> businessLinks = [];
|
||||||
final GlobalKey<RefreshIndicatorState> refreshIndicatorKey =
|
|
||||||
GlobalKey<RefreshIndicatorState>();
|
|
||||||
|
|
||||||
MzansiProfileProvider(
|
MzansiProfileProvider(
|
||||||
this._hiveData, {
|
this._hiveData, {
|
||||||
|
|
@ -62,24 +59,14 @@ class MzansiProfileProvider extends ChangeNotifier {
|
||||||
businessUserSignature = CachedNetworkImageProvider(cachedSigUrl);
|
businessUserSignature = CachedNetworkImageProvider(cachedSigUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
employeeList = _hiveData.getCachedBusinessEmployees();
|
|
||||||
|
|
||||||
personalLinks = _hiveData.getCachedPersonalProfileLinks();
|
personalLinks = _hiveData.getCachedPersonalProfileLinks();
|
||||||
|
|
||||||
businessLinks = _hiveData.getCachedBusinessProfileLinks();
|
|
||||||
|
|
||||||
KenLogger.success("Mzansi Profile Loaded from Cache");
|
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> syncWithMihServerData() async {
|
Future<void> syncWithCloudPipeline() async {
|
||||||
bool success = await _hiveData.syncProfileDataWithServer();
|
await _hiveData.syncProfileDataWithServer();
|
||||||
loadCachedProfileState();
|
loadCachedProfileState();
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
void triggerRefresh() {
|
|
||||||
refreshIndicatorKey.currentState?.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
|
|
|
||||||
|
|
@ -25,19 +25,6 @@ class MihBusinessEmployeeServices {
|
||||||
return response.statusCode;
|
return response.statusCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<BusinessEmployee>> fetchEmployeesV2(String business_id) async {
|
|
||||||
final response = await http.get(Uri.parse(
|
|
||||||
"${AppEnviroment.baseApiUrl}/business-user/employees/${business_id}"));
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
Iterable l = jsonDecode(response.body);
|
|
||||||
List<BusinessEmployee> employeeList = List<BusinessEmployee>.from(
|
|
||||||
l.map((model) => BusinessEmployee.fromJson(model)));
|
|
||||||
return employeeList;
|
|
||||||
} else {
|
|
||||||
throw Exception('failed to load employees');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<int> addEmployee(
|
Future<int> addEmployee(
|
||||||
MzansiProfileProvider provider,
|
MzansiProfileProvider provider,
|
||||||
AppUser newEmployee,
|
AppUser newEmployee,
|
||||||
|
|
|
||||||
|
|
@ -89,21 +89,6 @@ class MihProfileLinksServices {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<List<ProfileLink>> getBusinessProfileLinksV2(
|
|
||||||
String business_id,
|
|
||||||
) async {
|
|
||||||
final response = await http.get(Uri.parse(
|
|
||||||
"${AppEnviroment.baseApiUrl}/profile-links/business/$business_id"));
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
Iterable l = jsonDecode(response.body);
|
|
||||||
List<ProfileLink> myLinks =
|
|
||||||
List<ProfileLink>.from(l.map((model) => ProfileLink.fromJson(model)));
|
|
||||||
return myLinks;
|
|
||||||
} else {
|
|
||||||
throw Exception('failed to fecth user profile links');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static Future<int> deleteProfileLink(
|
static Future<int> deleteProfileLink(
|
||||||
MzansiProfileProvider profileProvider,
|
MzansiProfileProvider profileProvider,
|
||||||
int idprofile_links,
|
int idprofile_links,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue