QOL: Fix New User Setup flow
This commit is contained in:
@@ -82,14 +82,14 @@ class _MihHomeState extends State<MihHome> {
|
||||
String signatureUrl;
|
||||
Business? responseBusiness =
|
||||
await MihBusinessDetailsServices().getBusinessDetailsByUser(context);
|
||||
if (responseBusiness == null && user!.type == "business") {
|
||||
if (mounted) {
|
||||
context.goNamed(
|
||||
'businessProfileSetup',
|
||||
extra: user,
|
||||
);
|
||||
}
|
||||
}
|
||||
// if (responseBusiness == null && user!.type == "business") {
|
||||
// if (mounted) {
|
||||
// context.goNamed(
|
||||
// 'businessProfileSetup',
|
||||
// extra: user,
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
if (responseBusiness != null && user!.type == "business") {
|
||||
// Get Business
|
||||
@@ -548,7 +548,9 @@ class _MihHomeState extends State<MihHome> {
|
||||
);
|
||||
if (user.type != "personal") {
|
||||
toolBodies.add(
|
||||
MihBusinessHome(),
|
||||
MihBusinessHome(
|
||||
isLoading: _isLoadingInitialData,
|
||||
),
|
||||
);
|
||||
}
|
||||
return toolBodies;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
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_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_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_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_profile_provider.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';
|
||||
|
||||
class MihBusinessHome extends StatefulWidget {
|
||||
final bool isLoading;
|
||||
const MihBusinessHome({
|
||||
super.key,
|
||||
required this.isLoading,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -61,7 +63,6 @@ class _MihBusinessHomeState extends State<MihBusinessHome>
|
||||
List<Map<String, Widget>> temp = [];
|
||||
temp.add({
|
||||
"Setup Business": MzansiSetupBusinessProfileTile(
|
||||
signedInUser: context.read<MzansiProfileProvider>().user!,
|
||||
packageSize: packageSize,
|
||||
)
|
||||
});
|
||||
@@ -71,12 +72,22 @@ class _MihBusinessHomeState extends State<MihBusinessHome>
|
||||
List<Map<String, Widget>> setBusinessPackages() {
|
||||
MzansiProfileProvider mzansiProfileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
if (mzansiProfileProvider.user == null ||
|
||||
mzansiProfileProvider.business == null ||
|
||||
mzansiProfileProvider.businessUser == null) {
|
||||
return []; // Return empty list if data isn't ready
|
||||
}
|
||||
// if (mzansiProfileProvider.user == null ||
|
||||
// mzansiProfileProvider.business == null ||
|
||||
// mzansiProfileProvider.businessUser == null) {
|
||||
// return []; // Return empty list if data isn't ready
|
||||
// }
|
||||
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 ===============
|
||||
temp.add({
|
||||
"Business Profile": MzansiBusinessProfileTile(
|
||||
@@ -174,10 +185,8 @@ class _MihBusinessHomeState extends State<MihBusinessHome>
|
||||
super.initState();
|
||||
searchController.addListener(searchPackage);
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
businessPackagesMap = setBusinessPackages();
|
||||
searchPackage();
|
||||
});
|
||||
businessPackagesMap = setBusinessPackages();
|
||||
searchPackage();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -197,33 +206,39 @@ class _MihBusinessHomeState extends State<MihBusinessHome>
|
||||
MzansiProfileProvider mzansiProfileProvider,
|
||||
MzansiAiProvider mzansiAiProvider,
|
||||
Widget? child) {
|
||||
if (mzansiProfileProvider.business == null) {
|
||||
return Center(
|
||||
child: Mihloadingcircle(),
|
||||
);
|
||||
}
|
||||
// if (mzansiProfileProvider.user == null ||
|
||||
// mzansiProfileProvider.business == null ||
|
||||
// mzansiProfileProvider.businessUser == null) {
|
||||
// return Center(
|
||||
// child: Mihloadingcircle(),
|
||||
// );
|
||||
// }
|
||||
return MihSingleChildScroll(
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: width / 20),
|
||||
child: MihSearchBar(
|
||||
controller: searchController,
|
||||
hintText: "Ask Mzansi",
|
||||
prefixIcon: Icons.search,
|
||||
prefixAltIcon: MihIcons.mzansiAi,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
hintColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onPrefixIconTap: () {
|
||||
mzansiAiProvider.setStartUpQuestion(searchController.text);
|
||||
context.goNamed(
|
||||
"mzansiAi",
|
||||
);
|
||||
searchController.clear();
|
||||
},
|
||||
searchFocusNode: _searchFocusNode,
|
||||
child: Visibility(
|
||||
visible: mzansiProfileProvider.business != null,
|
||||
child: MihSearchBar(
|
||||
controller: searchController,
|
||||
hintText: "Ask Mzansi",
|
||||
prefixIcon: Icons.search,
|
||||
prefixAltIcon: MihIcons.mzansiAi,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
hintColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onPrefixIconTap: () {
|
||||
mzansiAiProvider
|
||||
.setStartUpQuestion(searchController.text);
|
||||
context.goNamed(
|
||||
"mzansiAi",
|
||||
);
|
||||
searchController.clear();
|
||||
},
|
||||
searchFocusNode: _searchFocusNode,
|
||||
),
|
||||
),
|
||||
),
|
||||
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/mih_components/mih_package_components/mih_package_tile.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MzansiSetupBusinessProfileTile extends StatefulWidget {
|
||||
final AppUser signedInUser;
|
||||
final double packageSize;
|
||||
const MzansiSetupBusinessProfileTile({
|
||||
super.key,
|
||||
required this.signedInUser,
|
||||
required this.packageSize,
|
||||
});
|
||||
|
||||
@@ -24,11 +23,13 @@ class _MzansiSetupBusinessProfileTileState
|
||||
extends State<MzansiSetupBusinessProfileTile> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
MzansiProfileProvider profileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
return MihPackageTile(
|
||||
onTap: () {
|
||||
context.goNamed(
|
||||
'businessProfileSetup',
|
||||
extra: widget.signedInUser,
|
||||
extra: profileProvider.user,
|
||||
);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// '/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_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_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_window.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
||||
@@ -96,13 +97,14 @@ class _MihEditPersonalProfileWindowState
|
||||
setProfileVariables(mzansiProfileProvider);
|
||||
newSelectedProPic = null;
|
||||
});
|
||||
bool stayOnPersonalSide = true;
|
||||
// if (originalProfileTypeIsBusiness == false && businessUser == true) {
|
||||
// stayOnPersonalSide = false;
|
||||
// }
|
||||
String message = "Your information has been updated successfully!";
|
||||
context.pop();
|
||||
successPopUp(message, stayOnPersonalSide);
|
||||
successPopUp(
|
||||
mzansiProfileProvider,
|
||||
message,
|
||||
);
|
||||
} else {
|
||||
internetConnectionPopUp();
|
||||
}
|
||||
@@ -158,7 +160,10 @@ class _MihEditPersonalProfileWindowState
|
||||
}
|
||||
}
|
||||
|
||||
void successPopUp(String message, bool stayOnPersonalSide) {
|
||||
void successPopUp(
|
||||
MzansiProfileProvider profileProvider,
|
||||
String message,
|
||||
) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
@@ -185,7 +190,14 @@ class _MihEditPersonalProfileWindowState
|
||||
Center(
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
if (profileProvider.user!.type.toLowerCase() ==
|
||||
"business" &&
|
||||
profileProvider.business == null) {
|
||||
setupBusinessPopUp(profileProvider);
|
||||
} else {
|
||||
context.pop();
|
||||
context.pop();
|
||||
}
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
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() {
|
||||
showDialog(
|
||||
context: context,
|
||||
@@ -447,7 +554,9 @@ class _MihEditPersonalProfileWindowState
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Update",
|
||||
mzansiProfileProvider.user!.username.isEmpty
|
||||
? "Setup Profile"
|
||||
: "Update",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
|
||||
Reference in New Issue
Block a user