forked from yaso_meth/mih-project
change profile getter to check for patient profile
This commit is contained in:
@@ -46,6 +46,7 @@ class MIHApiCalls {
|
||||
AppUser userData;
|
||||
Business? busData;
|
||||
BusinessUser? bUserData;
|
||||
Patient? patientData;
|
||||
List<MIHNotification> 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<String, dynamic>);
|
||||
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.
|
||||
|
||||
@@ -35,6 +35,7 @@ class HomeArguments {
|
||||
final AppUser signedInUser;
|
||||
final BusinessUser? businessUser;
|
||||
final Business? business;
|
||||
final Patient? patient;
|
||||
final List<MIHNotification> notifi;
|
||||
final String profilePicUrl;
|
||||
|
||||
@@ -42,6 +43,7 @@ class HomeArguments {
|
||||
this.signedInUser,
|
||||
this.businessUser,
|
||||
this.business,
|
||||
this.patient,
|
||||
this.notifi,
|
||||
this.profilePicUrl,
|
||||
);
|
||||
|
||||
@@ -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<MIHNotification> notifications;
|
||||
final ImageProvider<Object>? 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<MIHHome> {
|
||||
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(
|
||||
|
||||
@@ -99,6 +99,7 @@ class _MIHProfileGetterState extends State<MIHProfileGetter> {
|
||||
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),
|
||||
|
||||
Reference in New Issue
Block a user