diff --git a/Frontend/lib/mih_apis/mih_api_calls.dart b/Frontend/lib/mih_apis/mih_api_calls.dart index 5975b5b4..feeab0d2 100644 --- a/Frontend/lib/mih_apis/mih_api_calls.dart +++ b/Frontend/lib/mih_apis/mih_api_calls.dart @@ -46,6 +46,7 @@ class MIHApiCalls { AppUser userData; Business? busData; BusinessUser? bUserData; + Patient? patientData; List notifi; String userPic; @@ -129,8 +130,30 @@ class MIHApiCalls { notifi = []; } + //get patient profile + //print("Patien manager page: $endpoint"); + final response = await http.get( + Uri.parse("${AppEnviroment.baseApiUrl}/patients/${userData.app_id}")); + // print("Here"); + // print("Body: ${response.body}"); + // print("Code: ${response.statusCode}"); + // var errorCode = response.statusCode.toString(); + // var errorBody = response.body; + + if (response.statusCode == 200) { + print("Here1"); + var decodedData = jsonDecode(response.body); + print("Here2"); + Patient patients = Patient.fromJson(decodedData as Map); + print("Here3"); + print(patients); + patientData = patients; + } else { + patientData = null; + } //print(userPic); - return HomeArguments(userData, bUserData, busData, notifi, userPic); + return HomeArguments( + userData, bUserData, busData, patientData, notifi, userPic); } /// This function is used to get business details by business _id. diff --git a/Frontend/lib/mih_objects/arguments.dart b/Frontend/lib/mih_objects/arguments.dart index 3b924bbf..8ed94de4 100644 --- a/Frontend/lib/mih_objects/arguments.dart +++ b/Frontend/lib/mih_objects/arguments.dart @@ -35,6 +35,7 @@ class HomeArguments { final AppUser signedInUser; final BusinessUser? businessUser; final Business? business; + final Patient? patient; final List notifi; final String profilePicUrl; @@ -42,6 +43,7 @@ class HomeArguments { this.signedInUser, this.businessUser, this.business, + this.patient, this.notifi, this.profilePicUrl, ); diff --git a/Frontend/lib/mih_packages/mih_home/mih_home.dart b/Frontend/lib/mih_packages/mih_home/mih_home.dart index 15b5e36f..d0fec1c4 100644 --- a/Frontend/lib/mih_packages/mih_home/mih_home.dart +++ b/Frontend/lib/mih_packages/mih_home/mih_home.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'dart:convert'; // import 'dart:convert'; +import 'package:Mzansi_Innovation_Hub/mih_objects/patients.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_swipe_detector/flutter_swipe_detector.dart'; @@ -43,6 +44,7 @@ class MIHHome extends StatefulWidget { final AppUser signedInUser; final BusinessUser? businessUser; final Business? business; + final Patient? patient; final List notifications; final ImageProvider? propicFile; final bool isUserNew; @@ -55,6 +57,7 @@ class MIHHome extends StatefulWidget { required this.signedInUser, required this.businessUser, required this.business, + required this.patient, required this.notifications, required this.propicFile, required this.isUserNew, @@ -169,29 +172,78 @@ class _MIHHomeState extends State { p: getPrim(), s: getSec(), )); - tileList.add(MIHTile( - videoID: "NUDdoWrbXNc", - onTap: () { - Navigator.of(context).pushNamed('/patient-profile', - arguments: PatientViewArguments( - widget.signedInUser, null, null, null, "personal")); - }, - tileName: "Patient Profile", - tileIcon: Center( - child: FaIcon( - FontAwesomeIcons.bookMedical, - color: getSec(), - size: 200, + print("Pat Prof: ${widget.patient}"); + if (widget.patient != null) { + tileList.add(MIHTile( + videoID: "NUDdoWrbXNc", + onTap: () { + Navigator.of(context).pushNamed('/patient-profile', + arguments: PatientViewArguments( + widget.signedInUser, null, null, null, "personal")); + }, + tileName: "Patient Profile", + tileIcon: Center( + child: FaIcon( + FontAwesomeIcons.bookMedical, + color: getSec(), + size: 200, + ), ), - ), - // Icon( - // Icons.medication, - // color: getSec(), - // size: 200, - // ), - p: getPrim(), - s: getSec(), - )); + // Icon( + // Icons.medication, + // color: getSec(), + // size: 200, + // ), + p: getPrim(), + s: getSec(), + )); + } else { + tileList.add(MIHTile( + videoID: "NUDdoWrbXNc", + onTap: () { + Navigator.of(context).pushNamed('/patient-profile/set-up', + arguments: widget.signedInUser); + }, + tileName: "Set Up Patient", + tileIcon: Center( + child: FaIcon( + FontAwesomeIcons.bookMedical, + color: getSec(), + size: 200, + ), + ), + // Icon( + // Icons.medication, + // color: getSec(), + // size: 200, + // ), + p: getPrim(), + s: getSec(), + )); + } + // tileList.add(MIHTile( + // videoID: "NUDdoWrbXNc", + // onTap: () { + // Navigator.of(context).pushNamed('/patient-profile', + // arguments: PatientViewArguments( + // widget.signedInUser, null, null, null, "personal")); + // }, + // tileName: "Patient Profile", + // tileIcon: Center( + // child: FaIcon( + // FontAwesomeIcons.bookMedical, + // color: getSec(), + // size: 200, + // ), + // ), + // // Icon( + // // Icons.medication, + // // color: getSec(), + // // size: 200, + // // ), + // p: getPrim(), + // s: getSec(), + // )); tileList.add(MIHTile( onTap: () { Navigator.of(context).pushNamed( diff --git a/Frontend/lib/mih_packages/mih_home/mih_profile_getter.dart b/Frontend/lib/mih_packages/mih_home/mih_profile_getter.dart index fe43eebd..c0d71eb0 100644 --- a/Frontend/lib/mih_packages/mih_home/mih_profile_getter.dart +++ b/Frontend/lib/mih_packages/mih_home/mih_profile_getter.dart @@ -99,6 +99,7 @@ class _MIHProfileGetterState extends State { signedInUser: snapshot.requireData.signedInUser, businessUser: snapshot.data!.businessUser, business: snapshot.data!.business, + patient: snapshot.data!.patient, notifications: snapshot.data!.notifi, propicFile: isPictureAvailable(snapshot.data!.profilePicUrl), isUserNew: isUserNew(snapshot.requireData.signedInUser), diff --git a/Frontend/pubspec.yaml b/Frontend/pubspec.yaml index 50909c4f..b41e468e 100644 --- a/Frontend/pubspec.yaml +++ b/Frontend/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.0.0+9 +version: 1.0.1+1 environment: sdk: '>=3.2.4 <4.0.0'