diff --git a/Frontend/patient_manager/lib/objects/arguments.dart b/Frontend/patient_manager/lib/objects/arguments.dart index 658fde63..3bc0a23a 100644 --- a/Frontend/patient_manager/lib/objects/arguments.dart +++ b/Frontend/patient_manager/lib/objects/arguments.dart @@ -16,6 +16,20 @@ class BusinessArguments { ); } +class HomeArguments { + final AppUser signedInUser; + final BusinessUser? businessUser; + final Business? business; + final String profilePicUrl; + + HomeArguments( + this.signedInUser, + this.businessUser, + this.business, + this.profilePicUrl, + ); +} + class AppProfileUpdateArguments { final AppUser signedInUser; final ImageProvider? propicFile; diff --git a/Frontend/patient_manager/lib/pages/home.dart b/Frontend/patient_manager/lib/pages/home.dart index 712cda66..dd941027 100644 --- a/Frontend/patient_manager/lib/pages/home.dart +++ b/Frontend/patient_manager/lib/pages/home.dart @@ -23,15 +23,16 @@ class Home extends StatefulWidget { class _HomeState extends State { String useremail = ""; final baseAPI = AppEnviroment.baseApiUrl; - late Future profile; + late Future profile; String proPicUrl = "empty"; ImageProvider? propicFile; - Future getProfile() async { + Future getProfile() async { AppUser userData; Business? busData; BusinessUser? bUserData; + String userPic; // Get Userdata var uid = await SuperTokens.getUserId(); @@ -72,15 +73,10 @@ class _HomeState extends State { } //get profile picture - if (proPicUrl != "empty") { - } else if (userData.pro_pic_path == "") { - setState(() { - proPicUrl = ""; - }); + if (userData.pro_pic_path == "") { + userPic = ""; } else if (AppEnviroment.getEnv() == "Dev") { - setState(() { - proPicUrl = "${AppEnviroment.baseFileUrl}/mih/${userData.pro_pic_path}"; - }); + userPic = "${AppEnviroment.baseFileUrl}/mih/${userData.pro_pic_path}"; } else { var url = "${AppEnviroment.baseApiUrl}/minio/pull/file/${userData.pro_pic_path}/prod"; @@ -89,16 +85,15 @@ class _HomeState extends State { if (response.statusCode == 200) { String body = response.body; var decodedData = jsonDecode(body); - setState(() { - proPicUrl = decodedData['minioURL']; - }); + + userPic = decodedData['minioURL']; } else { throw Exception( "Error: GetUserData status code ${response.statusCode}"); } } - return BusinessArguments(userData, bUserData, busData); + return HomeArguments(userData, bUserData, busData, userPic); } Future getUserDetails() async { @@ -194,7 +189,7 @@ class _HomeState extends State { signedInUser: snapshot.requireData.signedInUser, businessUser: snapshot.data!.businessUser, business: snapshot.data!.business, - propicFile: propicFile, + propicFile: NetworkImage(snapshot.data!.profilePicUrl), ); } else { return Center(