NEW: MIH Home & Mzansi Profile Provider Setup pt 1

This commit is contained in:
2025-10-16 10:16:18 +02:00
parent 553d22dd6b
commit d51603ff5d
28 changed files with 2687 additions and 2515 deletions

View File

@@ -5,6 +5,7 @@ import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_authentic
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_banner_ad_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'; import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_calculator_provider.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_mine_sweeper_provider.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_mine_sweeper_provider.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_wallet_provider.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_wallet_provider.dart';
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@@ -78,6 +79,9 @@ class _MzansiInnovationHubState extends State<MzansiInnovationHub> {
ChangeNotifierProvider( ChangeNotifierProvider(
create: (context) => MihAuthenticationProvider(), create: (context) => MihAuthenticationProvider(),
), ),
ChangeNotifierProvider(
create: (context) => MzansiProfileProvider(),
),
ChangeNotifierProvider( ChangeNotifierProvider(
create: (context) => MzansiWalletProvider(), create: (context) => MzansiWalletProvider(),
), ),

View File

@@ -32,19 +32,8 @@ class _MihImageDisplayState extends State<MihImageDisplay> {
late ImageProvider<Object>? imagePreview; late ImageProvider<Object>? imagePreview;
ImageProvider<Object>? getImage() { ImageProvider<Object>? getImage() {
Color dark = const Color(0XFF3A4454);
if (widget.imageFile == null) { if (widget.imageFile == null) {
if (MihColors.getSecondaryColor( return null;
MzansiInnovationHub.of(context)!.theme.mode == "Dark") ==
dark) {
print("here in light icon");
return const AssetImage(
'lib/mih_components/mih_package_components/assets/images/i-dont-know-dark.png');
} else {
print("here in dark icon");
return const AssetImage(
'lib/mih_components/mih_package_components/assets/images/i-dont-know-light.png');
}
} else { } else {
return widget.imageFile; return widget.imageFile;
} }
@@ -69,9 +58,12 @@ class _MihImageDisplayState extends State<MihImageDisplay> {
child: Stack( child: Stack(
alignment: Alignment.center, alignment: Alignment.center,
children: [ children: [
ClipRRect( Visibility(
borderRadius: BorderRadius.circular(widget.width * 0.1), visible: imagePreview != null,
child: Image(image: imagePreview!), child: ClipRRect(
borderRadius: BorderRadius.circular(widget.width * 0.1),
child: Image(image: imagePreview!),
),
), ),
Visibility( Visibility(
visible: widget.editable, visible: widget.editable,

View File

@@ -0,0 +1,14 @@
import 'package:flutter/foundation.dart';
class MihCalendarProvider extends ChangeNotifier {
int toolIndex;
MihCalendarProvider({
this.toolIndex = 0,
});
void setToolIndex(int index) {
toolIndex = index;
notifyListeners();
}
}

View File

@@ -0,0 +1,35 @@
import 'package:flutter/widgets.dart';
class MihMineSweeperProvider extends ChangeNotifier {
int toolIndex;
int rowCount;
int columnCount;
int totalMines;
MihMineSweeperProvider({
this.toolIndex = 0,
this.rowCount = 10,
this.columnCount = 10,
this.totalMines = 15,
});
void setToolIndex(int index) {
toolIndex = index;
notifyListeners();
}
void setRowCount(int rowCount) {
this.rowCount = rowCount;
notifyListeners();
}
void setCoulmnCount(int columnCount) {
this.columnCount = columnCount;
notifyListeners();
}
void setTotalMines(int totalMines) {
this.totalMines = totalMines;
notifyListeners();
}
}

View File

@@ -0,0 +1,102 @@
import 'package:flutter/material.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_employee.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_user.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_objects/user_consent.dart';
class MzansiProfileProvider extends ChangeNotifier {
bool personalHome;
int personalIndex;
int businessIndex;
AppUser? user;
String? userProfilePicUrl;
ImageProvider<Object>? userProfilePicture;
Business? business;
String? businessProfilePicUrl;
ImageProvider<Object>? businessProfilePicture;
BusinessUser? businessUser;
String? businessUserSignatureUrl;
ImageProvider<Object>? businessUserSignature;
UserConsent? userConsent;
List<BusinessEmployee>? employeeList;
MzansiProfileProvider({
this.personalHome = true,
this.personalIndex = 0,
this.businessIndex = 0,
});
void reset() {
personalHome = true;
personalIndex = 0;
businessIndex = 0;
user = null;
userProfilePicUrl = null;
userProfilePicture = null;
business = null;
businessProfilePicUrl = null;
businessProfilePicture = null;
businessUser = null;
businessUserSignatureUrl = null;
businessUserSignature = null;
userConsent = null;
}
void setPersonalIndex(int index) {
personalIndex = index;
notifyListeners();
}
void setBusinessIndex(int index) {
businessIndex = index;
notifyListeners();
}
void setUser({
required AppUser newUser,
}) {
user = newUser;
notifyListeners();
}
void setUserProfilePicUrl(String url) {
userProfilePicUrl = url;
userProfilePicture = url.isNotEmpty ? NetworkImage(url) : null;
notifyListeners();
}
void setBusiness({
Business? newBusiness,
}) {
business = newBusiness;
notifyListeners();
}
void setBusinessProfilePicUrl(String url) {
businessProfilePicUrl = url;
businessProfilePicture = url.isNotEmpty ? NetworkImage(url) : null;
notifyListeners();
}
void setBusinessUser({required BusinessUser newBusinessUser}) {
businessUser = newBusinessUser;
notifyListeners();
}
void setBusinessUserSignatureUrl(String url) {
businessUserSignatureUrl = url;
businessUserSignature = url.isNotEmpty ? NetworkImage(url) : null;
notifyListeners();
}
void setUserConsent(UserConsent? newUserConsent) {
userConsent = newUserConsent;
notifyListeners();
}
void setEmployeeList({required List<BusinessEmployee> employeeList}) {
this.employeeList = employeeList;
notifyListeners();
}
}

View File

@@ -37,7 +37,7 @@ class MihColors {
if (darkMode == true) { if (darkMode == true) {
return const Color(0xff8ae290); return const Color(0xff8ae290);
} else { } else {
return const Color(0xffB0F2B4); return const Color(0xFF41B349);
} }
} }
@@ -63,7 +63,7 @@ class MihColors {
return const Color(0xffd69d7d); return const Color(0xffd69d7d);
} else { } else {
// Add a different shade of pink for light mode // Add a different shade of pink for light mode
return const Color(0xffd69d7d); return const Color(0xFFBD7145);
} }
} }
@@ -81,7 +81,7 @@ class MihColors {
return const Color(0xff6e7dcc); return const Color(0xff6e7dcc);
} else { } else {
// Add a different shade of pink for light mode // Add a different shade of pink for light mode
return const Color(0xff6e7dcc); return const Color(0xFF5567C0);
} }
} }
@@ -90,7 +90,7 @@ class MihColors {
return const Color(0xffb682e7); return const Color(0xffb682e7);
} else { } else {
// Add a different shade of pink for light mode // Add a different shade of pink for light mode
return const Color(0xffb682e7); return const Color(0xFF9857D4);
} }
} }
} }

View File

@@ -4,6 +4,7 @@ import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_print_prevew
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/Example/package_test.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_package_components/Example/package_test.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
import 'package:mzansi_innovation_hub/mih_packages/about_mih/about_mih.dart'; import 'package:mzansi_innovation_hub/mih_packages/about_mih/about_mih.dart';
import 'package:mzansi_innovation_hub/mih_packages/access_review/mih_access.dart'; import 'package:mzansi_innovation_hub/mih_packages/access_review/mih_access.dart';
import 'package:mzansi_innovation_hub/mih_packages/calculator/mih_calculator.dart'; import 'package:mzansi_innovation_hub/mih_packages/calculator/mih_calculator.dart';
@@ -29,6 +30,7 @@ import 'package:mzansi_innovation_hub/mih_packages/patient_profile/pat_profile/a
import 'package:mzansi_innovation_hub/mih_packages/patient_profile/pat_profile/components/full_screen_file.dart'; import 'package:mzansi_innovation_hub/mih_packages/patient_profile/pat_profile/components/full_screen_file.dart';
import 'package:mzansi_innovation_hub/mih_packages/patient_profile/pat_profile/patient_edit.dart'; import 'package:mzansi_innovation_hub/mih_packages/patient_profile/pat_profile/patient_edit.dart';
import 'package:mzansi_innovation_hub/mih_packages/patient_profile/pat_profile/patient_profile.dart'; import 'package:mzansi_innovation_hub/mih_packages/patient_profile/pat_profile/patient_profile.dart';
import 'package:provider/provider.dart';
import 'package:supertokens_flutter/supertokens.dart'; import 'package:supertokens_flutter/supertokens.dart';
class MihGoRouterPaths { class MihGoRouterPaths {
@@ -133,16 +135,8 @@ 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");
if (state.extra != null) {
final bool personalSelected = state.extra as bool;
return MihHome(
key: UniqueKey(),
personalSelected: personalSelected,
);
}
return MihHome( return MihHome(
key: UniqueKey(), key: UniqueKey(),
personalSelected: true,
); );
}, },
), ),
@@ -166,15 +160,13 @@ class MihGoRouter {
path: MihGoRouterPaths.mzansiProfileManage, path: MihGoRouterPaths.mzansiProfileManage,
builder: (BuildContext context, GoRouterState state) { builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: mzansiProfileManage"); KenLogger.success("MihGoRouter: mzansiProfileManage");
final AppProfileUpdateArguments? args = if (context.watch<MzansiProfileProvider>().user == null) {
state.extra as AppProfileUpdateArguments?;
if (args == null) {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
context.go(MihGoRouterPaths.mihHome); context.go(MihGoRouterPaths.mihHome);
}); });
return const SizedBox.shrink(); return const SizedBox.shrink();
} }
return MzansiProfile(arguments: args); return MzansiProfile();
}, },
), ),
GoRoute( GoRoute(
@@ -198,8 +190,7 @@ class MihGoRouter {
path: MihGoRouterPaths.businessProfileManage, path: MihGoRouterPaths.businessProfileManage,
builder: (BuildContext context, GoRouterState state) { builder: (BuildContext context, GoRouterState state) {
KenLogger.success("MihGoRouter: businessProfileManage"); KenLogger.success("MihGoRouter: businessProfileManage");
final BusinessArguments? args = state.extra as BusinessArguments?; if (context.watch<MzansiProfileProvider>().business == null) {
if (args == null) {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
context.go(MihGoRouterPaths.mihHome); context.go(MihGoRouterPaths.mihHome);
}); });
@@ -207,7 +198,6 @@ class MihGoRouter {
} }
return MzansiBusinessProfile( return MzansiBusinessProfile(
key: UniqueKey(), key: UniqueKey(),
arguments: args,
); );
}, },
), ),

View File

@@ -28,10 +28,6 @@ class _MihCalculatorTileState extends State<MihCalculatorTile> {
"mihCalculator", "mihCalculator",
extra: widget.personalSelected, extra: widget.personalSelected,
); );
// Navigator.of(context).pushNamed(
// '/calculator',
// arguments: widget.personalSelected,
// );
}, },
appName: "Calculator", appName: "Calculator",
appIcon: Icon( appIcon: Icon(

View File

@@ -3,8 +3,10 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
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_action.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_calendar_provider.dart';
import 'package:mzansi_innovation_hub/mih_packages/calendar/package_tools/appointments.dart'; import 'package:mzansi_innovation_hub/mih_packages/calendar/package_tools/appointments.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class MzansiCalendar extends StatefulWidget { class MzansiCalendar extends StatefulWidget {
final CalendarArguments arguments; final CalendarArguments arguments;
@@ -18,8 +20,6 @@ class MzansiCalendar extends StatefulWidget {
} }
class _MzansiCalendarState extends State<MzansiCalendar> { class _MzansiCalendarState extends State<MzansiCalendar> {
int _selcetedIndex = 0;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MihPackage( return MihPackage(
@@ -27,12 +27,9 @@ class _MzansiCalendarState extends State<MzansiCalendar> {
appTools: getTools(), appTools: getTools(),
appBody: getToolBody(), appBody: getToolBody(),
appToolTitles: getToolTitle(), appToolTitles: getToolTitle(),
selectedbodyIndex: _selcetedIndex, selectedbodyIndex: context.watch<MihCalendarProvider>().toolIndex,
onIndexChange: (newValue) { onIndexChange: (newIndex) {
setState(() { context.read<MihCalendarProvider>().setToolIndex(newIndex);
_selcetedIndex = newValue;
});
print("Index: $_selcetedIndex");
}, },
); );
} }
@@ -55,14 +52,12 @@ class _MzansiCalendarState extends State<MzansiCalendar> {
MihPackageTools getTools() { MihPackageTools getTools() {
Map<Widget, void Function()?> temp = {}; Map<Widget, void Function()?> temp = {};
temp[const Icon(Icons.calendar_month)] = () { temp[const Icon(Icons.calendar_month)] = () {
setState(() { context.read<MihCalendarProvider>().setToolIndex(0);
_selcetedIndex = 0;
});
}; };
return MihPackageTools( return MihPackageTools(
tools: temp, tools: temp,
selcetedIndex: _selcetedIndex, selcetedIndex: context.watch<MihCalendarProvider>().toolIndex,
); );
} }

View File

@@ -5,6 +5,7 @@ import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart'
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_circle_avatar.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_circle_avatar.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_providers/about_mih_provider.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_providers/about_mih_provider.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../../../main.dart'; import '../../../main.dart';
@@ -78,293 +79,299 @@ class _MIHAppDrawerState extends State<MIHAppDrawer> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
// precacheImage( // precacheImage(
// MzansiInnovationHub.of(context)!.theme.logoImage().image, context); // MzansiInnovationHub.of(context)!.theme.logoImage().image, context);
return SafeArea( return Consumer<MzansiProfileProvider>(
child: Drawer( builder: (BuildContext context,
//backgroundColor: MihColors.getPrimaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"), MzansiProfileProvider mzansiProfileProvider, Widget? child) {
child: LayoutBuilder( return SafeArea(
builder: (BuildContext context, BoxConstraints constraints) { child: Drawer(
return Stack( //backgroundColor: MihColors.getPrimaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
//fit: StackFit.passthrough, child: LayoutBuilder(
children: [ builder: (BuildContext context, BoxConstraints constraints) {
Column( return Stack(
// reverse: false, //fit: StackFit.passthrough,
// padding: EdgeInsets.zero,
mainAxisSize: MainAxisSize.max,
children: [ children: [
DrawerHeader( Column(
decoration: BoxDecoration( // reverse: false,
color: MihColors.getSecondaryColor( // padding: EdgeInsets.zero,
MzansiInnovationHub.of(context)!.theme.mode == mainAxisSize: MainAxisSize.max,
"Dark"), children: [
), DrawerHeader(
child: SizedBox( decoration: BoxDecoration(
height: 400, color: MihColors.getSecondaryColor(
width: constraints.maxWidth, MzansiInnovationHub.of(context)!.theme.mode ==
child: Column( "Dark"),
crossAxisAlignment: CrossAxisAlignment.start, ),
mainAxisSize: MainAxisSize.max, child: SizedBox(
children: [ height: 400,
profilePictureLoaded, width: constraints.maxWidth,
Text( child: Column(
"${widget.signedInUser.fname} ${widget.signedInUser.lname}", crossAxisAlignment: CrossAxisAlignment.start,
style: TextStyle( mainAxisSize: MainAxisSize.max,
fontWeight: FontWeight.bold, children: [
color: MihColors.getPrimaryColor( profilePictureLoaded,
MzansiInnovationHub.of(context)! Text(
.theme "${widget.signedInUser.fname} ${widget.signedInUser.lname}",
.mode == style: TextStyle(
"Dark"), fontWeight: FontWeight.bold,
), color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
),
),
Text(
"@${widget.signedInUser.username}",
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
),
),
Text(
widget.signedInUser.type.toUpperCase(),
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.bold,
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
),
),
],
), ),
Text( ),
"@${widget.signedInUser.username}", ),
style: TextStyle( // ListTile(
fontSize: 12, // title: Row(
fontWeight: FontWeight.bold, // mainAxisSize: MainAxisSize.max,
color: MihColors.getPrimaryColor( // children: [
MzansiInnovationHub.of(context)! // Icon(
.theme // Icons.home_outlined,
.mode == // color:
"Dark"), // MihColors.getSecondaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
// ),
// const SizedBox(width: 25.0),
// Text(
// "Home",
// style: TextStyle(
// //fontWeight: FontWeight.bold,
// color: MzansiInnovationHub.of(context)!
// .theme
// .secondaryColor(),
// ),
// ),
// ],
// ),
// onTap: () {
// Navigator.of(context)
// .pushNamedAndRemoveUntil('/', (route) => false);
// },
// ),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
mainAxisSize: MainAxisSize.max,
children: [
ListTile(
title: Row(
mainAxisSize: MainAxisSize.max,
children: [
Icon(
Icons.policy,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
),
const SizedBox(width: 25.0),
Text(
"Privacy Policy",
style: TextStyle(
//fontWeight: FontWeight.bold,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
),
),
],
),
onTap: () {
WidgetsBinding.instance
.addPostFrameCallback((_) async {
context
.read<AboutMihProvider>()
.setToolIndex(1);
});
context.goNamed(
"aboutMih",
extra: true,
);
},
), ),
), ListTile(
Text( title: Row(
widget.signedInUser.type.toUpperCase(), mainAxisSize: MainAxisSize.max,
style: TextStyle( children: [
fontSize: 10, Icon(
fontWeight: FontWeight.bold, Icons.design_services_rounded,
color: MihColors.getPrimaryColor( color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)! MzansiInnovationHub.of(context)!
.theme .theme
.mode == .mode ==
"Dark"), "Dark"),
),
const SizedBox(width: 25.0),
Text(
"Terms of Service",
style: TextStyle(
//fontWeight: FontWeight.bold,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
),
),
],
),
onTap: () {
WidgetsBinding.instance
.addPostFrameCallback((_) async {
context
.read<AboutMihProvider>()
.setToolIndex(2);
});
context.goNamed(
"aboutMih",
extra: true,
);
},
), ),
), ListTile(
], title: Row(
mainAxisSize: MainAxisSize.max,
children: [
Icon(
Icons.logout,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
),
const SizedBox(width: 25.0),
Text(
"Sign Out",
style: TextStyle(
//fontWeight: FontWeight.bold,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
),
),
],
),
onTap: () async {
await SuperTokens.signOut(
completionHandler: (error) {
print(error);
});
if (await SuperTokens.doesSessionExist() ==
false) {
mzansiProfileProvider.reset();
context.goNamed(
'mihHome',
extra: true,
);
// Navigator.of(context).pop();
// Navigator.of(context).popAndPushNamed(
// '/',
// arguments: AuthArguments(true, false),
// );
}
},
),
],
),
),
],
),
Positioned(
top: 5,
right: 5,
width: 30,
height: 30,
child: InkWell(
onTap: () {
setState(() {
if (MzansiInnovationHub.of(context)?.theme.mode ==
"Dark") {
//darkm = !darkm;
MzansiInnovationHub.of(context)!
.changeTheme(ThemeMode.light);
//print("Dark Mode: $darkm");
} else {
//darkm = !darkm;
MzansiInnovationHub.of(context)!
.changeTheme(ThemeMode.dark);
//print("Dark Mode: $darkm");
}
Navigator.of(context).pop();
Navigator.of(context).popAndPushNamed(
'/',
arguments: AuthArguments(true, false),
);
// Navigator.of(context).popAndPushNamed('/',);
});
},
child: Icon(
MihIcons.mihLogo,
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
), ),
), ),
), // IconButton(
// ListTile( // onPressed: () {
// title: Row( // setState(() {
// mainAxisSize: MainAxisSize.max, // if (MzansiInnovationHub.of(context)?.theme.mode == "Dark") {
// children: [ // //darkm = !darkm;
// Icon( // MzansiInnovationHub.of(context)!.changeTheme(ThemeMode.light);
// Icons.home_outlined, // //print("Dark Mode: $darkm");
// color: // } else {
// MihColors.getSecondaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"), // //darkm = !darkm;
// ), // MzansiInnovationHub.of(context)!.changeTheme(ThemeMode.dark);
// const SizedBox(width: 25.0), // //print("Dark Mode: $darkm");
// Text( // }
// "Home", // Navigator.of(context).popAndPushNamed('/');
// style: TextStyle( // });
// //fontWeight: FontWeight.bold, // },
// color: MzansiInnovationHub.of(context)! // icon: Icon(
// .theme // Icons.light_mode,
// .secondaryColor(), // color: MihColors.getPrimaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
// ), // size: 35,
// ), // ),
// ], // ),
// ),
// onTap: () {
// Navigator.of(context)
// .pushNamedAndRemoveUntil('/', (route) => false);
// },
// ),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
mainAxisSize: MainAxisSize.max,
children: [
ListTile(
title: Row(
mainAxisSize: MainAxisSize.max,
children: [
Icon(
Icons.policy,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
),
const SizedBox(width: 25.0),
Text(
"Privacy Policy",
style: TextStyle(
//fontWeight: FontWeight.bold,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
),
),
],
),
onTap: () {
WidgetsBinding.instance
.addPostFrameCallback((_) async {
context
.read<AboutMihProvider>()
.setToolIndex(1);
});
context.goNamed(
"aboutMih",
extra: true,
);
},
),
ListTile(
title: Row(
mainAxisSize: MainAxisSize.max,
children: [
Icon(
Icons.design_services_rounded,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
),
const SizedBox(width: 25.0),
Text(
"Terms of Service",
style: TextStyle(
//fontWeight: FontWeight.bold,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
),
),
],
),
onTap: () {
WidgetsBinding.instance
.addPostFrameCallback((_) async {
context
.read<AboutMihProvider>()
.setToolIndex(2);
});
context.goNamed(
"aboutMih",
extra: true,
);
},
),
ListTile(
title: Row(
mainAxisSize: MainAxisSize.max,
children: [
Icon(
Icons.logout,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
),
const SizedBox(width: 25.0),
Text(
"Sign Out",
style: TextStyle(
//fontWeight: FontWeight.bold,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
),
),
],
),
onTap: () async {
await SuperTokens.signOut(
completionHandler: (error) {
print(error);
});
if (await SuperTokens.doesSessionExist() ==
false) {
context.goNamed(
'mihHome',
extra: true,
);
// Navigator.of(context).pop();
// Navigator.of(context).popAndPushNamed(
// '/',
// arguments: AuthArguments(true, false),
// );
}
},
),
],
),
), ),
], ],
), );
Positioned( },
top: 5, ),
right: 5, ),
width: 30, );
height: 30, },
child: InkWell(
onTap: () {
setState(() {
if (MzansiInnovationHub.of(context)?.theme.mode ==
"Dark") {
//darkm = !darkm;
MzansiInnovationHub.of(context)!
.changeTheme(ThemeMode.light);
//print("Dark Mode: $darkm");
} else {
//darkm = !darkm;
MzansiInnovationHub.of(context)!
.changeTheme(ThemeMode.dark);
//print("Dark Mode: $darkm");
}
Navigator.of(context).pop();
Navigator.of(context).popAndPushNamed(
'/',
arguments: AuthArguments(true, false),
);
// Navigator.of(context).popAndPushNamed('/',);
});
},
child: Icon(
MihIcons.mihLogo,
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
),
),
// IconButton(
// onPressed: () {
// setState(() {
// if (MzansiInnovationHub.of(context)?.theme.mode == "Dark") {
// //darkm = !darkm;
// MzansiInnovationHub.of(context)!.changeTheme(ThemeMode.light);
// //print("Dark Mode: $darkm");
// } else {
// //darkm = !darkm;
// MzansiInnovationHub.of(context)!.changeTheme(ThemeMode.dark);
// //print("Dark Mode: $darkm");
// }
// Navigator.of(context).popAndPushNamed('/');
// });
// },
// icon: Icon(
// Icons.light_mode,
// color: MihColors.getPrimaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
// size: 35,
// ),
// ),
),
],
);
},
),
),
); );
} }
} }

View File

@@ -1,7 +1,8 @@
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:ken_logger/ken_logger.dart'; import 'package:ken_logger/ken_logger.dart';
import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/main.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_user.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_objects/user_consent.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_objects/user_consent.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.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.dart';
@@ -13,22 +14,24 @@ import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_window.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_window.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_scack_bar.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_scack_bar.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.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/about_mih_provider.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_colors.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_packages/mih_home/components/mih_app_drawer.dart'; import 'package:mzansi_innovation_hub/mih_packages/mih_home/components/mih_app_drawer.dart';
import 'package:mzansi_innovation_hub/mih_packages/mih_home/mih_home_error.dart';
import 'package:mzansi_innovation_hub/mih_packages/mih_home/package_tools/mih_business_home.dart'; import 'package:mzansi_innovation_hub/mih_packages/mih_home/package_tools/mih_business_home.dart';
import 'package:mzansi_innovation_hub/mih_packages/mih_home/package_tools/mih_personal_home.dart'; import 'package:mzansi_innovation_hub/mih_packages/mih_home/package_tools/mih_personal_home.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_service_calls.dart'; 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';
import 'package:mzansi_innovation_hub/mih_services/mih_user_consent_services.dart'; import 'package:mzansi_innovation_hub/mih_services/mih_user_consent_services.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_user_services.dart';
import 'package:provider/provider.dart';
// ignore: must_be_immutable
class MihHome extends StatefulWidget { class MihHome extends StatefulWidget {
final bool personalSelected;
const MihHome({ const MihHome({
super.key, super.key,
required this.personalSelected,
}); });
@override @override
@@ -38,12 +41,49 @@ class MihHome extends StatefulWidget {
class _MihHomeState extends State<MihHome> { class _MihHomeState extends State<MihHome> {
final proPicController = TextEditingController(); final proPicController = TextEditingController();
late int _selcetedIndex; late int _selcetedIndex;
late bool _personalSelected; late bool _personalHome;
late Future<HomeArguments> profileData;
late Future<UserConsent?> futureUserConsent;
bool showUserConsent = false;
DateTime latestPrivacyPolicyDate = DateTime.parse("2024-12-01"); DateTime latestPrivacyPolicyDate = DateTime.parse("2024-12-01");
DateTime latestTermOfServiceDate = DateTime.parse("2024-12-01"); DateTime latestTermOfServiceDate = DateTime.parse("2024-12-01");
bool _isLoadingInitialData = true;
Future<void> _loadInitialData() async {
// Note: getUserData sets user and userProfilePicUrl in the provider
await getUserData();
// Note: getUserConsentStatus sets userConsent in the provider
await getUserConsentStatus();
await getBusinessData();
// 2. Set state after all data is loaded
if (mounted) {
setState(() {
_isLoadingInitialData = false;
});
}
}
Future<void> getBusinessData() async {
Business? business = context.read<MzansiProfileProvider>().business;
AppUser? user = context.read<MzansiProfileProvider>().user;
String logoUrl;
String signatureUrl;
if (business == null && user!.type == "business") {
// Get Business
await MihBusinessDetailsServices().getBusinessDetailsByUser(context);
logoUrl = await MihFileApi.getMinioFileUrl(
context.read<MzansiProfileProvider>().business!.logo_path,
context,
);
context.read<MzansiProfileProvider>().setBusinessProfilePicUrl(logoUrl);
// Get Business User
await MihMyBusinessUserServices().getBusinessUser(context);
signatureUrl = await MihFileApi.getMinioFileUrl(
context.read<MzansiProfileProvider>().businessUser!.sig_path,
context,
);
context
.read<MzansiProfileProvider>()
.setBusinessUserSignatureUrl(signatureUrl);
}
}
bool showPolicyWindow(UserConsent? userConsent) { bool showPolicyWindow(UserConsent? userConsent) {
if (userConsent == null) { if (userConsent == null) {
@@ -60,20 +100,19 @@ class _MihHomeState extends State<MihHome> {
} }
} }
void createOrUpdateAccpetance(UserConsent? userConsent, String app_id) { void createOrUpdateAccpetance(MzansiProfileProvider mzansiProfileProvider) {
UserConsent? userConsent = mzansiProfileProvider.userConsent;
userConsent != null userConsent != null
? MihUserConsentServices() ? MihUserConsentServices()
.updateUserConsentStatus( .updateUserConsentStatus(
app_id,
DateTime.now().toIso8601String(), DateTime.now().toIso8601String(),
DateTime.now().toIso8601String(), DateTime.now().toIso8601String(),
mzansiProfileProvider,
context,
) )
.then((value) { .then((value) {
if (value == 200) { if (value == 200) {
// setState(() { context.goNamed("mihHome");
// showUserConsent = false;
// });
context.goNamed("mihHome", extra: false);
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
MihSnackBar( MihSnackBar(
child: Text("Thank you for accepting our Policies"), child: Text("Thank you for accepting our Policies"),
@@ -89,16 +128,14 @@ class _MihHomeState extends State<MihHome> {
}) })
: MihUserConsentServices() : MihUserConsentServices()
.insertUserConsentStatus( .insertUserConsentStatus(
app_id,
DateTime.now().toIso8601String(), DateTime.now().toIso8601String(),
DateTime.now().toIso8601String(), DateTime.now().toIso8601String(),
mzansiProfileProvider,
context,
) )
.then((value) { .then((value) {
if (value == 201) { if (value == 201) {
// setState(() { context.goNamed("mihHome");
// showUserConsent = false;
// });
context.goNamed("mihHome", extra: false);
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
MihSnackBar( MihSnackBar(
child: Text("Thank you for accepting our Policies"), child: Text("Thank you for accepting our Policies"),
@@ -114,6 +151,22 @@ class _MihHomeState extends State<MihHome> {
}); });
} }
Future<void> getUserData() async {
String url;
await MihUserServices().getUserDetails(
context,
);
url = await MihFileApi.getMinioFileUrl(
context.read<MzansiProfileProvider>().user!.pro_pic_path,
context,
);
context.read<MzansiProfileProvider>().setUserProfilePicUrl(url);
}
Future<void> getUserConsentStatus() async {
await MihUserConsentServices().getUserConsentStatus(context);
}
@override @override
void dispose() { void dispose() {
super.dispose(); super.dispose();
@@ -122,18 +175,15 @@ class _MihHomeState extends State<MihHome> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
profileData = MIHApiCalls().getProfile(10, context); WidgetsBinding.instance.addPostFrameCallback((_) async {
futureUserConsent = MihUserConsentServices().getUserConsentStatus(); _loadInitialData();
if (widget.personalSelected == true) { });
setState(() { if (context.read<MzansiProfileProvider>().personalHome == true) {
_selcetedIndex = 0; _selcetedIndex = 0;
_personalSelected = true; _personalHome = true;
});
} else { } else {
setState(() { _selcetedIndex = 1;
_selcetedIndex = 1; _personalHome = false;
_personalSelected = false;
});
} }
} }
@@ -147,278 +197,239 @@ class _MihHomeState extends State<MihHome> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return FutureBuilder( return Consumer<MzansiProfileProvider>(
future: profileData, builder: (BuildContext context,
builder: (context, asyncSnapshot) { MzansiProfileProvider mzansiProfileProvider, Widget? child) {
if (asyncSnapshot.connectionState == ConnectionState.waiting) { if (_isLoadingInitialData) {
return Scaffold( return Scaffold(
body: const Mihloadingcircle( body: Center(
// message: "Fetching your Data...", child: Mihloadingcircle(),
), ),
); );
} else if (asyncSnapshot.connectionState == ConnectionState.done && }
asyncSnapshot.hasData) { // bool showConsentWindow =
return Stack( // showPolicyWindow(mzansiProfileProvider.userConsent);
children: [ return Stack(
MihPackage( children: [
appActionButton: getAction(asyncSnapshot.data!.profilePicUrl), MihPackage(
appTools: getTools( appActionButton:
asyncSnapshot.data!.signedInUser.type != "personal"), getAction(mzansiProfileProvider.userProfilePicUrl as String),
appBody: getToolBody(asyncSnapshot.data!), appTools:
appToolTitles: getToolTitle(), getTools(mzansiProfileProvider.user!.type != "personal"),
actionDrawer: getActionDrawer( appBody: getToolBody(),
asyncSnapshot.data!.signedInUser, appToolTitles: getToolTitle(),
asyncSnapshot.data!.profilePicUrl, actionDrawer: getActionDrawer(),
), selectedbodyIndex: _selcetedIndex,
selectedbodyIndex: _selcetedIndex, onIndexChange: (newValue) {
onIndexChange: (newValue) { if (_selcetedIndex == 0) {
if (_selcetedIndex == 0) { setState(() {
setState(() { _selcetedIndex = newValue;
_selcetedIndex = newValue; _personalHome = true;
_personalSelected = true; });
}); } else {
} else { setState(() {
setState(() { _selcetedIndex = newValue;
_selcetedIndex = newValue; _personalHome = false;
_personalSelected = false; });
}); }
} },
}, ),
), Visibility(
FutureBuilder( visible: showPolicyWindow(mzansiProfileProvider.userConsent),
future: futureUserConsent, child: Container(
builder: (context, asyncSnapshotUserConsent) { color: Colors.black.withValues(alpha: 0.5),
if (asyncSnapshotUserConsent.connectionState == child: Column(
ConnectionState.waiting) { mainAxisAlignment: MainAxisAlignment.center,
showUserConsent = false; mainAxisSize: MainAxisSize.max,
} else if (asyncSnapshotUserConsent.connectionState == children: [
ConnectionState.done && MihPackageWindow(
asyncSnapshotUserConsent.hasData) { fullscreen: false,
showUserConsent = windowTitle: "Privacy Policy & Terms Of Service Alert!",
showPolicyWindow(asyncSnapshotUserConsent.data); onWindowTapClose: () {
} else if (asyncSnapshotUserConsent.connectionState == showDialog(
ConnectionState.done && context: context,
!asyncSnapshotUserConsent.hasData) { builder: (context) {
showUserConsent = true; return MihPackageAlert(
} else { alertIcon: Icon(
showUserConsent = false; Icons.warning_amber_rounded,
} size: 100,
return Visibility( color: MihColors.getRedColor(
visible: showUserConsent, MzansiInnovationHub.of(context)!
child: Container( .theme
color: Colors.black.withValues(alpha: 0.5), .mode ==
child: Column( "Dark",
mainAxisAlignment: MainAxisAlignment.center, ),
mainAxisSize: MainAxisSize.max, ),
children: [ alertTitle:
MihPackageWindow( "Oops, Looks like you missed a step!",
fullscreen: false, alertBody: Text(
windowTitle: "We're excited for you to keep using the MIH app! Before you do, please take a moment to accept our Privacy Policy and Terms of Service. Thanks for helping us keep your experience great!",
"Privacy Policy & Terms Of Service Alert!", textAlign: TextAlign.center,
onWindowTapClose: () { style: TextStyle(
showDialog(
context: context,
builder: (context) {
return MihPackageAlert(
alertIcon: Icon(
Icons.warning_amber_rounded,
size: 100,
color: MihColors.getRedColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark",
),
),
alertTitle:
"Oops, Looks like you missed a step!",
alertBody: Text(
"We're excited for you to keep using the MIH app! Before you do, please take a moment to accept our Privacy Policy and Terms of Service. Thanks for helping us keep your experience great!",
textAlign: TextAlign.center,
style: TextStyle(
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark",
),
fontSize: 15,
fontWeight: FontWeight.normal,
),
),
alertColour: MihColors.getRedColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark",
),
);
});
},
windowBody: Column(
children: [
Icon(
Icons.policy,
size: 150,
color: MihColors.getSecondaryColor( color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)! MzansiInnovationHub.of(context)!
.theme .theme
.mode == .mode ==
"Dark", "Dark",
), ),
fontSize: 15,
fontWeight: FontWeight.normal,
), ),
const SizedBox(height: 10), ),
Text( alertColour: MihColors.getRedColor(
"Welcome to the MIH App", MzansiInnovationHub.of(context)!.theme.mode ==
textAlign: TextAlign.center, "Dark",
),
);
});
},
windowBody: Column(
children: [
Icon(
Icons.policy,
size: 150,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark",
),
),
const SizedBox(height: 10),
Text(
"Welcome to the MIH App",
textAlign: TextAlign.center,
style: TextStyle(
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark",
),
fontSize: 30,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 10),
Text(
"To keep using the MIH app, please take a moment to review and accept our Policies. Our agreements helps us keep things running smoothly and securely.",
textAlign: TextAlign.center,
style: TextStyle(
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark",
),
fontSize: 15,
fontWeight: FontWeight.normal,
),
),
const SizedBox(height: 20),
Center(
child: Wrap(
alignment: WrapAlignment.center,
spacing: 10,
runSpacing: 10,
children: [
MihButton(
onPressed: () {
WidgetsBinding.instance
.addPostFrameCallback((_) async {
context
.read<AboutMihProvider>()
.setToolIndex(1);
});
context.goNamed("aboutMih",
extra:
mzansiProfileProvider.personalHome);
},
buttonColor: MihColors.getOrangeColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
elevation: 10,
width: 300,
child: Text(
"Privacy Policy",
style: TextStyle( style: TextStyle(
color: MihColors.getSecondaryColor( color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)! MzansiInnovationHub.of(context)!
.theme .theme
.mode == .mode ==
"Dark", "Dark"),
), fontSize: 20,
fontSize: 30,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
const SizedBox(height: 10), ),
Text( MihButton(
"To keep using the MIH app, please take a moment to review and accept our Policies. Our agreements helps us keep things running smoothly and securely.", onPressed: () {
textAlign: TextAlign.center, WidgetsBinding.instance
.addPostFrameCallback((_) async {
context
.read<AboutMihProvider>()
.setToolIndex(2);
});
context.goNamed("aboutMih",
extra:
mzansiProfileProvider.personalHome);
},
buttonColor: MihColors.getYellowColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
elevation: 10,
width: 300,
child: Text(
"Terms of Service",
style: TextStyle( style: TextStyle(
color: MihColors.getSecondaryColor( color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)! MzansiInnovationHub.of(context)!
.theme .theme
.mode == .mode ==
"Dark", "Dark"),
), fontSize: 20,
fontSize: 15, fontWeight: FontWeight.bold,
fontWeight: FontWeight.normal,
), ),
), ),
const SizedBox(height: 20), ),
Center( MihButton(
child: Wrap( onPressed: () {
alignment: WrapAlignment.center, DateTime now = DateTime.now();
spacing: 10, KenLogger.success("Date Time Now: $now");
runSpacing: 10, createOrUpdateAccpetance(
children: [ mzansiProfileProvider);
MihButton( },
onPressed: () { buttonColor: MihColors.getGreenColor(
context.goNamed( MzansiInnovationHub.of(context)!
"aboutMih", .theme
extra: AboutArguments( .mode ==
widget.personalSelected, "Dark"),
1, elevation: 10,
), width: 300,
); child: Text(
}, "Accept",
buttonColor: MihColors.getOrangeColor( style: TextStyle(
MzansiInnovationHub.of(context)! color: MihColors.getPrimaryColor(
.theme MzansiInnovationHub.of(context)!
.mode == .theme
"Dark"), .mode ==
elevation: 10, "Dark"),
width: 300, fontSize: 20,
child: Text( fontWeight: FontWeight.bold,
"Privacy Policy",
style: TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(
context)!
.theme
.mode ==
"Dark"),
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
),
MihButton(
onPressed: () {
context.goNamed(
"aboutMih",
extra: AboutArguments(
widget.personalSelected,
2,
),
);
},
buttonColor: MihColors.getYellowColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
elevation: 10,
width: 300,
child: Text(
"Terms of Service",
style: TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(
context)!
.theme
.mode ==
"Dark"),
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
),
MihButton(
onPressed: () {
DateTime now = DateTime.now();
KenLogger.success(
"Date Time Now: $now");
createOrUpdateAccpetance(
asyncSnapshotUserConsent.data,
asyncSnapshot
.data!.signedInUser.app_id,
);
},
buttonColor: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
elevation: 10,
width: 300,
child: Text(
"Accept",
style: TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(
context)!
.theme
.mode ==
"Dark"),
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
),
],
), ),
), ),
const SizedBox(height: 10), ),
], ],
),
), ),
], ),
), const SizedBox(height: 10),
],
), ),
); ),
}), ],
], ),
); ),
} else { ),
return MihHomeError( ],
errorMessage: asyncSnapshot.hasError );
? asyncSnapshot.error.toString()
: "An unknown error occurred",
);
}
}, },
); );
} }
@@ -464,7 +475,11 @@ class _MihHomeState extends State<MihHome> {
}); });
} }
MIHAppDrawer getActionDrawer(AppUser signedInUser, String proPicUrl) { MIHAppDrawer getActionDrawer() {
AppUser signedInUser =
context.watch<MzansiProfileProvider>().user as AppUser;
String proPicUrl =
context.watch<MzansiProfileProvider>().userProfilePicUrl ?? "";
return MIHAppDrawer( return MIHAppDrawer(
signedInUser: signedInUser, signedInUser: signedInUser,
propicFile: proPicUrl != "" ? NetworkImage(proPicUrl) : null, propicFile: proPicUrl != "" ? NetworkImage(proPicUrl) : null,
@@ -476,14 +491,14 @@ class _MihHomeState extends State<MihHome> {
temp[const Icon(Icons.person)] = () { temp[const Icon(Icons.person)] = () {
setState(() { setState(() {
_selcetedIndex = 0; _selcetedIndex = 0;
_personalSelected = true; _personalHome = true;
}); });
}; };
if (isBusinessUser) { if (isBusinessUser) {
temp[const Icon(Icons.business_center)] = () { temp[const Icon(Icons.business_center)] = () {
setState(() { setState(() {
_selcetedIndex = 1; _selcetedIndex = 1;
_personalSelected = false; _personalHome = false;
}); });
}; };
} }
@@ -493,29 +508,35 @@ class _MihHomeState extends State<MihHome> {
); );
} }
List<Widget> getToolBody(HomeArguments profData) { List<Widget> getToolBody() {
List<Widget> toolBodies = []; List<Widget> toolBodies = [];
AppUser? user = context.watch<MzansiProfileProvider>().user;
Business? business = context.watch<MzansiProfileProvider>().business;
BusinessUser? businessUser =
context.watch<MzansiProfileProvider>().businessUser;
String userProfilePictureUrl =
context.watch<MzansiProfileProvider>().userProfilePicUrl ?? "";
toolBodies.add( toolBodies.add(
MihPersonalHome( MihPersonalHome(
signedInUser: profData.signedInUser, signedInUser: user!,
personalSelected: _personalSelected, personalSelected: _personalHome,
business: profData.business, business: business,
businessUser: profData.businessUser, businessUser: businessUser,
propicFile: profData.profilePicUrl != "" propicFile: userProfilePictureUrl != ""
? NetworkImage(profData.profilePicUrl) ? NetworkImage(userProfilePictureUrl)
: null, : null,
isDevActive: AppEnviroment.getEnv() == "Dev", isDevActive: AppEnviroment.getEnv() == "Dev",
isUserNew: profData.signedInUser.username == "", isUserNew: user.username == "",
), ),
); );
if (profData.signedInUser.type != "personal") { if (user.type != "personal") {
toolBodies.add( toolBodies.add(
MihBusinessHome( MihBusinessHome(
signedInUser: profData.signedInUser, signedInUser: user,
personalSelected: _personalSelected, personalSelected: _personalHome,
businessUser: profData.businessUser, businessUser: businessUser,
business: profData.business, business: business,
isBusinessUserNew: profData.businessUser == null, isBusinessUserNew: businessUser == null,
), ),
); );
} }

View File

@@ -14,6 +14,7 @@ import 'package:mzansi_innovation_hub/mih_packages/about_mih/package_tile/about_
import 'package:mzansi_innovation_hub/mih_packages/access_review/package_tile/mih_access_tile.dart'; import 'package:mzansi_innovation_hub/mih_packages/access_review/package_tile/mih_access_tile.dart';
import 'package:mzansi_innovation_hub/mih_packages/calculator/package_tiles/mih_calculator_tile.dart'; import 'package:mzansi_innovation_hub/mih_packages/calculator/package_tiles/mih_calculator_tile.dart';
import 'package:mzansi_innovation_hub/mih_packages/calendar/package_tiles/mzansi_calendar_tile.dart'; import 'package:mzansi_innovation_hub/mih_packages/calendar/package_tiles/mzansi_calendar_tile.dart';
import 'package:mzansi_innovation_hub/mih_packages/mine_sweeper/package_tiles/mih_mine_sweeper_tile.dart';
import 'package:mzansi_innovation_hub/mih_packages/mzansi_ai/package_tiles/mzansi_ai_tile.dart'; import 'package:mzansi_innovation_hub/mih_packages/mzansi_ai/package_tiles/mzansi_ai_tile.dart';
import 'package:mzansi_innovation_hub/mih_packages/mzansi_directory/package_tiles/mzansi_directory_tile.dart'; import 'package:mzansi_innovation_hub/mih_packages/mzansi_directory/package_tiles/mzansi_directory_tile.dart';
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/personal_profile/package_tiles/mzansi_profile_tile.dart'; import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/personal_profile/package_tiles/mzansi_profile_tile.dart';
@@ -153,6 +154,13 @@ class _MihPersonalHomeState extends State<MihPersonalHome>
packageSize: packageSize, packageSize: packageSize,
) )
}); });
//=============== Mine Sweeper ===============
temp.add({
"Mine Sweeper": MihMineSweeperTile(
personalSelected: widget.personalSelected,
packageSize: packageSize,
)
});
//=============== MIH Access =============== //=============== MIH Access ===============
temp.add({ temp.add({
"MIH Access": MihAccessTile( "MIH Access": MihAccessTile(

View File

@@ -4,6 +4,7 @@ import 'package:flutter_speed_dial/flutter_speed_dial.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/main.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart'; import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart'; import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
@@ -16,19 +17,17 @@ import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_del
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.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_components/mih_objects/arguments.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_employee.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_employee.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:supertokens_flutter/http.dart' as http; import 'package:supertokens_flutter/http.dart' as http;
class BuildEmployeeList extends StatefulWidget { class BuildEmployeeList extends StatefulWidget {
final List<BusinessEmployee> employees; final List<BusinessEmployee> employees;
final BusinessArguments arguments;
const BuildEmployeeList({ const BuildEmployeeList({
super.key, super.key,
required this.employees, required this.employees,
required this.arguments,
}); });
@override @override
@@ -369,36 +368,41 @@ class _BuildEmployeeListState extends State<BuildEmployeeList> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
double screenWidth = MediaQuery.of(context).size.width; double screenWidth = MediaQuery.of(context).size.width;
return ListView.separated( return Consumer<MzansiProfileProvider>(
shrinkWrap: true, builder: (BuildContext context,
physics: const NeverScrollableScrollPhysics(), MzansiProfileProvider mzansiProfileProvider, Widget? child) {
separatorBuilder: (BuildContext context, index) { return ListView.separated(
return Divider( shrinkWrap: true,
color: MihColors.getSecondaryColor( physics: const NeverScrollableScrollPhysics(),
MzansiInnovationHub.of(context)!.theme.mode == "Dark"), separatorBuilder: (BuildContext context, index) {
); return Divider(
},
itemCount: widget.employees.length,
itemBuilder: (context, index) {
//final patient = widget.patients[index].id_no.contains(widget.searchString);
//print(index);
var isMe = "";
if (widget.arguments.signedInUser.app_id ==
widget.employees[index].app_id) {
isMe = "(You)";
}
return ListTile(
title: Text(
"${widget.employees[index].fname} ${widget.employees[index].lname} - ${widget.employees[index].title} $isMe"),
subtitle: Text(
"${widget.employees[index].username}\n${widget.employees[index].email}\nAccess: ${widget.employees[index].access}",
style: TextStyle(
color: MihColors.getSecondaryColor( color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"), MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
), );
), },
onTap: () { itemCount: widget.employees.length,
updateEmployeePopUp(index, screenWidth); itemBuilder: (context, index) {
//final patient = widget.patients[index].id_no.contains(widget.searchString);
//print(index);
var isMe = "";
if (mzansiProfileProvider.user!.app_id ==
widget.employees[index].app_id) {
isMe = "(You)";
}
return ListTile(
title: Text(
"${widget.employees[index].fname} ${widget.employees[index].lname} - ${widget.employees[index].title} $isMe"),
subtitle: Text(
"${widget.employees[index].username}\n${widget.employees[index].email}\nAccess: ${widget.employees[index].access}",
style: TextStyle(
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
),
),
onTap: () {
updateEmployeePopUp(index, screenWidth);
},
);
}, },
); );
}, },

View File

@@ -0,0 +1,705 @@
import 'package:country_code_picker/country_code_picker.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
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_button.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_circle_avatar.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_form.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_window.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_text_form_field.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.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/mzansi_profile_provider.dart';
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
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_location_services.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
import 'package:provider/provider.dart';
class MihUpdateBusinessDetailsWindow extends StatefulWidget {
final double width;
const MihUpdateBusinessDetailsWindow({
super.key,
required this.width,
});
@override
State<MihUpdateBusinessDetailsWindow> createState() =>
_MihUpdateBusinessDetailsWindowState();
}
class _MihUpdateBusinessDetailsWindowState
extends State<MihUpdateBusinessDetailsWindow> {
final _formKey = GlobalKey<FormState>();
PlatformFile? newSelectedLogoPic;
final fileNameController = TextEditingController();
final regController = TextEditingController();
final nameController = TextEditingController();
final typeController = TextEditingController();
final practiceNoController = TextEditingController();
final vatNoController = TextEditingController();
final countryCodeController = TextEditingController();
final contactController = TextEditingController();
final emailController = TextEditingController();
final locationController = TextEditingController();
final websiteController = TextEditingController();
final ratingController = TextEditingController();
final missionVisionController = TextEditingController();
final ValueNotifier<int> _counter = ValueNotifier<int>(0);
late String env;
void setContactNumberControllers(
MzansiProfileProvider mzansiProfileProvider) {
if (mzansiProfileProvider.business!.contact_no[0] == "+") {
List<String> contactDetails =
mzansiProfileProvider.business!.contact_no.split("-");
setState(() {
countryCodeController.text = contactDetails[0];
contactController.text = contactDetails[1];
});
} else {
setState(() {
countryCodeController.text = "+27";
contactController.text = mzansiProfileProvider.business!.contact_no;
});
}
}
void setControllers() {
MzansiProfileProvider mzansiProfileProvider =
context.read<MzansiProfileProvider>();
setState(() {
fileNameController.text =
mzansiProfileProvider.business!.logo_path.split("/").last;
regController.text = mzansiProfileProvider.business!.registration_no;
nameController.text = mzansiProfileProvider.business!.Name;
typeController.text = mzansiProfileProvider.business!.type;
practiceNoController.text = mzansiProfileProvider.business!.practice_no;
vatNoController.text = mzansiProfileProvider.business!.vat_no;
emailController.text = mzansiProfileProvider.business!.bus_email;
locationController.text = mzansiProfileProvider.business!.gps_location;
websiteController.text = mzansiProfileProvider.business!.website;
ratingController.text = mzansiProfileProvider.business!.rating;
missionVisionController.text =
mzansiProfileProvider.business!.mission_vision;
});
setContactNumberControllers(mzansiProfileProvider);
if (AppEnviroment.getEnv() == "Prod") {
env = "Prod";
} else {
env = "Dev";
}
}
Color getMissionVisionLimitColor(int limit) {
if (_counter.value <= limit) {
return MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark");
} else {
return MihColors.getRedColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark");
}
}
void _updateMissionVisionCounter() {
// New function name
// No need for setState since you are using a ValueNotifier for _counter
_counter.value = missionVisionController.text.characters.length;
}
String getNumberWithCountryCode() {
String numberWithoutBeginingZero = "";
if (contactController.text[0] == "0") {
numberWithoutBeginingZero = contactController.text
.replaceAll(" ", "")
.substring(1, contactController.text.length);
} else {
numberWithoutBeginingZero = contactController.text.replaceAll("-", " ");
}
return "${countryCodeController.text}-$numberWithoutBeginingZero";
}
bool isFormFilled() {
if (typeController.text.isEmpty) {
return false;
} else {
return true;
}
}
void successPopUp(String message, bool stayOnPersonalSide) {
showDialog(
context: context,
builder: (context) {
return MihPackageAlert(
alertIcon: Icon(
Icons.check_circle_outline_rounded,
size: 150,
color: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
),
alertTitle: "Successfully Updated Profile",
alertBody: Column(
children: [
Text(
message,
style: TextStyle(
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
fontSize: 15,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 25),
Center(
child: MihButton(
onPressed: () {
context.pop();
},
buttonColor: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
elevation: 10,
width: 300,
child: Text(
"Dismiss",
style: TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
),
)
],
),
alertColour: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
);
// return MIHSuccessMessage(
// successType: "Success",
// successMessage: message,
// );
},
);
}
Future<bool> uploadFile(MzansiProfileProvider mzansiProfileProvider) async {
if (newSelectedLogoPic != null) {
int uploadStatusCode = 0;
uploadStatusCode = await MihFileApi.uploadFile(
mzansiProfileProvider.business!.business_id,
env,
"business_files",
newSelectedLogoPic!,
context,
);
if (uploadStatusCode == 200) {
int deleteStatusCode = 0;
deleteStatusCode = await MihFileApi.deleteFile(
mzansiProfileProvider.business!.logo_path.split("/").first,
env,
"business_files",
mzansiProfileProvider.business!.logo_path.split("/").last,
context,
);
if (deleteStatusCode == 200) {
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return true; // No file selected, so no upload needed
}
}
Future<void> submitForm(MzansiProfileProvider mzansiProfileProvider) async {
KenLogger.success("Start Submit Form");
if (isFormFilled()) {
KenLogger.success("Form Filled");
KenLogger.success("Start File Upload");
bool successfullyUploadedFile = await uploadFile(mzansiProfileProvider);
KenLogger.success(
"File Upload Complete: outcome $successfullyUploadedFile");
if (!mounted) return;
KenLogger.success("is mounted");
if (successfullyUploadedFile) {
KenLogger.success("Start Details Update");
int statusCode = 0;
statusCode = await MihBusinessDetailsServices().updateBusinessDetailsV2(
mzansiProfileProvider.business!.business_id,
nameController.text,
typeController.text,
regController.text,
practiceNoController.text,
vatNoController.text,
emailController.text,
getNumberWithCountryCode(),
// contactController.text,
locationController.text,
fileNameController.text,
websiteController.text,
ratingController.text.isEmpty ? "0" : ratingController.text,
missionVisionController.text,
mzansiProfileProvider,
context,
);
KenLogger.success("Details Update Complete: status code $statusCode");
if (!mounted) return;
KenLogger.success("is mounted");
if (statusCode == 200) {
KenLogger.success("Start Success Message");
//You left of here
String message = "Your information has been updated successfully!";
context.pop();
successPopUp(message, false);
// File uploaded successfully
} else {
context.pop();
// File upload failed
showDialog(
context: context,
builder: (context) {
return MihPackageAlert(
alertIcon: Icon(
Icons.warning_rounded,
color: MihColors.getRedColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
),
alertTitle: "Error Updating Business Details",
alertBody: Column(
children: [
Text(
"An error occurred while updating the business details. Please check internet connection and try again.",
style: TextStyle(
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
),
),
],
),
alertColour: MihColors.getRedColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
);
},
);
}
} else {
context.pop();
if (!mounted) return;
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(errorType: "Internet Connection");
},
);
}
} else {
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(errorType: "Input Error");
},
);
}
}
@override
void initState() {
super.initState();
setControllers();
missionVisionController.addListener(_updateMissionVisionCounter);
}
@override
Widget build(BuildContext context) {
return Consumer<MzansiProfileProvider>(
builder: (BuildContext context,
MzansiProfileProvider mzansiProfileProvider, Widget? child) {
return MihPackageWindow(
fullscreen: false,
windowTitle: 'Edit Profile',
onWindowTapClose: () {
context.pop();
},
windowBody: MihSingleChildScroll(
child: Padding(
padding:
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
? EdgeInsets.symmetric(horizontal: widget.width * 0.05)
: EdgeInsets.symmetric(horizontal: widget.width * 0),
child: Column(
children: [
MihForm(
formKey: _formKey,
formFields: [
Center(
child: MihCircleAvatar(
imageFile: newSelectedLogoPic != null
? MemoryImage(newSelectedLogoPic!.bytes!)
: mzansiProfileProvider.businessProfilePicture,
width: 150,
editable: true,
fileNameController: fileNameController,
userSelectedfile: newSelectedLogoPic,
frameColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
backgroundColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
onChange: (selectedfile) {
setState(() {
newSelectedLogoPic = selectedfile;
});
},
),
),
Visibility(
visible: false,
child: MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: fileNameController,
multiLineInput: false,
requiredText: true,
readOnly: true,
hintText: "Selected File Name",
),
),
const SizedBox(height: 20),
MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: nameController,
multiLineInput: false,
requiredText: true,
hintText: "Business Name",
validator: (value) {
return MihValidationServices().isEmpty(value);
},
),
const SizedBox(height: 10),
MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: typeController,
multiLineInput: false,
requiredText: true,
hintText: "Business Type",
validator: (value) {
return MihValidationServices()
.validateNoSpecialChars(value);
},
),
const SizedBox(height: 10),
MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: emailController,
multiLineInput: false,
requiredText: true,
hintText: "Business Email",
validator: (value) {
return MihValidationServices().validateEmail(value);
},
),
const SizedBox(height: 10),
Container(
width: 300,
alignment: Alignment.topLeft,
child: const Text(
"Contact Number:",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
CountryCodePicker(
padding: EdgeInsetsGeometry.all(0),
onChanged: (selectedCode) {
setState(() {
countryCodeController.text =
selectedCode.toString();
});
debugPrint(
"Selected Country Code: ${countryCodeController.text}");
},
initialSelection: countryCodeController.text,
showDropDownButton: false,
pickerStyle: PickerStyle.bottomSheet,
dialogBackgroundColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
barrierColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
),
Expanded(
child: MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: contactController,
numberMode: true,
multiLineInput: false,
requiredText: true,
hintText: null,
validator: (value) {
return MihValidationServices().isEmpty(value);
},
),
),
],
),
const SizedBox(height: 10),
MihTextFormField(
height: 250,
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: missionVisionController,
multiLineInput: true,
requiredText: true,
hintText: "Business Mission & Vision",
validator: (value) {
return MihValidationServices().validateLength(
missionVisionController.text, 256);
},
),
SizedBox(
height: 15,
child: ValueListenableBuilder(
valueListenable: _counter,
builder:
(BuildContext context, int value, Widget? child) {
return Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
"$value",
style: TextStyle(
color: getMissionVisionLimitColor(256),
fontWeight: FontWeight.bold,
),
),
const SizedBox(width: 5),
Text(
"/256",
style: TextStyle(
color: getMissionVisionLimitColor(256),
fontWeight: FontWeight.bold,
),
),
],
);
},
),
),
const SizedBox(height: 10.0),
MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: websiteController,
multiLineInput: false,
requiredText: false,
hintText: "Business Website",
validator: (value) {
return MihValidationServices()
.validateWebsite(value, false);
},
),
const SizedBox(height: 10),
MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: regController,
multiLineInput: false,
requiredText: false,
hintText: "Registration No.",
validator: (value) {
// return MihValidationServices().isEmpty(value);
return null;
},
),
const SizedBox(height: 10),
MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: practiceNoController,
multiLineInput: false,
requiredText: false,
hintText: "Practice Number",
validator: (validateValue) {
return null;
},
),
const SizedBox(height: 10),
MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: vatNoController,
multiLineInput: false,
requiredText: false,
hintText: "VAT Number",
validator: (value) {
// return MihValidationServices().isEmpty(value);
return null;
},
),
const SizedBox(height: 10),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Flexible(
child: MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: locationController,
multiLineInput: false,
requiredText: true,
readOnly: true,
hintText: "GPS Location",
),
),
const SizedBox(width: 10.0),
MihButton(
onPressed: () {
showDialog(
context: context,
builder: (context) {
return const Mihloadingcircle(
message: "Getting your location",
);
},
);
MIHLocationAPI()
.getGPSPosition(context)
.then((position) {
if (position != null) {
setState(() {
locationController.text =
"${position.latitude}, ${position.longitude}";
});
}
//Dismiss loading indicator
context.pop();
});
},
buttonColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
width: 100,
child: Text(
"Set",
style: TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
),
],
),
const SizedBox(height: 25),
Center(
child: MihButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
submitForm(mzansiProfileProvider);
} else {
MihAlertServices()
.formNotFilledCompletely(context);
}
},
buttonColor: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
width: 300,
child: Text(
"Update",
style: TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
),
),
const SizedBox(height: 20),
],
),
],
),
),
),
);
},
);
}
}

View File

@@ -1,23 +1,22 @@
import 'dart:convert';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_qr_code.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_employee.dart';
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_reviews.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.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.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_action.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_details.dart'; import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_details.dart';
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_user_search.dart';
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tools/mih_my_business_team.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tools/mih_my_business_team.dart';
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tools/mih_my_business_user.dart'; import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tools/mih_my_business_user.dart';
import 'package:provider/provider.dart';
import 'package:supertokens_flutter/http.dart' as http;
class MzansiBusinessProfile extends StatefulWidget { class MzansiBusinessProfile extends StatefulWidget {
final BusinessArguments arguments;
const MzansiBusinessProfile({ const MzansiBusinessProfile({
super.key, super.key,
required this.arguments,
}); });
@override @override
@@ -25,26 +24,38 @@ class MzansiBusinessProfile extends StatefulWidget {
} }
class _MzansiBusinessProfileState extends State<MzansiBusinessProfile> { class _MzansiBusinessProfileState extends State<MzansiBusinessProfile> {
int _selcetedIndex = 0; String errorCode = "";
late Future<String> futureLogoUrl; String errorBody = "";
late Future<String> futureProPicUrl;
late Future<String> futureUserSignatureUrl; Future<void> fetchEmployees() async {
//print("Patien manager page: $endpoint");
MzansiProfileProvider mzansiProfileProvider =
context.read<MzansiProfileProvider>();
final response = await http.get(Uri.parse(
"${AppEnviroment.baseApiUrl}/business-user/employees/${mzansiProfileProvider.businessUser!.business_id}"));
errorCode = response.statusCode.toString();
errorBody = response.body;
if (response.statusCode == 200) {
//print("Here1");
Iterable l = jsonDecode(response.body);
//print("Here2");
List<BusinessEmployee> employeeList = List<BusinessEmployee>.from(
l.map((model) => BusinessEmployee.fromJson(model)));
mzansiProfileProvider.setEmployeeList(employeeList: employeeList);
//print("Here3");
//print(patientQueue);
// return patientQueue;
} else {
throw Exception('failed to load employees');
}
}
@override @override
void initState() { void initState() {
super.initState(); super.initState();
futureLogoUrl = MihFileApi.getMinioFileUrl( WidgetsBinding.instance.addPostFrameCallback((_) async {
widget.arguments.business!.logo_path, await fetchEmployees();
context, });
);
futureProPicUrl = MihFileApi.getMinioFileUrl(
widget.arguments.signedInUser.pro_pic_path,
context,
);
futureUserSignatureUrl = MihFileApi.getMinioFileUrl(
widget.arguments.businessUser!.sig_path,
context,
);
} }
@override @override
@@ -54,11 +65,9 @@ class _MzansiBusinessProfileState extends State<MzansiBusinessProfile> {
appTools: getTools(), appTools: getTools(),
appBody: getToolBody(), appBody: getToolBody(),
appToolTitles: getToolTitle(), appToolTitles: getToolTitle(),
selectedbodyIndex: _selcetedIndex, selectedbodyIndex: context.watch<MzansiProfileProvider>().businessIndex,
onIndexChange: (newValue) { onIndexChange: (newIndex) {
setState(() { context.read<MzansiProfileProvider>().setBusinessIndex(newIndex);
_selcetedIndex = newValue;
});
}, },
); );
} }
@@ -80,96 +89,40 @@ class _MzansiBusinessProfileState extends State<MzansiBusinessProfile> {
MihPackageTools getTools() { MihPackageTools getTools() {
Map<Widget, void Function()?> temp = {}; Map<Widget, void Function()?> temp = {};
temp[const Icon(Icons.business)] = () { temp[const Icon(Icons.business)] = () {
setState(() { context.read<MzansiProfileProvider>().setBusinessIndex(0);
_selcetedIndex = 0;
});
}; };
temp[const Icon(Icons.person)] = () { temp[const Icon(Icons.person)] = () {
setState(() { context.read<MzansiProfileProvider>().setBusinessIndex(1);
_selcetedIndex = 1;
});
}; };
// temp[const Icon(Icons.warning)] = () {
// setState(() {
// _selcetedIndex = 2;
// });
// };
temp[const Icon(Icons.people)] = () { temp[const Icon(Icons.people)] = () {
setState(() { context.read<MzansiProfileProvider>().setBusinessIndex(2);
_selcetedIndex = 2;
});
};
temp[const Icon(Icons.add)] = () {
setState(() {
_selcetedIndex = 3;
});
};
temp[const Icon(Icons.star_rate_rounded)] = () {
setState(() {
_selcetedIndex = 4;
});
};
temp[const Icon(Icons.qr_code_rounded)] = () {
setState(() {
_selcetedIndex = 5;
});
}; };
// temp[const Icon(Icons.add)] = () {
// context.read<MzansiProfileProvider>().setBusinessIndex(3);
// };
// temp[const Icon(Icons.star_rate_rounded)] = () {
// context.read<MzansiProfileProvider>().setBusinessIndex(4);
// };
// temp[const Icon(Icons.qr_code_rounded)] = () {
// context.read<MzansiProfileProvider>().setBusinessIndex(5);
// };
return MihPackageTools( return MihPackageTools(
tools: temp, tools: temp,
selcetedIndex: _selcetedIndex, selcetedIndex: context.watch<MzansiProfileProvider>().businessIndex,
); );
} }
List<Widget> getToolBody() { List<Widget> getToolBody() {
List<Widget> toolBodies = [ List<Widget> toolBodies = [
FutureBuilder( MihBusinessDetails(),
future: futureLogoUrl, MihMyBusinessUser(),
builder: (context, snapshot) { MihMyBusinessTeam(),
if (snapshot.connectionState == ConnectionState.waiting) { // MihBusinessUserSearch(arguments: widget.arguments),
return const Center(child: Mihloadingcircle()); // MihBusinessReviews(business: widget.arguments.business!),
} else if (snapshot.connectionState == ConnectionState.done && // MihBusinessQrCode(
snapshot.hasData) { // business: widget.arguments.business!,
final logoUrl = snapshot.data!.isNotEmpty // startUpSearch: "",
? NetworkImage(snapshot.data!) // ),
: null;
return MihBusinessDetails(
arguments: widget.arguments,
logoImage: logoUrl,
);
} else {
return Text("Error: ${snapshot.error}");
}
}),
FutureBuilder<List<String>>(
future: Future.wait([futureProPicUrl, futureUserSignatureUrl]),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: Mihloadingcircle());
} else if (snapshot.connectionState == ConnectionState.done &&
snapshot.hasData) {
final proPicUrl = NetworkImage(snapshot.data![0]);
print("=============== Signature URL: ${snapshot.data![1]}");
final signatureUrl = snapshot.data![1].isNotEmpty
? NetworkImage(snapshot.data![1])
: null;
return MihMyBusinessUser(
arguments: widget.arguments,
userProPicImage: proPicUrl,
userSignatureImage: signatureUrl,
);
} else {
return Text("Error: ${snapshot.error}");
}
},
),
// MihBusinessProfile(arguments: widget.arguments),
MihMyBusinessTeam(arguments: widget.arguments),
MihBusinessUserSearch(arguments: widget.arguments),
MihBusinessReviews(business: widget.arguments.business!),
MihBusinessQrCode(
business: widget.arguments.business!,
startUpSearch: "",
),
]; ];
return toolBodies; return toolBodies;
} }
@@ -179,9 +132,9 @@ class _MzansiBusinessProfileState extends State<MzansiBusinessProfile> {
"Profile", "Profile",
"User", "User",
"Team", "Team",
"Add", // "Add",
"Reviews", // "Reviews",
"Share", // "Share",
]; ];
return toolTitles; return toolTitles;
} }

View File

@@ -3,19 +3,18 @@ import 'package:mzansi_innovation_hub/main.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_single_child_scroll.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tool_body.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tool_body.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.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/mzansi_profile_provider.dart';
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_colors.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_components/mih_objects/arguments.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_employee.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_employee.dart';
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/builders/build_employee_list.dart'; import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/builders/build_employee_list.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:supertokens_flutter/http.dart' as http; import 'package:supertokens_flutter/http.dart' as http;
class MihMyBusinessTeam extends StatefulWidget { class MihMyBusinessTeam extends StatefulWidget {
final BusinessArguments arguments;
const MihMyBusinessTeam({ const MihMyBusinessTeam({
super.key, super.key,
required this.arguments,
}); });
@override @override
@@ -23,36 +22,35 @@ class MihMyBusinessTeam extends StatefulWidget {
} }
class _MihMyBusinessTeamState extends State<MihMyBusinessTeam> { class _MihMyBusinessTeamState extends State<MihMyBusinessTeam> {
late Future<List<BusinessEmployee>> employeeList;
String errorCode = ""; String errorCode = "";
String errorBody = ""; String errorBody = "";
Future<List<BusinessEmployee>> fetchEmployees() async { // Future<void> fetchEmployees(
//print("Patien manager page: $endpoint"); // MzansiProfileProvider mzansiProfileProvider) async {
final response = await http.get(Uri.parse( // //print("Patien manager page: $endpoint");
"${AppEnviroment.baseApiUrl}/business-user/employees/${widget.arguments.businessUser!.business_id}")); // final response = await http.get(Uri.parse(
errorCode = response.statusCode.toString(); // "${AppEnviroment.baseApiUrl}/business-user/employees/${mzansiProfileProvider.businessUser!.business_id}"));
errorBody = response.body; // errorCode = response.statusCode.toString();
if (response.statusCode == 200) { // errorBody = response.body;
//print("Here1"); // if (response.statusCode == 200) {
Iterable l = jsonDecode(response.body); // //print("Here1");
//print("Here2"); // Iterable l = jsonDecode(response.body);
List<BusinessEmployee> patientQueue = List<BusinessEmployee>.from( // //print("Here2");
l.map((model) => BusinessEmployee.fromJson(model))); // List<BusinessEmployee> employeeList = List<BusinessEmployee>.from(
//print("Here3"); // l.map((model) => BusinessEmployee.fromJson(model)));
//print(patientQueue); // mzansiProfileProvider.setEmployeeList(employeeList: employeeList);
return patientQueue; // //print("Here3");
} else { // //print(patientQueue);
throw Exception('failed to load employees'); // // return patientQueue;
} // } else {
} // throw Exception('failed to load employees');
// }
// }
Widget displayEmployeeList(List<BusinessEmployee> employeeList) { Widget displayEmployeeList(List<BusinessEmployee> employeeList) {
if (employeeList.isNotEmpty) { if (employeeList.isNotEmpty) {
return BuildEmployeeList( return BuildEmployeeList(
employees: employeeList, employees: employeeList,
arguments: widget.arguments,
); );
} }
return Center( return Center(
@@ -70,7 +68,10 @@ class _MihMyBusinessTeamState extends State<MihMyBusinessTeam> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
employeeList = fetchEmployees(); // fetchEmployees(context.read<MzansiProfileProvider>()).catchError((e) {
// // Handle the error thrown in fetchEmployees
// print('Error fetching employees: $e');
// });
} }
@override @override
@@ -82,40 +83,20 @@ class _MihMyBusinessTeamState extends State<MihMyBusinessTeam> {
} }
Widget getBody() { Widget getBody() {
return MihSingleChildScroll( return Consumer<MzansiProfileProvider>(
child: Column(mainAxisSize: MainAxisSize.max, children: [ builder: (BuildContext context,
FutureBuilder( MzansiProfileProvider mzansiProfileProvider, Widget? child) {
future: employeeList, if (mzansiProfileProvider.employeeList == null) {
builder: (context, snapshot) { return Center(
//print("patient Queue List ${snapshot.hasData}"); child: Mihloadingcircle(),
if (snapshot.connectionState == ConnectionState.waiting) { );
return const Mihloadingcircle(); }
} else if (snapshot.connectionState == ConnectionState.done) { return MihSingleChildScroll(
//List<BusinessEmployee> employeeListResults; child: Column(mainAxisSize: MainAxisSize.max, children: [
// if (searchString == "") { displayEmployeeList(mzansiProfileProvider.employeeList!),
// patientQueueList = []; ]),
// } else { );
},
// print(patientQueueList);
// }
return displayEmployeeList(snapshot.requireData);
} else {
return Center(
child: Text(
"$errorCode: Error pulling Patients Data\n${AppEnviroment.baseApiUrl}/business-user/users/${widget.arguments.businessUser!.business_id}\n$errorBody",
style: TextStyle(
fontSize: 25,
color: MihColors.getRedColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark")),
textAlign: TextAlign.center,
),
);
}
},
),
]),
); );
} }
} }

View File

@@ -1,7 +1,9 @@
import 'package:file_picker/file_picker.dart'; import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart'; 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/main.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart'; import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart'; import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
@@ -17,18 +19,11 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.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_components/mih_objects/arguments.dart'; import 'package:provider/provider.dart';
class MihMyBusinessUser extends StatefulWidget { class MihMyBusinessUser extends StatefulWidget {
final BusinessArguments arguments;
final ImageProvider<Object>? userProPicImage;
final ImageProvider<Object>? userSignatureImage;
const MihMyBusinessUser({ const MihMyBusinessUser({
super.key, super.key,
required this.arguments,
required this.userProPicImage,
required this.userSignatureImage,
}); });
@override @override
@@ -37,7 +32,7 @@ class MihMyBusinessUser extends StatefulWidget {
class _MihMyBusinessUserState extends State<MihMyBusinessUser> { class _MihMyBusinessUserState extends State<MihMyBusinessUser> {
PlatformFile? userPicFile; PlatformFile? userPicFile;
PlatformFile? userSignatureFile; PlatformFile? newSelectedSignaturePic;
final fileNameController = TextEditingController(); final fileNameController = TextEditingController();
final titleTextController = TextEditingController(); final titleTextController = TextEditingController();
final fnameController = TextEditingController(); final fnameController = TextEditingController();
@@ -55,23 +50,24 @@ class _MihMyBusinessUserState extends State<MihMyBusinessUser> {
} }
} }
Future<bool> uploadFile() async { Future<bool> uploadFile(MzansiProfileProvider mzansiProfileProvider) async {
if (userSignatureFile != null) { if (newSelectedSignaturePic != null) {
int uploadStatusCode = 0; int uploadStatusCode = 0;
uploadStatusCode = await MihFileApi.uploadFile( uploadStatusCode = await MihFileApi.uploadFile(
widget.arguments.signedInUser.app_id, mzansiProfileProvider.user!.app_id,
env, env,
"business_files", "business_files",
userSignatureFile!, newSelectedSignaturePic!,
context, context,
); );
if (uploadStatusCode == 200) { if (uploadStatusCode == 200) {
signtureController.text = newSelectedSignaturePic!.name;
int deleteStatusCode = 0; int deleteStatusCode = 0;
deleteStatusCode = await MihFileApi.deleteFile( deleteStatusCode = await MihFileApi.deleteFile(
widget.arguments.signedInUser.app_id, mzansiProfileProvider.user!.app_id,
env, env,
"business_files", "business_files",
widget.arguments.businessUser!.sig_path.split("/").last, mzansiProfileProvider.businessUser!.sig_path.split("/").last,
context, context,
); );
if (deleteStatusCode == 200) { if (deleteStatusCode == 200) {
@@ -87,42 +83,34 @@ class _MihMyBusinessUserState extends State<MihMyBusinessUser> {
} }
} }
Future<void> submitForm() async { Future<void> submitForm(MzansiProfileProvider mzansiProfileProvider) async {
KenLogger.success("Start Submit Form");
if (isFormFilled()) { if (isFormFilled()) {
int statusCode = await MihMyBusinessUserServices().updateBusinessUser( KenLogger.success("Form Filled");
widget.arguments.signedInUser.app_id, KenLogger.success("Start File Upload");
widget.arguments.businessUser!.business_id, bool successfullyUploadedFile = await uploadFile(mzansiProfileProvider);
titleTextController.text, KenLogger.success(
accessController.text, "File Upload Complete: outcome $successfullyUploadedFile");
signtureController.text, if (!mounted) return;
context, KenLogger.success("is mounted");
); if (successfullyUploadedFile) {
if (statusCode == 200) { int statusCode = await MihMyBusinessUserServices().updateBusinessUser(
bool successfullyUploadedFile = await uploadFile(); mzansiProfileProvider.user!.app_id,
if (successfullyUploadedFile) { mzansiProfileProvider.businessUser!.business_id,
// Navigator.of(context).pop(); titleTextController.text,
// Navigator.of(context).pop(); accessController.text,
// Navigator.of(context).pushNamed( signtureController.text,
// '/', mzansiProfileProvider,
// arguments: AuthArguments( context,
// false, );
// false, KenLogger.success("Details Update Complete: status code $statusCode");
// ), if (!mounted) return;
// ); KenLogger.success("is mounted");
// File uploaded successfully if (statusCode == 200) {
KenLogger.success("Start Success Message");
String message = "Business details updated successfully"; String message = "Business details updated successfully";
successPopUp(message, false); successPopUp(message, false);
// showDialog(
// context: context,
// builder: (context) {
// return const MIHSuccessMessage(
// successType: "Success",
// successMessage: "Business details updated successfully",
// );
// },
// );
} else { } else {
// File upload failed
showDialog( showDialog(
context: context, context: context,
builder: (context) { builder: (context) {
@@ -196,10 +184,7 @@ class _MihMyBusinessUserState extends State<MihMyBusinessUser> {
Center( Center(
child: MihButton( child: MihButton(
onPressed: () { onPressed: () {
context.goNamed( context.pop();
'mihHome',
extra: stayOnPersonalSide,
);
}, },
buttonColor: MihColors.getGreenColor( buttonColor: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"), MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
@@ -230,6 +215,29 @@ class _MihMyBusinessUserState extends State<MihMyBusinessUser> {
); );
} }
void setControllers() {
MzansiProfileProvider mzansiProfileProvider =
context.read<MzansiProfileProvider>();
setState(() {
fileNameController.text =
mzansiProfileProvider.user!.pro_pic_path.split("/").last;
signtureController.text =
mzansiProfileProvider.businessUser!.sig_path.split("/").last;
KenLogger.success("title: ${mzansiProfileProvider.businessUser!.title}");
KenLogger.success(
"sig url: ${mzansiProfileProvider.businessUser!.sig_path}");
titleTextController.text = mzansiProfileProvider.businessUser!.title;
fnameController.text = mzansiProfileProvider.user!.fname;
lnameController.text = mzansiProfileProvider.user!.lname;
accessController.text = mzansiProfileProvider.businessUser!.access;
});
if (AppEnviroment.getEnv() == "Prod") {
env = "Prod";
} else {
env = "Dev";
}
}
@override @override
void dispose() { void dispose() {
super.dispose(); super.dispose();
@@ -240,27 +248,13 @@ class _MihMyBusinessUserState extends State<MihMyBusinessUser> {
accessController.dispose(); accessController.dispose();
signtureController.dispose(); signtureController.dispose();
userPicFile = null; userPicFile = null;
userSignatureFile = null; newSelectedSignaturePic = null;
} }
@override @override
void initState() { void initState() {
super.initState(); super.initState();
setState(() { setControllers();
fileNameController.text =
widget.arguments.signedInUser.pro_pic_path.split("/").last;
signtureController.text =
widget.arguments.businessUser!.sig_path.split("/").last;
titleTextController.text = widget.arguments.businessUser!.title;
fnameController.text = widget.arguments.signedInUser.fname;
lnameController.text = widget.arguments.signedInUser.lname;
accessController.text = widget.arguments.businessUser!.access;
});
if (AppEnviroment.getEnv() == "Prod") {
env = "Prod";
} else {
env = "Dev";
}
} }
@override @override
@@ -274,177 +268,200 @@ class _MihMyBusinessUserState extends State<MihMyBusinessUser> {
} }
Widget getBody(double width) { Widget getBody(double width) {
return MihSingleChildScroll( return Consumer<MzansiProfileProvider>(
child: Padding( builder: (BuildContext context,
padding: MzansiInnovationHub.of(context)!.theme.screenType == "desktop" MzansiProfileProvider mzansiProfileProvider, Widget? child) {
? EdgeInsets.symmetric(horizontal: width * 0.2) return MihSingleChildScroll(
: EdgeInsets.symmetric(horizontal: width * 0.075), child: Padding(
child: Column( padding:
children: [ MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
MihForm( ? EdgeInsets.symmetric(horizontal: width * 0.2)
formKey: _formKey, : EdgeInsets.symmetric(horizontal: width * 0.075),
formFields: [ child: Column(
Center( children: [
child: MihCircleAvatar( MihForm(
imageFile: widget.userProPicImage, formKey: _formKey,
width: 150, formFields: [
editable: false, Center(
fileNameController: fileNameController, child: MihCircleAvatar(
userSelectedfile: userPicFile, imageFile: mzansiProfileProvider.userProfilePicture,
frameColor: MihColors.getSecondaryColor( width: 150,
MzansiInnovationHub.of(context)!.theme.mode == "Dark"), editable: false,
backgroundColor: MihColors.getPrimaryColor( fileNameController: fileNameController,
MzansiInnovationHub.of(context)!.theme.mode == "Dark"), userSelectedfile: userPicFile,
onChange: (_) {}, frameColor: MihColors.getSecondaryColor(
),
),
Visibility(
visible: false,
child: MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
controller: fileNameController,
multiLineInput: false,
requiredText: true,
readOnly: true,
hintText: "Selected File Name",
),
),
const SizedBox(height: 20),
MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
controller: titleTextController,
multiLineInput: false,
requiredText: true,
readOnly: false,
hintText: "Title",
validator: (value) {
return MihValidationServices().isEmpty(value);
},
),
const SizedBox(height: 10),
MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
controller: fnameController,
multiLineInput: false,
requiredText: true,
readOnly: true,
hintText: "First Name",
validator: (value) {
return MihValidationServices().isEmpty(value);
},
),
const SizedBox(height: 10),
MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
controller: lnameController,
multiLineInput: false,
requiredText: true,
readOnly: true,
hintText: "Surname",
validator: (value) {
return MihValidationServices().isEmpty(value);
},
),
const SizedBox(height: 10),
MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
controller: accessController,
multiLineInput: false,
requiredText: true,
hintText: "Access Level",
readOnly: true,
validator: (value) {
return MihValidationServices().isEmpty(value);
},
),
const SizedBox(height: 10),
Container(
width: 300,
alignment: Alignment.topLeft,
child: const Text(
"Signature:",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
Center(
child: MihImageDisplay(
imageFile: widget.userSignatureImage,
width: 300,
height: 200,
editable: true,
fileNameController: signtureController,
userSelectedfile: userSignatureFile,
onChange: (selectedFile) {
setState(() {
userSignatureFile = selectedFile;
});
},
),
),
const SizedBox(height: 10),
Visibility(
visible: false,
child: MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
controller: fileNameController,
multiLineInput: false,
requiredText: true,
readOnly: true,
hintText: "Selected Signature File",
),
),
const SizedBox(height: 15),
Center(
child: MihButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
submitForm();
} else {
MihAlertServices().formNotFilledCompletely(context);
}
},
buttonColor: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
width: 300,
child: Text(
"Update",
style: TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"), "Dark"),
fontSize: 20, backgroundColor: MihColors.getPrimaryColor(
fontWeight: FontWeight.bold, MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
onChange: (_) {},
), ),
), ),
), Visibility(
visible: false,
child: MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: fileNameController,
multiLineInput: false,
requiredText: true,
readOnly: true,
hintText: "Selected File Name",
),
),
const SizedBox(height: 20),
MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: titleTextController,
multiLineInput: false,
requiredText: true,
readOnly: false,
hintText: "Title",
validator: (value) {
return MihValidationServices().isEmpty(value);
},
),
const SizedBox(height: 10),
MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: fnameController,
multiLineInput: false,
requiredText: true,
readOnly: true,
hintText: "First Name",
validator: (value) {
return MihValidationServices().isEmpty(value);
},
),
const SizedBox(height: 10),
MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: lnameController,
multiLineInput: false,
requiredText: true,
readOnly: true,
hintText: "Surname",
validator: (value) {
return MihValidationServices().isEmpty(value);
},
),
const SizedBox(height: 10),
MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: accessController,
multiLineInput: false,
requiredText: true,
hintText: "Access Level",
readOnly: true,
validator: (value) {
return MihValidationServices().isEmpty(value);
},
),
const SizedBox(height: 10),
Container(
width: 300,
alignment: Alignment.topLeft,
child: const Text(
"Signature:",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
Center(
child: MihImageDisplay(
imageFile: newSelectedSignaturePic != null
? MemoryImage(newSelectedSignaturePic!.bytes!)
: mzansiProfileProvider.businessUserSignature,
width: 300,
height: 200,
editable: true,
fileNameController: signtureController,
userSelectedfile: newSelectedSignaturePic,
onChange: (selectedFile) {
setState(() {
newSelectedSignaturePic = selectedFile;
});
},
),
),
const SizedBox(height: 10),
Visibility(
visible: false,
child: MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: fileNameController,
multiLineInput: false,
requiredText: true,
readOnly: true,
hintText: "Selected Signature File",
),
),
const SizedBox(height: 15),
Center(
child: MihButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
submitForm(mzansiProfileProvider);
} else {
MihAlertServices().formNotFilledCompletely(context);
}
},
buttonColor: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
width: 300,
child: Text(
"Update",
style: TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
),
),
const SizedBox(height: 20),
],
), ),
const SizedBox(height: 20),
], ],
), ),
], ),
), );
), },
); );
} }
} }

View File

@@ -2,16 +2,15 @@ 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.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_action.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/personal_profile/package_tools/mih_personal_profile.dart'; import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/personal_profile/package_tools/mih_personal_profile.dart';
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/personal_profile/package_tools/mih_personal_settings.dart'; import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/personal_profile/package_tools/mih_personal_settings.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class MzansiProfile extends StatefulWidget { class MzansiProfile extends StatefulWidget {
final AppProfileUpdateArguments arguments;
const MzansiProfile({ const MzansiProfile({
super.key, super.key,
required this.arguments,
}); });
@override @override
@@ -19,8 +18,6 @@ class MzansiProfile extends StatefulWidget {
} }
class _MzansiProfileState extends State<MzansiProfile> { class _MzansiProfileState extends State<MzansiProfile> {
int _selcetedIndex = 0;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MihPackage( return MihPackage(
@@ -28,11 +25,9 @@ class _MzansiProfileState extends State<MzansiProfile> {
appTools: getTools(), appTools: getTools(),
appBody: getToolBody(), appBody: getToolBody(),
appToolTitles: getToolTitle(), appToolTitles: getToolTitle(),
selectedbodyIndex: _selcetedIndex, selectedbodyIndex: context.watch<MzansiProfileProvider>().personalIndex,
onIndexChange: (newValue) { onIndexChange: (newIndex) {
setState(() { context.read<MzansiProfileProvider>().setPersonalIndex(newIndex);
_selcetedIndex = newValue;
});
}, },
); );
} }
@@ -55,29 +50,25 @@ class _MzansiProfileState extends State<MzansiProfile> {
MihPackageTools getTools() { MihPackageTools getTools() {
Map<Widget, void Function()?> temp = {}; Map<Widget, void Function()?> temp = {};
temp[const Icon(Icons.person)] = () { temp[const Icon(Icons.person)] = () {
setState(() { context.read<MzansiProfileProvider>().setPersonalIndex(0);
_selcetedIndex = 0;
});
}; };
// temp[const Icon(Icons.person)] = () {
// context.read<MzansiProfileProvider>().setPersonalIndex(1);
// };
temp[const Icon(Icons.settings)] = () { temp[const Icon(Icons.settings)] = () {
setState(() { context.read<MzansiProfileProvider>().setPersonalIndex(1);
_selcetedIndex = 1;
});
}; };
return MihPackageTools( return MihPackageTools(
tools: temp, tools: temp,
selcetedIndex: _selcetedIndex, selcetedIndex: context.watch<MzansiProfileProvider>().personalIndex,
); );
} }
List<Widget> getToolBody() { List<Widget> getToolBody() {
List<Widget> toolBodies = []; List<Widget> toolBodies = [];
toolBodies.add(MihPersonalProfile( toolBodies.add(MihPersonalProfile());
arguments: widget.arguments, // toolBodies.add(MihPersonalProfile());
)); toolBodies.add(MihPersonalSettings());
toolBodies.add(MihPersonalSettings(
signedInUser: widget.arguments.signedInUser,
));
return toolBodies; return toolBodies;
} }

View File

@@ -1,19 +1,18 @@
import 'package:mzansi_innovation_hub/main.dart'; import 'package:mzansi_innovation_hub/main.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_user_services.dart'; import 'package:mzansi_innovation_hub/mih_services/mih_user_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_single_child_scroll.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tool_body.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tool_body.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
class MihPersonalSettings extends StatefulWidget { class MihPersonalSettings extends StatefulWidget {
final AppUser signedInUser;
const MihPersonalSettings({ const MihPersonalSettings({
super.key, super.key,
required this.signedInUser,
}); });
@override @override
@@ -35,75 +34,83 @@ class _MihPersonalSettingsState extends State<MihPersonalSettings> {
context: context, context: context,
barrierDismissible: false, barrierDismissible: false,
builder: (context) { builder: (context) {
return MihPackageAlert( return Consumer<MzansiProfileProvider>(
alertIcon: Icon( builder: (BuildContext context,
Icons.warning_amber_rounded, MzansiProfileProvider mzansiProfileProvider, Widget? child) {
size: 100, return MihPackageAlert(
color: MihColors.getRedColor( alertIcon: Icon(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"), Icons.warning_amber_rounded,
), size: 100,
alertTitle: color: MihColors.getRedColor(
"Are you sure you want to permanently delete your MIH account?", MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
alertBody: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"This action will remove all of your data, and it cannot be recovered. We understand this is a big decision, so please take a moment to double-check.\n\nIf you're certain, please confirm below. If you've changed your mind, you can simply close this window.",
style: TextStyle(
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
fontSize: 15,
fontWeight: FontWeight.bold,
),
), ),
const SizedBox(height: 15), alertTitle:
Wrap( "Are you sure you want to permanently delete your MIH account?",
spacing: 10, alertBody: Column(
runSpacing: 10, mainAxisSize: MainAxisSize.min,
children: [ children: [
MihButton( Text(
onPressed: () { "This action will remove all of your data, and it cannot be recovered. We understand this is a big decision, so please take a moment to double-check.\n\nIf you're certain, please confirm below. If you've changed your mind, you can simply close this window.",
MihUserServices.deleteAccount( style: TextStyle(
widget.signedInUser.app_id, context); color: MihColors.getSecondaryColor(
}, MzansiInnovationHub.of(context)!.theme.mode ==
buttonColor: MihColors.getRedColor( "Dark"),
MzansiInnovationHub.of(context)!.theme.mode == "Dark"), fontSize: 15,
width: 300, fontWeight: FontWeight.bold,
child: Text(
"Delete",
style: TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
fontSize: 20,
fontWeight: FontWeight.bold,
),
), ),
), ),
MihButton( const SizedBox(height: 15),
onPressed: () { Wrap(
Navigator.pop(context); spacing: 10,
}, runSpacing: 10,
buttonColor: MihColors.getGreenColor( children: [
MzansiInnovationHub.of(context)!.theme.mode == "Dark"), MihButton(
width: 300, onPressed: () {
child: Text( MihUserServices.deleteAccount(
"Cancel", mzansiProfileProvider, context);
style: TextStyle( },
color: MihColors.getPrimaryColor( buttonColor: MihColors.getRedColor(
MzansiInnovationHub.of(context)!.theme.mode == MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"), "Dark"),
fontSize: 20, width: 300,
fontWeight: FontWeight.bold, child: Text(
"Delete",
style: TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
), ),
), MihButton(
), onPressed: () {
Navigator.pop(context);
},
buttonColor: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
width: 300,
child: Text(
"Cancel",
style: TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
),
],
)
], ],
) ),
], alertColour: MihColors.getRedColor(
), MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
alertColour: MihColors.getRedColor( );
MzansiInnovationHub.of(context)!.theme.mode == "Dark"), },
); );
}, },
); );

View File

@@ -1,10 +1,15 @@
import 'dart:convert'; import 'dart:convert';
import 'package:go_router/go_router.dart';
import 'package:http/http.dart'; import 'package:http/http.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.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_config/mih_env.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
import 'package:provider/provider.dart';
import 'package:supertokens_flutter/supertokens.dart';
import '../mih_components/mih_pop_up_messages/mih_error_message.dart'; import '../mih_components/mih_pop_up_messages/mih_error_message.dart';
import 'package:supertokens_flutter/http.dart' as http; import 'package:supertokens_flutter/http.dart' as http;
@@ -75,8 +80,9 @@ class MihBusinessDetailsServices {
} }
Future<Business?> getBusinessDetailsByUser( Future<Business?> getBusinessDetailsByUser(
String app_id, BuildContext context,
) async { ) async {
String app_id = await SuperTokens.getUserId();
var response = await http.get( var response = await http.get(
Uri.parse("${AppEnviroment.baseApiUrl}/business/app_id/$app_id"), Uri.parse("${AppEnviroment.baseApiUrl}/business/app_id/$app_id"),
headers: <String, String>{ headers: <String, String>{
@@ -86,7 +92,9 @@ class MihBusinessDetailsServices {
if (response.statusCode == 200) { if (response.statusCode == 200) {
String body = response.body; String body = response.body;
var jsonBody = jsonDecode(body); var jsonBody = jsonDecode(body);
return Business.fromJson(jsonBody); Business? business = Business.fromJson(jsonBody);
context.read<MzansiProfileProvider>().setBusiness(newBusiness: business);
return business;
} else { } else {
return null; return null;
} }
@@ -175,6 +183,7 @@ class MihBusinessDetailsServices {
String businessWebsite, String businessWebsite,
String businessRating, String businessRating,
String businessMissionVision, String businessMissionVision,
MzansiProfileProvider provider,
BuildContext context, BuildContext context,
) async { ) async {
showDialog( showDialog(
@@ -183,6 +192,7 @@ class MihBusinessDetailsServices {
return const Mihloadingcircle(); return const Mihloadingcircle();
}, },
); );
var filePath = "$business_id/business_files/$business_logo_name";
var response = await http.put( var response = await http.put(
Uri.parse("${AppEnviroment.baseApiUrl}/business/update/v2/"), Uri.parse("${AppEnviroment.baseApiUrl}/business/update/v2/"),
headers: <String, String>{ headers: <String, String>{
@@ -194,7 +204,7 @@ class MihBusinessDetailsServices {
"type": business_type, "type": business_type,
"registration_no": business_registration_no, "registration_no": business_registration_no,
"logo_name": business_logo_name, "logo_name": business_logo_name,
"logo_path": "$business_id/business_files/$business_logo_name", "logo_path": filePath,
"contact_no": business_phone_number, "contact_no": business_phone_number,
"bus_email": business_email, "bus_email": business_email,
"gps_location": business_location, "gps_location": business_location,
@@ -205,8 +215,29 @@ class MihBusinessDetailsServices {
"mission_vision": businessMissionVision, "mission_vision": businessMissionVision,
}), }),
); );
Navigator.of(context).pop(); context.pop();
if (response.statusCode == 200) { if (response.statusCode == 200) {
provider.setBusiness(
newBusiness: Business(
business_id,
business_name,
business_type,
business_registration_no,
business_logo_name,
filePath,
business_phone_number,
business_email,
provider.business!.app_id,
business_location,
business_practice_no,
business_vat_no,
businessWebsite,
businessRating,
businessMissionVision,
),
);
String newProPicUrl = await MihFileApi.getMinioFileUrl(filePath, context);
provider.setBusinessProfilePicUrl(newProPicUrl);
return 200; return 200;
} else { } else {
return 500; return 500;

View File

@@ -1,6 +1,7 @@
import 'dart:convert'; import 'dart:convert';
import 'package:file_picker/file_picker.dart'; import 'package:file_picker/file_picker.dart';
import 'package:go_router/go_router.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_success_message.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_success_message.dart';
@@ -75,7 +76,7 @@ class MihFileApi {
request.files.add(await http2.MultipartFile.fromBytes('file', file!.bytes!, request.files.add(await http2.MultipartFile.fromBytes('file', file!.bytes!,
filename: file.name.replaceAll(RegExp(r' '), '-'))); filename: file.name.replaceAll(RegExp(r' '), '-')));
var response = await request.send(); var response = await request.send();
Navigator.of(context).pop(); // Pop loading dialog context.pop(); // Pop loading dialog
return response.statusCode; return response.statusCode;
} }
@@ -99,7 +100,7 @@ class MihFileApi {
"env": env, "env": env,
}), }),
); );
Navigator.of(context).pop(); // Pop loading dialog context.pop(); // Pop loading dialog
return response.statusCode; return response.statusCode;
} }

View File

@@ -1,15 +1,22 @@
import 'dart:convert'; import 'dart:convert';
import 'package:go_router/go_router.dart';
import 'package:ken_logger/ken_logger.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_user.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_user.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.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_config/mih_env.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
import 'package:provider/provider.dart';
import 'package:supertokens_flutter/supertokens.dart';
import '../mih_components/mih_pop_up_messages/mih_error_message.dart'; import '../mih_components/mih_pop_up_messages/mih_error_message.dart';
import 'package:supertokens_flutter/http.dart' as http; import 'package:supertokens_flutter/http.dart' as http;
class MihMyBusinessUserServices { class MihMyBusinessUserServices {
Future<BusinessUser?> getBusinessUser( Future<BusinessUser?> getBusinessUser(
String app_id, BuildContext context,
) async { ) async {
String app_id = await SuperTokens.getUserId();
var response = await http.get( var response = await http.get(
Uri.parse("${AppEnviroment.baseApiUrl}/business-user/$app_id"), Uri.parse("${AppEnviroment.baseApiUrl}/business-user/$app_id"),
headers: <String, String>{ headers: <String, String>{
@@ -17,7 +24,13 @@ class MihMyBusinessUserServices {
}, },
); );
if (response.statusCode == 200) { if (response.statusCode == 200) {
return BusinessUser.fromJson(jsonDecode(response.body)); KenLogger.success(response.body);
BusinessUser? businessUser =
BusinessUser.fromJson(jsonDecode(response.body));
context
.read<MzansiProfileProvider>()
.setBusinessUser(newBusinessUser: businessUser);
return businessUser;
} else { } else {
return null; return null;
} }
@@ -51,7 +64,7 @@ class MihMyBusinessUserServices {
"access": access, "access": access,
}), }),
); );
Navigator.of(context).pop(); context.pop();
if (response.statusCode == 201) { if (response.statusCode == 201) {
return 201; return 201;
} else { } else {
@@ -67,6 +80,7 @@ class MihMyBusinessUserServices {
String bUserTitle, String bUserTitle,
String bUserAccess, String bUserAccess,
String signatureFileName, String signatureFileName,
MzansiProfileProvider provider,
BuildContext context, BuildContext context,
) async { ) async {
showDialog( showDialog(
@@ -75,6 +89,7 @@ class MihMyBusinessUserServices {
return const Mihloadingcircle(); return const Mihloadingcircle();
}, },
); );
var filePath = "$app_id/business_files/$signatureFileName";
var response = await http.put( var response = await http.put(
Uri.parse("${AppEnviroment.baseApiUrl}/business-user/update/"), Uri.parse("${AppEnviroment.baseApiUrl}/business-user/update/"),
headers: <String, String>{ headers: <String, String>{
@@ -84,32 +99,26 @@ class MihMyBusinessUserServices {
"business_id": business_id, "business_id": business_id,
"app_id": app_id, "app_id": app_id,
"signature": signatureFileName, "signature": signatureFileName,
"sig_path": "$app_id/business_files/$signatureFileName", "sig_path": filePath,
"title": bUserTitle, "title": bUserTitle,
"access": bUserAccess, "access": bUserAccess,
}), }),
); );
// var response = await http.put( context.pop();
// Uri.parse("${AppEnviroment.baseApiUrl}/business/update/"),
// headers: <String, String>{
// "Content-Type": "application/json; charset=UTF-8"
// },
// body: jsonEncode(<String, dynamic>{
// "business_id": business_id,
// "Name": business_name,
// "type": business_type,
// "registration_no": business_registration_no,
// "logo_name": business_logo_name,
// "logo_path": "$business_id/business_files/$business_logo_name",
// "contact_no": business_phone_number,
// "bus_email": business_email,
// "gps_location": business_location,
// "practice_no": business_practice_no,
// "vat_no": business_vat_no,
// }),
// );
Navigator.of(context).pop();
if (response.statusCode == 200) { if (response.statusCode == 200) {
provider.setBusinessUser(
newBusinessUser: BusinessUser(
provider.businessUser!.idbusiness_users,
business_id,
app_id,
signatureFileName,
filePath,
bUserTitle,
bUserAccess,
),
);
String newProPicUrl = await MihFileApi.getMinioFileUrl(filePath, context);
provider.setBusinessUserSignatureUrl(newProPicUrl);
return 200; return 200;
} else { } else {
internetConnectionPopUp(context); internetConnectionPopUp(context);

View File

@@ -61,7 +61,7 @@ class MIHApiCalls {
// Get Userdata // Get Userdata
var uid = await SuperTokens.getUserId(); var uid = await SuperTokens.getUserId();
AppUser? user = await MihUserServices().getUserDetails(uid, context); AppUser? user = await MihUserServices().getUserDetails(context);
if (user != null) { if (user != null) {
userData = user; userData = user;
} else { } else {
@@ -70,7 +70,7 @@ class MIHApiCalls {
// Get BusinessUserdata // Get BusinessUserdata
BusinessUser? businessUser = BusinessUser? businessUser =
await MihMyBusinessUserServices().getBusinessUser(uid); await MihMyBusinessUserServices().getBusinessUser(context);
if (businessUser != null) { if (businessUser != null) {
bUserData = businessUser; bUserData = businessUser;
} else { } else {
@@ -79,9 +79,7 @@ class MIHApiCalls {
// Get Businessdata // Get Businessdata
Business? business = Business? business =
await MihBusinessDetailsServices().getBusinessDetailsByUser( await MihBusinessDetailsServices().getBusinessDetailsByUser(context);
uid,
);
if (business != null) { if (business != null) {
busData = business; busData = business;
} else { } else {

View File

@@ -1,31 +1,39 @@
import 'dart:convert'; import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_objects/user_consent.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_objects/user_consent.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_config/mih_env.dart';
import 'package:provider/provider.dart';
import 'package:supertokens_flutter/http.dart' as http; import 'package:supertokens_flutter/http.dart' as http;
import 'package:supertokens_flutter/supertokens.dart'; import 'package:supertokens_flutter/supertokens.dart';
class MihUserConsentServices { class MihUserConsentServices {
Future<UserConsent?> getUserConsentStatus() async { Future<void> getUserConsentStatus(
BuildContext context,
) async {
var app_id = await SuperTokens.getUserId(); var app_id = await SuperTokens.getUserId();
final response = await http.get( final response = await http.get(
Uri.parse("${AppEnviroment.baseApiUrl}/user-consent/user/$app_id")); Uri.parse("${AppEnviroment.baseApiUrl}/user-consent/user/$app_id"));
if (response.statusCode == 200) { if (response.statusCode == 200) {
Map<String, dynamic> userMap = jsonDecode(response.body); Map<String, dynamic> userMap = jsonDecode(response.body);
UserConsent userConsent = UserConsent.fromJson(userMap); UserConsent userConsent = UserConsent.fromJson(userMap);
return userConsent; context.read<MzansiProfileProvider>().setUserConsent(userConsent);
} else { // return userConsent;
return null;
} }
// else {
// return null;
// }
} }
Future<int> insertUserConsentStatus( Future<int> insertUserConsentStatus(
String app_id,
String latestPrivacyPolicyDate, String latestPrivacyPolicyDate,
String latestTermOfServiceDate, String latestTermOfServiceDate,
MzansiProfileProvider provider,
BuildContext context,
) async { ) async {
UserConsent userConsent = UserConsent( UserConsent userConsent = UserConsent(
app_id: app_id, app_id: provider.user!.app_id,
privacy_policy_accepted: DateTime.parse(latestPrivacyPolicyDate), privacy_policy_accepted: DateTime.parse(latestPrivacyPolicyDate),
terms_of_services_accepted: DateTime.parse(latestTermOfServiceDate), terms_of_services_accepted: DateTime.parse(latestTermOfServiceDate),
); );
@@ -34,16 +42,18 @@ class MihUserConsentServices {
headers: {"Content-Type": "application/json"}, headers: {"Content-Type": "application/json"},
body: jsonEncode(userConsent.toJson()), body: jsonEncode(userConsent.toJson()),
); );
provider.setUserConsent(userConsent);
return response.statusCode; return response.statusCode;
} }
Future<int> updateUserConsentStatus( Future<int> updateUserConsentStatus(
String app_id,
String latestPrivacyPolicyDate, String latestPrivacyPolicyDate,
String latestTermOfServiceDate, String latestTermOfServiceDate,
MzansiProfileProvider provider,
BuildContext context,
) async { ) async {
UserConsent userConsent = UserConsent( UserConsent userConsent = UserConsent(
app_id: app_id, app_id: provider.user!.app_id,
privacy_policy_accepted: DateTime.parse(latestPrivacyPolicyDate), privacy_policy_accepted: DateTime.parse(latestPrivacyPolicyDate),
terms_of_services_accepted: DateTime.parse(latestTermOfServiceDate), terms_of_services_accepted: DateTime.parse(latestTermOfServiceDate),
); );
@@ -52,6 +62,7 @@ class MihUserConsentServices {
headers: {"Content-Type": "application/json"}, headers: {"Content-Type": "application/json"},
body: jsonEncode(userConsent.toJson()), body: jsonEncode(userConsent.toJson()),
); );
provider.setUserConsent(userConsent);
return response.statusCode; return response.statusCode;
} }
} }

View File

@@ -7,9 +7,12 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart'; import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.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/mzansi_profile_provider.dart';
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart'; import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
import 'package:provider/provider.dart';
import 'package:supertokens_flutter/http.dart' as http; import 'package:supertokens_flutter/http.dart' as http;
import 'package:supertokens_flutter/supertokens.dart'; import 'package:supertokens_flutter/supertokens.dart';
@@ -94,9 +97,9 @@ class MihUserServices {
} }
Future<AppUser?> getUserDetails( Future<AppUser?> getUserDetails(
String app_id,
BuildContext context, BuildContext context,
) async { ) async {
String app_id = await SuperTokens.getUserId();
var response = await http.get( var response = await http.get(
Uri.parse("${AppEnviroment.baseApiUrl}/user/$app_id"), Uri.parse("${AppEnviroment.baseApiUrl}/user/$app_id"),
headers: <String, String>{ headers: <String, String>{
@@ -107,6 +110,9 @@ class MihUserServices {
if (response.statusCode == 200) { if (response.statusCode == 200) {
String body = response.body; String body = response.body;
var jsonBody = jsonDecode(body); var jsonBody = jsonDecode(body);
context.read<MzansiProfileProvider>().setUser(
newUser: AppUser.fromJson(jsonBody),
);
return AppUser.fromJson(jsonBody); return AppUser.fromJson(jsonBody);
} else { } else {
return null; return null;
@@ -147,6 +153,21 @@ class MihUserServices {
}), }),
); );
if (response.statusCode == 200) { if (response.statusCode == 200) {
context.read<MzansiProfileProvider>().setUser(
newUser: AppUser(
signedInUser.idUser,
signedInUser.email,
firstName,
lastName,
profileType,
signedInUser.app_id,
username,
filePath,
purpose,
),
);
String newProPicUrl = await MihFileApi.getMinioFileUrl(filePath, context);
context.read<MzansiProfileProvider>().setUserProfilePicUrl(newProPicUrl);
return response.statusCode; return response.statusCode;
} else { } else {
return response.statusCode; return response.statusCode;
@@ -192,7 +213,7 @@ class MihUserServices {
} }
static Future<void> deleteAccount( static Future<void> deleteAccount(
String app_id, MzansiProfileProvider provider,
BuildContext context, BuildContext context,
) async { ) async {
loadingPopUp(context); loadingPopUp(context);
@@ -202,7 +223,7 @@ class MihUserServices {
"Content-Type": "application/json; charset=UTF-8" "Content-Type": "application/json; charset=UTF-8"
}, },
body: jsonEncode(<String, dynamic>{ body: jsonEncode(<String, dynamic>{
"app_id": app_id, "app_id": provider.user!.app_id,
"env": AppEnviroment.getEnv(), "env": AppEnviroment.getEnv(),
}), }),
); );
@@ -212,18 +233,12 @@ class MihUserServices {
print(error); print(error);
}); });
if (await SuperTokens.doesSessionExist() == false) { if (await SuperTokens.doesSessionExist() == false) {
// Navigator.of(context).pop(); // Pop loading dialog
// Navigator.of(context).pop(); // Pop delete account dialog
// Navigator.of(context).pop(); // Pop Mzansi Profile
// Navigator.of(context).popAndPushNamed(
// '/',
// arguments: AuthArguments(true, false),
// ); //Pop and push to login page
successPopUp( successPopUp(
"Account Deleted Successfully", "Account Deleted Successfully",
"Your account has been successfully deleted. We are sorry to see you go, but we respect your decision.", "Your account has been successfully deleted. We are sorry to see you go, but we respect your decision.",
context, context,
); // Show success message. ); // Show success message.
provider.dispose();
} }
} else { } else {
Navigator.of(context).pop(); // Pop loading dialog Navigator.of(context).pop(); // Pop loading dialog

View File

@@ -249,6 +249,7 @@ async def delete_users_data_by_app_id(itemRequest: userDeleteRequest, session:
"DELETE FROM patient_manager.patient_notes where app_id = %s", "DELETE FROM patient_manager.patient_notes where app_id = %s",
"DELETE FROM patient_manager.patient_files where app_id = %s", "DELETE FROM patient_manager.patient_files where app_id = %s",
"DELETE FROM patient_manager.claim_statement_file where app_id = %s", "DELETE FROM patient_manager.claim_statement_file where app_id = %s",
"DELETE FROM app_data.user_consent where app_id = %s",
"DELETE FROM app_data.users where app_id = %s", "DELETE FROM app_data.users where app_id = %s",
] ]
# Delete user from all tables # Delete user from all tables