NEW: MIH Access Controlls Provider Setup
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/about_mih_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_access_controlls_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_authentication_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_banner_ad_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_calculator_provider.dart';
|
||||
@@ -96,6 +97,9 @@ class _MzansiInnovationHubState extends State<MzansiInnovationHub> {
|
||||
ChangeNotifierProvider(
|
||||
create: (context) => MihCalculatorProvider(),
|
||||
),
|
||||
ChangeNotifierProvider(
|
||||
create: (context) => MihAccessControllsProvider(),
|
||||
),
|
||||
ChangeNotifierProvider(
|
||||
create: (context) => MihCalendarProvider(),
|
||||
),
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/patient_access.dart';
|
||||
|
||||
class MihAccessControllsProvider extends ChangeNotifier {
|
||||
int toolIndex;
|
||||
List<PatientAccess>? accessList;
|
||||
|
||||
MihAccessControllsProvider({
|
||||
this.toolIndex = 0,
|
||||
});
|
||||
|
||||
void setToolIndex(int index) {
|
||||
toolIndex = index;
|
||||
}
|
||||
|
||||
void setAccessList(List<PatientAccess> accesses) {
|
||||
accessList = accesses;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void editAccessItem(PatientAccess updatedAccess) {
|
||||
if (accessList == null) return;
|
||||
int index = accessList!.indexWhere((access) =>
|
||||
access.app_id == updatedAccess.app_id &&
|
||||
access.business_id == updatedAccess.business_id);
|
||||
if (index != -1) {
|
||||
accessList![index] = updatedAccess;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -321,8 +321,7 @@ class MihGoRouter {
|
||||
name: "mihAccess",
|
||||
path: MihGoRouterPaths.mihAccess,
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
final AppUser? signedInUser = state.extra as AppUser?;
|
||||
if (signedInUser == null) {
|
||||
if (context.watch<MzansiProfileProvider>().business == null) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
context.go(MihGoRouterPaths.mihHome);
|
||||
});
|
||||
@@ -330,7 +329,6 @@ class MihGoRouter {
|
||||
}
|
||||
return MihAccess(
|
||||
key: UniqueKey(),
|
||||
signedInUser: signedInUser,
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -2,15 +2,14 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_action.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_access_controlls_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/access_review/package_tools/mih_access_requests.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MihAccess extends StatefulWidget {
|
||||
final AppUser signedInUser;
|
||||
const MihAccess({
|
||||
super.key,
|
||||
required this.signedInUser,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -18,7 +17,6 @@ class MihAccess extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MihAccessState extends State<MihAccess> {
|
||||
int _selcetedIndex = 0;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackage(
|
||||
@@ -26,12 +24,9 @@ class _MihAccessState extends State<MihAccess> {
|
||||
appTools: getTools(),
|
||||
appBody: getToolBody(),
|
||||
appToolTitles: getToolTitle(),
|
||||
selectedbodyIndex: _selcetedIndex,
|
||||
selectedbodyIndex: context.watch<MihAccessControllsProvider>().toolIndex,
|
||||
onIndexChange: (newValue) {
|
||||
setState(() {
|
||||
_selcetedIndex = newValue;
|
||||
});
|
||||
print("Index: $_selcetedIndex");
|
||||
context.read<MihAccessControllsProvider>().setToolIndex(newValue);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -52,21 +47,17 @@ class _MihAccessState extends State<MihAccess> {
|
||||
MihPackageTools getTools() {
|
||||
Map<Widget, void Function()?> temp = {};
|
||||
temp[const Icon(Icons.people)] = () {
|
||||
setState(() {
|
||||
_selcetedIndex = 0;
|
||||
});
|
||||
context.read<MihAccessControllsProvider>().setToolIndex(0);
|
||||
};
|
||||
return MihPackageTools(
|
||||
tools: temp,
|
||||
selcetedIndex: _selcetedIndex,
|
||||
selcetedIndex: context.watch<MihAccessControllsProvider>().toolIndex,
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> getToolBody() {
|
||||
List<Widget> toolBodies = [
|
||||
MihAccessRequest(
|
||||
signedInUser: widget.signedInUser,
|
||||
),
|
||||
MihAccessRequest(),
|
||||
];
|
||||
return toolBodies;
|
||||
}
|
||||
|
||||
@@ -2,17 +2,14 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tile.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
|
||||
class MihAccessTile extends StatefulWidget {
|
||||
final AppUser signedInUser;
|
||||
final double packageSize;
|
||||
|
||||
const MihAccessTile({
|
||||
super.key,
|
||||
required this.signedInUser,
|
||||
required this.packageSize,
|
||||
});
|
||||
|
||||
@@ -28,7 +25,6 @@ class _MihAccessTileState extends State<MihAccessTile> {
|
||||
onTap: () {
|
||||
context.goNamed(
|
||||
"mihAccess",
|
||||
extra: widget.signedInUser,
|
||||
);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// '/mih-access',
|
||||
|
||||
@@ -1,28 +1,24 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:ken_logger/ken_logger.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_action.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_header.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/patient_access.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_access_controlls_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/access_review/builder/build_business_access_list.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_access_controls_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_single_child_scroll.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_dropdwn_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tool_body.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../mih_services/mih_service_calls.dart';
|
||||
import '../../../mih_components/mih_layout/mih_action.dart';
|
||||
import '../../../mih_components/mih_layout/mih_header.dart';
|
||||
import '../../../mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import '../../../mih_config/mih_env.dart';
|
||||
import '../../../mih_components/mih_objects/app_user.dart';
|
||||
import '../../../mih_components/mih_objects/patient_access.dart';
|
||||
import '../builder/build_business_access_list.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MihAccessRequest extends StatefulWidget {
|
||||
final AppUser signedInUser;
|
||||
|
||||
const MihAccessRequest({
|
||||
super.key,
|
||||
required this.signedInUser,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -31,7 +27,7 @@ class MihAccessRequest extends StatefulWidget {
|
||||
|
||||
class _MihAccessRequestState extends State<MihAccessRequest> {
|
||||
TextEditingController filterController = TextEditingController();
|
||||
|
||||
bool isLoading = true;
|
||||
String baseUrl = AppEnviroment.baseApiUrl;
|
||||
|
||||
String errorCode = "";
|
||||
@@ -41,35 +37,8 @@ class _MihAccessRequestState extends State<MihAccessRequest> {
|
||||
bool forceRefresh = false;
|
||||
late String selectedDropdown;
|
||||
|
||||
late Future<List<PatientAccess>> accessList;
|
||||
|
||||
// Future<List<AccessRequest>> fetchAccessRequests() async {
|
||||
// //print("Patien manager page: $endpoint");
|
||||
// final response = await http.get(
|
||||
// Uri.parse("$baseUrl/access-requests/${widget.signedInUser.app_id}"));
|
||||
// // print("Here");
|
||||
// // print("Body: ${response.body}");
|
||||
// // print("Code: ${response.statusCode}");
|
||||
// errorCode = response.statusCode.toString();
|
||||
// errorBody = response.body;
|
||||
|
||||
// if (response.statusCode == 200) {
|
||||
// //print("Here1");
|
||||
// Iterable l = jsonDecode(response.body);
|
||||
// //print("Here2");
|
||||
// List<AccessRequest> patientQueue = List<AccessRequest>.from(
|
||||
// l.map((model) => AccessRequest.fromJson(model)));
|
||||
// //print("Here3");
|
||||
// //print(patientQueue);
|
||||
// return patientQueue;
|
||||
// } else {
|
||||
// throw Exception('failed to load patients');
|
||||
// }
|
||||
// }
|
||||
|
||||
List<PatientAccess> filterSearchResults(List<PatientAccess> accessList) {
|
||||
List<PatientAccess> templist = [];
|
||||
|
||||
for (var item in accessList) {
|
||||
if (filterController.text == "All") {
|
||||
templist.add(item);
|
||||
@@ -83,16 +52,24 @@ class _MihAccessRequestState extends State<MihAccessRequest> {
|
||||
}
|
||||
|
||||
void refreshList() {
|
||||
MzansiProfileProvider mzansiProfileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
MihAccessControllsProvider accessProvider =
|
||||
context.read<MihAccessControllsProvider>();
|
||||
if (forceRefresh == true) {
|
||||
MihAccessControlsServices().getBusinessAccessListOfPatient(
|
||||
mzansiProfileProvider.user!.app_id,
|
||||
accessProvider,
|
||||
);
|
||||
setState(() {
|
||||
accessList = MIHApiCalls.getBusinessAccessListOfPatient(
|
||||
widget.signedInUser.app_id);
|
||||
forceRefresh = false;
|
||||
});
|
||||
} else if (selectedDropdown != filterController.text) {
|
||||
MihAccessControlsServices().getBusinessAccessListOfPatient(
|
||||
mzansiProfileProvider.user!.app_id,
|
||||
accessProvider,
|
||||
);
|
||||
setState(() {
|
||||
accessList = MIHApiCalls.getBusinessAccessListOfPatient(
|
||||
widget.signedInUser.app_id);
|
||||
selectedDropdown = filterController.text;
|
||||
});
|
||||
}
|
||||
@@ -131,166 +108,92 @@ class _MihAccessRequestState extends State<MihAccessRequest> {
|
||||
}
|
||||
|
||||
Widget getBody() {
|
||||
return MihSingleChildScroll(
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
return Consumer2<MzansiProfileProvider, MihAccessControllsProvider>(
|
||||
builder: (BuildContext context,
|
||||
MzansiProfileProvider mzansiProfileProvider,
|
||||
MihAccessControllsProvider accessProvider,
|
||||
Widget? child) {
|
||||
if (isLoading) {
|
||||
return const Center(
|
||||
child: Mihloadingcircle(),
|
||||
);
|
||||
}
|
||||
return MihSingleChildScroll(
|
||||
child: Column(
|
||||
children: [
|
||||
Flexible(
|
||||
child: MihDropdownField(
|
||||
controller: filterController,
|
||||
hintText: "Access Type",
|
||||
dropdownOptions: const [
|
||||
"All",
|
||||
"Approved",
|
||||
"Pending",
|
||||
"Declined",
|
||||
"Cancelled",
|
||||
],
|
||||
requiredText: true,
|
||||
editable: true,
|
||||
enableSearch: true,
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
iconSize: 35,
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
forceRefresh = true;
|
||||
});
|
||||
KenLogger.warning("Refreshing Access List");
|
||||
refreshList();
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.refresh,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
FutureBuilder(
|
||||
future: accessList,
|
||||
builder: (context, snapshot) {
|
||||
//print("patient Queue List ${snapshot.hasData}");
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Mihloadingcircle();
|
||||
} else if (snapshot.connectionState == ConnectionState.done) {
|
||||
List<PatientAccess> accessRequestList;
|
||||
accessRequestList = filterSearchResults(snapshot.requireData);
|
||||
if (accessRequestList.isNotEmpty) {
|
||||
return BuildBusinessAccessList(
|
||||
signedInUser: widget.signedInUser,
|
||||
patientAccessList: accessRequestList,
|
||||
onSuccessUpate: () {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Flexible(
|
||||
child: MihDropdownField(
|
||||
controller: filterController,
|
||||
hintText: "Access Type",
|
||||
dropdownOptions: const [
|
||||
"All",
|
||||
"Approved",
|
||||
"Pending",
|
||||
"Declined",
|
||||
"Cancelled",
|
||||
],
|
||||
requiredText: true,
|
||||
editable: true,
|
||||
enableSearch: true,
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
iconSize: 35,
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
forceRefresh = true;
|
||||
});
|
||||
KenLogger.warning("Refreshing Access List");
|
||||
refreshList();
|
||||
},
|
||||
);
|
||||
} else {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(height: 50),
|
||||
Icon(
|
||||
MihIcons.accessControl,
|
||||
size: 165,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"No access has been granted to your MIH Profile",
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.visible,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
// const SizedBox(height: 10),
|
||||
// Center(
|
||||
// child: RichText(
|
||||
// textAlign: TextAlign.center,
|
||||
// text: TextSpan(
|
||||
// style: TextStyle(
|
||||
// fontSize: 20,
|
||||
// fontWeight: FontWeight.normal,
|
||||
// color: MzansiInnovationHub.of(context)!
|
||||
// .theme
|
||||
// .secondaryColor(),
|
||||
// ),
|
||||
// children: [
|
||||
// TextSpan(text: "Press "),
|
||||
// WidgetSpan(
|
||||
// alignment: PlaceholderAlignment.middle,
|
||||
// child: Icon(
|
||||
// Icons.menu,
|
||||
// size: 20,
|
||||
// color: MzansiInnovationHub.of(context)!
|
||||
// .theme
|
||||
// .secondaryColor(),
|
||||
// ),
|
||||
// ),
|
||||
// TextSpan(
|
||||
// text: " to add your first loyalty card."),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
icon: const Icon(
|
||||
Icons.refresh,
|
||||
),
|
||||
);
|
||||
// return Center(
|
||||
// child: Text(
|
||||
// "No Request have been made.",
|
||||
// style: TextStyle(
|
||||
// fontSize: 25,
|
||||
// color: MzansiInnovationHub.of(context)!
|
||||
// .theme
|
||||
// .messageTextColor()),
|
||||
// textAlign: TextAlign.center,
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
|
||||
// return Expanded(
|
||||
// child: displayAccessRequestList(accessRequestList),
|
||||
// );
|
||||
} else {
|
||||
return Center(
|
||||
child: Text(
|
||||
"$errorCode: Error pulling Patients Data\n$baseUrl/queue/patients/\n$errorBody",
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
color: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark")),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
BuildBusinessAccessList(
|
||||
filterText: filterController.text,
|
||||
onSuccessUpate: () {
|
||||
setState(() {
|
||||
forceRefresh = true;
|
||||
});
|
||||
refreshList();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> initiasizeAccessList() async {
|
||||
MzansiProfileProvider mzansiProfileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
MihAccessControllsProvider accessProvider =
|
||||
context.read<MihAccessControllsProvider>();
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
});
|
||||
await MihAccessControlsServices().getBusinessAccessListOfPatient(
|
||||
mzansiProfileProvider.user!.app_id,
|
||||
accessProvider,
|
||||
);
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
filterController.dispose();
|
||||
@@ -302,9 +205,8 @@ class _MihAccessRequestState extends State<MihAccessRequest> {
|
||||
selectedDropdown = "All";
|
||||
filterController.text = "All";
|
||||
filterController.addListener(refreshList);
|
||||
setState(() {
|
||||
accessList = MIHApiCalls.getBusinessAccessListOfPatient(
|
||||
widget.signedInUser.app_id);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
await initiasizeAccessList();
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ class _MzansiCalendarState extends State<MzansiCalendar> {
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
// Navigator.of(context).pop();
|
||||
context.read<MihCalendarProvider>().resetSelectedDay();
|
||||
context.goNamed(
|
||||
'mihHome',
|
||||
|
||||
@@ -98,7 +98,6 @@ class _MihPersonalHomeState extends State<MihPersonalHome>
|
||||
//=============== Mzansi Wallet ===============
|
||||
temp.add({
|
||||
"Mzansi Wallet": MihWalletTile(
|
||||
signedInUser: widget.signedInUser,
|
||||
packageSize: packageSize,
|
||||
)
|
||||
});
|
||||
@@ -150,7 +149,6 @@ class _MihPersonalHomeState extends State<MihPersonalHome>
|
||||
//=============== MIH Access ===============
|
||||
temp.add({
|
||||
"MIH Access": MihAccessTile(
|
||||
signedInUser: widget.signedInUser,
|
||||
packageSize: packageSize,
|
||||
)
|
||||
});
|
||||
|
||||
@@ -2,18 +2,14 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tile.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
|
||||
class MihWalletTile extends StatefulWidget {
|
||||
final AppUser signedInUser;
|
||||
final double packageSize;
|
||||
|
||||
const MihWalletTile({
|
||||
super.key,
|
||||
required this.signedInUser,
|
||||
required this.packageSize,
|
||||
});
|
||||
|
||||
@@ -29,7 +25,6 @@ class _MihWalletTileState extends State<MihWalletTile> {
|
||||
onTap: () {
|
||||
context.goNamed(
|
||||
'mzansiWallet',
|
||||
extra: WalletArguments(widget.signedInUser, 0),
|
||||
);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// '/mzansi-wallet',
|
||||
|
||||
@@ -2,11 +2,36 @@ import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/patient_access.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_access_controlls_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
import 'package:supertokens_flutter/http.dart' as http;
|
||||
|
||||
class MihAccessControlsServices {
|
||||
Future<int> getBusinessAccessListOfPatient(
|
||||
String app_id,
|
||||
MihAccessControllsProvider mihAccessColtrollsProvider,
|
||||
) async {
|
||||
final response = await http.get(Uri.parse(
|
||||
"${AppEnviroment.baseApiUrl}/access-requests/personal/patient/$app_id"));
|
||||
// var errorCode = response.statusCode.toString();
|
||||
// print(response.statusCode);
|
||||
// print(response.body);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
Iterable l = jsonDecode(response.body);
|
||||
List<PatientAccess> patientAccesses = List<PatientAccess>.from(
|
||||
l.map((model) => PatientAccess.fromJson(model)));
|
||||
if (response.statusCode == 200) {
|
||||
mihAccessColtrollsProvider.setAccessList(patientAccesses);
|
||||
}
|
||||
return response.statusCode;
|
||||
} else {
|
||||
throw Exception('failed to pull patient access List for business');
|
||||
}
|
||||
}
|
||||
|
||||
/// This function is used to UPDATE access the business has.
|
||||
///
|
||||
/// Patameters:-
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_business_details_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';
|
||||
@@ -7,20 +6,8 @@ import 'package:mzansi_innovation_hub/mih_services/mih_notification_services.dar
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_patient_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_user_services.dart';
|
||||
// import '../mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||
// import '../mih_components/mih_pop_up_messages/mih_success_message.dart';
|
||||
// import '../mih_env/mih_env.dart';
|
||||
// import '../mih_objects/app_user.dart';
|
||||
// import '../mih_objects/arguments.dart';
|
||||
// import '../mih_objects/business.dart';
|
||||
// import '../mih_objects/business_user.dart';
|
||||
// import '../mih_objects/notification.dart';
|
||||
// import '../mih_objects/patient_access.dart';
|
||||
// import '../mih_objects/patient_queue.dart';
|
||||
// import '../mih_objects/patients.dart';
|
||||
import 'package:supertokens_flutter/supertokens.dart';
|
||||
import 'package:supertokens_flutter/http.dart' as http;
|
||||
|
||||
import '../mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||
import '../mih_components/mih_pop_up_messages/mih_success_message.dart';
|
||||
import '../mih_config/mih_env.dart';
|
||||
@@ -163,29 +150,6 @@ class MIHApiCalls {
|
||||
}
|
||||
}
|
||||
|
||||
/// This function is used to get list of access the business has.
|
||||
///
|
||||
/// Patameters: String business_id.
|
||||
///
|
||||
/// Returns List<PatientAccess> (List of access that match the above parameters).
|
||||
static Future<List<PatientAccess>> getBusinessAccessListOfPatient(
|
||||
String app_id) async {
|
||||
final response = await http.get(Uri.parse(
|
||||
"${AppEnviroment.baseApiUrl}/access-requests/personal/patient/$app_id"));
|
||||
// var errorCode = response.statusCode.toString();
|
||||
// print(response.statusCode);
|
||||
// print(response.body);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
Iterable l = jsonDecode(response.body);
|
||||
List<PatientAccess> patientAccesses = List<PatientAccess>.from(
|
||||
l.map((model) => PatientAccess.fromJson(model)));
|
||||
return patientAccesses;
|
||||
} else {
|
||||
throw Exception('failed to pull patient access List for business');
|
||||
}
|
||||
}
|
||||
|
||||
/// This function is used to UPDATE access the business has.
|
||||
///
|
||||
/// Patameters:-
|
||||
|
||||
Reference in New Issue
Block a user