QOL: Fix New User Setup flow
This commit is contained in:
@@ -82,14 +82,14 @@ class _MihHomeState extends State<MihHome> {
|
|||||||
String signatureUrl;
|
String signatureUrl;
|
||||||
Business? responseBusiness =
|
Business? responseBusiness =
|
||||||
await MihBusinessDetailsServices().getBusinessDetailsByUser(context);
|
await MihBusinessDetailsServices().getBusinessDetailsByUser(context);
|
||||||
if (responseBusiness == null && user!.type == "business") {
|
// if (responseBusiness == null && user!.type == "business") {
|
||||||
if (mounted) {
|
// if (mounted) {
|
||||||
context.goNamed(
|
// context.goNamed(
|
||||||
'businessProfileSetup',
|
// 'businessProfileSetup',
|
||||||
extra: user,
|
// extra: user,
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (responseBusiness != null && user!.type == "business") {
|
if (responseBusiness != null && user!.type == "business") {
|
||||||
// Get Business
|
// Get Business
|
||||||
@@ -548,7 +548,9 @@ class _MihHomeState extends State<MihHome> {
|
|||||||
);
|
);
|
||||||
if (user.type != "personal") {
|
if (user.type != "personal") {
|
||||||
toolBodies.add(
|
toolBodies.add(
|
||||||
MihBusinessHome(),
|
MihBusinessHome(
|
||||||
|
isLoading: _isLoadingInitialData,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return toolBodies;
|
return toolBodies;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
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_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_icons.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_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_search_bar.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_search_bar.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_pop_up_messages/mih_loading_circle.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_ai_provider.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_ai_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_profile_provider.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||||
@@ -21,8 +21,10 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class MihBusinessHome extends StatefulWidget {
|
class MihBusinessHome extends StatefulWidget {
|
||||||
|
final bool isLoading;
|
||||||
const MihBusinessHome({
|
const MihBusinessHome({
|
||||||
super.key,
|
super.key,
|
||||||
|
required this.isLoading,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -61,7 +63,6 @@ class _MihBusinessHomeState extends State<MihBusinessHome>
|
|||||||
List<Map<String, Widget>> temp = [];
|
List<Map<String, Widget>> temp = [];
|
||||||
temp.add({
|
temp.add({
|
||||||
"Setup Business": MzansiSetupBusinessProfileTile(
|
"Setup Business": MzansiSetupBusinessProfileTile(
|
||||||
signedInUser: context.read<MzansiProfileProvider>().user!,
|
|
||||||
packageSize: packageSize,
|
packageSize: packageSize,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
@@ -71,12 +72,22 @@ class _MihBusinessHomeState extends State<MihBusinessHome>
|
|||||||
List<Map<String, Widget>> setBusinessPackages() {
|
List<Map<String, Widget>> setBusinessPackages() {
|
||||||
MzansiProfileProvider mzansiProfileProvider =
|
MzansiProfileProvider mzansiProfileProvider =
|
||||||
context.read<MzansiProfileProvider>();
|
context.read<MzansiProfileProvider>();
|
||||||
if (mzansiProfileProvider.user == null ||
|
// if (mzansiProfileProvider.user == null ||
|
||||||
mzansiProfileProvider.business == null ||
|
// mzansiProfileProvider.business == null ||
|
||||||
mzansiProfileProvider.businessUser == null) {
|
// mzansiProfileProvider.businessUser == null) {
|
||||||
return []; // Return empty list if data isn't ready
|
// return []; // Return empty list if data isn't ready
|
||||||
}
|
// }
|
||||||
List<Map<String, Widget>> temp = [];
|
List<Map<String, Widget>> temp = [];
|
||||||
|
KenLogger.success("here");
|
||||||
|
if (mzansiProfileProvider.business == null && !widget.isLoading) {
|
||||||
|
KenLogger.success("here");
|
||||||
|
temp.add({
|
||||||
|
"Setup Business": MzansiSetupBusinessProfileTile(
|
||||||
|
packageSize: packageSize,
|
||||||
|
)
|
||||||
|
});
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
//=============== Biz Profile ===============
|
//=============== Biz Profile ===============
|
||||||
temp.add({
|
temp.add({
|
||||||
"Business Profile": MzansiBusinessProfileTile(
|
"Business Profile": MzansiBusinessProfileTile(
|
||||||
@@ -174,10 +185,8 @@ class _MihBusinessHomeState extends State<MihBusinessHome>
|
|||||||
super.initState();
|
super.initState();
|
||||||
searchController.addListener(searchPackage);
|
searchController.addListener(searchPackage);
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
businessPackagesMap = setBusinessPackages();
|
||||||
businessPackagesMap = setBusinessPackages();
|
searchPackage();
|
||||||
searchPackage();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -197,33 +206,39 @@ class _MihBusinessHomeState extends State<MihBusinessHome>
|
|||||||
MzansiProfileProvider mzansiProfileProvider,
|
MzansiProfileProvider mzansiProfileProvider,
|
||||||
MzansiAiProvider mzansiAiProvider,
|
MzansiAiProvider mzansiAiProvider,
|
||||||
Widget? child) {
|
Widget? child) {
|
||||||
if (mzansiProfileProvider.business == null) {
|
// if (mzansiProfileProvider.user == null ||
|
||||||
return Center(
|
// mzansiProfileProvider.business == null ||
|
||||||
child: Mihloadingcircle(),
|
// mzansiProfileProvider.businessUser == null) {
|
||||||
);
|
// return Center(
|
||||||
}
|
// child: Mihloadingcircle(),
|
||||||
|
// );
|
||||||
|
// }
|
||||||
return MihSingleChildScroll(
|
return MihSingleChildScroll(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.symmetric(horizontal: width / 20),
|
padding: EdgeInsets.symmetric(horizontal: width / 20),
|
||||||
child: MihSearchBar(
|
child: Visibility(
|
||||||
controller: searchController,
|
visible: mzansiProfileProvider.business != null,
|
||||||
hintText: "Ask Mzansi",
|
child: MihSearchBar(
|
||||||
prefixIcon: Icons.search,
|
controller: searchController,
|
||||||
prefixAltIcon: MihIcons.mzansiAi,
|
hintText: "Ask Mzansi",
|
||||||
fillColor: MihColors.getSecondaryColor(
|
prefixIcon: Icons.search,
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
prefixAltIcon: MihIcons.mzansiAi,
|
||||||
hintColor: MihColors.getPrimaryColor(
|
fillColor: MihColors.getSecondaryColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
onPrefixIconTap: () {
|
hintColor: MihColors.getPrimaryColor(
|
||||||
mzansiAiProvider.setStartUpQuestion(searchController.text);
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
context.goNamed(
|
onPrefixIconTap: () {
|
||||||
"mzansiAi",
|
mzansiAiProvider
|
||||||
);
|
.setStartUpQuestion(searchController.text);
|
||||||
searchController.clear();
|
context.goNamed(
|
||||||
},
|
"mzansiAi",
|
||||||
searchFocusNode: _searchFocusNode,
|
);
|
||||||
|
searchController.clear();
|
||||||
|
},
|
||||||
|
searchFocusNode: _searchFocusNode,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
|
|||||||
@@ -2,16 +2,15 @@ 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_tile.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tile.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.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: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';
|
||||||
|
|
||||||
class MzansiSetupBusinessProfileTile extends StatefulWidget {
|
class MzansiSetupBusinessProfileTile extends StatefulWidget {
|
||||||
final AppUser signedInUser;
|
|
||||||
final double packageSize;
|
final double packageSize;
|
||||||
const MzansiSetupBusinessProfileTile({
|
const MzansiSetupBusinessProfileTile({
|
||||||
super.key,
|
super.key,
|
||||||
required this.signedInUser,
|
|
||||||
required this.packageSize,
|
required this.packageSize,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -24,11 +23,13 @@ class _MzansiSetupBusinessProfileTileState
|
|||||||
extends State<MzansiSetupBusinessProfileTile> {
|
extends State<MzansiSetupBusinessProfileTile> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
MzansiProfileProvider profileProvider =
|
||||||
|
context.read<MzansiProfileProvider>();
|
||||||
return MihPackageTile(
|
return MihPackageTile(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'businessProfileSetup',
|
'businessProfileSetup',
|
||||||
extra: widget.signedInUser,
|
extra: profileProvider.user,
|
||||||
);
|
);
|
||||||
// Navigator.of(context).pushNamed(
|
// Navigator.of(context).pushNamed(
|
||||||
// '/business-profile/set-up',
|
// '/business-profile/set-up',
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ 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_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_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_form.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_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_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_text_form_field.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
||||||
@@ -96,13 +97,14 @@ class _MihEditPersonalProfileWindowState
|
|||||||
setProfileVariables(mzansiProfileProvider);
|
setProfileVariables(mzansiProfileProvider);
|
||||||
newSelectedProPic = null;
|
newSelectedProPic = null;
|
||||||
});
|
});
|
||||||
bool stayOnPersonalSide = true;
|
|
||||||
// if (originalProfileTypeIsBusiness == false && businessUser == true) {
|
// if (originalProfileTypeIsBusiness == false && businessUser == true) {
|
||||||
// stayOnPersonalSide = false;
|
// stayOnPersonalSide = false;
|
||||||
// }
|
// }
|
||||||
String message = "Your information has been updated successfully!";
|
String message = "Your information has been updated successfully!";
|
||||||
context.pop();
|
successPopUp(
|
||||||
successPopUp(message, stayOnPersonalSide);
|
mzansiProfileProvider,
|
||||||
|
message,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
internetConnectionPopUp();
|
internetConnectionPopUp();
|
||||||
}
|
}
|
||||||
@@ -158,7 +160,10 @@ class _MihEditPersonalProfileWindowState
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void successPopUp(String message, bool stayOnPersonalSide) {
|
void successPopUp(
|
||||||
|
MzansiProfileProvider profileProvider,
|
||||||
|
String message,
|
||||||
|
) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
@@ -185,7 +190,14 @@ class _MihEditPersonalProfileWindowState
|
|||||||
Center(
|
Center(
|
||||||
child: MihButton(
|
child: MihButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context.pop();
|
if (profileProvider.user!.type.toLowerCase() ==
|
||||||
|
"business" &&
|
||||||
|
profileProvider.business == null) {
|
||||||
|
setupBusinessPopUp(profileProvider);
|
||||||
|
} else {
|
||||||
|
context.pop();
|
||||||
|
context.pop();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
buttonColor: MihColors.getGreenColor(
|
buttonColor: MihColors.getGreenColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
@@ -216,6 +228,101 @@ class _MihEditPersonalProfileWindowState
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setupBusinessPopUp(
|
||||||
|
MzansiProfileProvider profileProvider,
|
||||||
|
) {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return MihPackageAlert(
|
||||||
|
alertIcon: Icon(
|
||||||
|
MihIcons.businessSetup,
|
||||||
|
size: 150,
|
||||||
|
color: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
),
|
||||||
|
alertTitle: "Setup Business Profile?",
|
||||||
|
alertBody: Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"It looks like this is the first time activating your business account. Would you like to set up your business now or would you like to do it later?",
|
||||||
|
style: TextStyle(
|
||||||
|
color: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 25),
|
||||||
|
Center(
|
||||||
|
child: Wrap(
|
||||||
|
alignment: WrapAlignment.center,
|
||||||
|
runAlignment: WrapAlignment.center,
|
||||||
|
spacing: 10,
|
||||||
|
runSpacing: 10,
|
||||||
|
children: [
|
||||||
|
MihButton(
|
||||||
|
onPressed: () {
|
||||||
|
context.pop();
|
||||||
|
context.goNamed(
|
||||||
|
'businessProfileSetup',
|
||||||
|
extra: profileProvider.user,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
buttonColor: MihColors.getGreenColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
elevation: 10,
|
||||||
|
width: 300,
|
||||||
|
child: Text(
|
||||||
|
"Setup Business",
|
||||||
|
style: TextStyle(
|
||||||
|
color: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
MihButton(
|
||||||
|
onPressed: () {
|
||||||
|
context.pop();
|
||||||
|
context.pop();
|
||||||
|
context.pop();
|
||||||
|
},
|
||||||
|
buttonColor: MihColors.getOrangeColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
elevation: 10,
|
||||||
|
width: 300,
|
||||||
|
child: Text(
|
||||||
|
"Setup Later",
|
||||||
|
style: TextStyle(
|
||||||
|
color: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
alertColour: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
);
|
||||||
|
// return MIHSuccessMessage(
|
||||||
|
// successType: "Success",
|
||||||
|
// successMessage: message,
|
||||||
|
// );
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void internetConnectionPopUp() {
|
void internetConnectionPopUp() {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -447,7 +554,9 @@ class _MihEditPersonalProfileWindowState
|
|||||||
"Dark"),
|
"Dark"),
|
||||||
width: 300,
|
width: 300,
|
||||||
child: Text(
|
child: Text(
|
||||||
"Update",
|
mzansiProfileProvider.user!.username.isEmpty
|
||||||
|
? "Setup Profile"
|
||||||
|
: "Update",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: MihColors.getPrimaryColor(
|
color: MihColors.getPrimaryColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
|||||||
Reference in New Issue
Block a user