Shortened the Registration Process by skipping and therefore making Visions and Corporate Culture values optional.

master
Rafael 2024-06-23 02:04:13 +02:00
parent c5a788c67f
commit ba37ca72f8
6 changed files with 83 additions and 76 deletions

View File

@ -123,6 +123,8 @@ class CultureValuesFormPageState extends State<CultureValuesFormPage> {
MaterialPageRoute( MaterialPageRoute(
// //
// set following registration page HERE // set following registration page HERE
// this Page (CorporateCultureForm) is optional as of 22.06.24
// and therefore not called anymore during RegProcess
// //
builder: (context) => RisksFormPage( builder: (context) => RisksFormPage(
isRegProcess: widget.isRegProcess, isRegProcess: widget.isRegProcess,

View File

@ -2,6 +2,7 @@ import 'package:collection/collection.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cloud_firestore/cloud_firestore.dart';
import '../components/my_elevated_button.dart'; import '../components/my_elevated_button.dart';
import '../components/text_bold.dart';
import '../constants.dart'; import '../constants.dart';
import '../enumerations.dart'; import '../enumerations.dart';
import '../pages/registration_complete_page.dart'; import '../pages/registration_complete_page.dart';
@ -20,7 +21,7 @@ class RisksFormPage extends StatefulWidget {
} }
class RisksFormPageState extends State<RisksFormPage> { class RisksFormPageState extends State<RisksFormPage> {
CommunicationPreference? communicationPreference; AvailabilityOption? availability;
RiskTolerance? riskPreference; RiskTolerance? riskPreference;
final AuthService _authService = AuthService(); final AuthService _authService = AuthService();
@ -41,11 +42,11 @@ class RisksFormPageState extends State<RisksFormPage> {
final data = snapshot.data(); final data = snapshot.data();
setState(() { setState(() {
if (data != null) { if (data != null) {
// Load Communication Preference // Load Availability option
if (data[Constants.dbFieldUsersCommunication] != null) { if (data[Constants.dbFieldUsersAvailability] != null) {
communicationPreference = CommunicationPreference.values availability = AvailabilityOption.values.firstWhereOrNull(
.firstWhereOrNull((x) => (x) => x.toString() == data[Constants.dbFieldUsersAvailability],
x.toString() == data[Constants.dbFieldUsersCommunication]); );
} }
// Load Risk Tolerance // Load Risk Tolerance
if (data[Constants.dbFieldUsersRiskTolerance] != null) { if (data[Constants.dbFieldUsersRiskTolerance] != null) {
@ -65,8 +66,7 @@ class RisksFormPageState extends State<RisksFormPage> {
await userDoc.set( await userDoc.set(
{ {
Constants.dbFieldUsersCommunication: Constants.dbFieldUsersAvailability: availability.toString(),
communicationPreference?.toString(),
Constants.dbFieldUsersRiskTolerance: riskPreference?.toString(), Constants.dbFieldUsersRiskTolerance: riskPreference?.toString(),
}, },
SetOptions(merge: true), // avoid overwriting existing data SetOptions(merge: true), // avoid overwriting existing data
@ -83,13 +83,12 @@ class RisksFormPageState extends State<RisksFormPage> {
} }
Future<void> handleSubmit() async { Future<void> handleSubmit() async {
if (communicationPreference == null) { if (availability == null) {
showErrorSnackBar(context, 'Please select a communication preference.'); _showSnackBar('Please select an availability option.');
return; return;
} }
if (riskPreference == null) { if (riskPreference == null) {
showErrorSnackBar( showErrorSnackBar(context, 'Please select a willingness to take risks.');
context, 'Please select the willingness to take risks.');
return; return;
} }
// Handle the form submission logic here // Handle the form submission logic here
@ -116,7 +115,7 @@ class RisksFormPageState extends State<RisksFormPage> {
if (widget.isEditMode == true) { if (widget.isEditMode == true) {
// pass selectedOptions data back to caller // pass selectedOptions data back to caller
Navigator.pop(context, { Navigator.pop(context, {
Constants.dbFieldUsersCommunication: communicationPreference, Constants.dbFieldUsersAvailability: availability,
Constants.dbFieldUsersRiskTolerance: riskPreference, Constants.dbFieldUsersRiskTolerance: riskPreference,
}); });
} else { } else {
@ -144,28 +143,24 @@ class RisksFormPageState extends State<RisksFormPage> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
const TextBold(text: 'Availability and commitment'),
const Text( const Text(
'Communication preference', 'How much time can you devote to the startup each week?',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
), ),
const Text('How do you prefer to communicate in a team?'), ...AvailabilityOption.values.map((option) {
...CommunicationPreference.values.map((option) {
return RadioListTile( return RadioListTile(
title: Text(option.displayName), title: Text(option.displayName),
value: option, value: option,
groupValue: communicationPreference, groupValue: availability,
onChanged: (CommunicationPreference? value) { onChanged: (AvailabilityOption? value) {
setState(() { setState(() {
communicationPreference = value; availability = value;
}); });
}, },
); );
}), }),
const SizedBox(height: 40), const SizedBox(height: 40),
const Text( const TextBold(text: 'Risk tolerance'),
'Risk tolerance',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
const Text('How do you deal with uncertainty and risk?'), const Text('How do you deal with uncertainty and risk?'),
...RiskTolerance.values.map((option) { ...RiskTolerance.values.map((option) {
return RadioListTile( return RadioListTile(

View File

@ -3,8 +3,8 @@ import '../../enumerations.dart';
import '../../services/auth/auth_service.dart'; import '../../services/auth/auth_service.dart';
import '../../services/user_service.dart'; import '../../services/user_service.dart';
import '../constants.dart'; import '../constants.dart';
import '../pages/user_vision_page.dart';
import 'profile_category_form.dart'; import 'profile_category_form.dart';
import 'risks_form.dart';
class SectorsForm extends StatelessWidget { class SectorsForm extends StatelessWidget {
SectorsForm({ SectorsForm({
@ -54,7 +54,7 @@ class SectorsForm extends StatelessWidget {
context, context,
MaterialPageRoute( MaterialPageRoute(
// set following registration page HERE // set following registration page HERE
builder: (context) => UserVisionPage( builder: (context) => RisksFormPage(
isRegProcess: isRegProcess, isRegProcess: isRegProcess,
isEditMode: false, isEditMode: false,
), ),

View File

@ -201,7 +201,7 @@ class _UserProfilePageState extends State<UserProfilePage> {
} }
} }
void editUserCommunicationInfo() async { void editUserRiskInfo() async {
final updatedUserData = await Navigator.push( final updatedUserData = await Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
@ -255,12 +255,12 @@ class _UserProfilePageState extends State<UserProfilePage> {
if (isOwner) if (isOwner)
Divider(color: Theme.of(context).colorScheme.primary), Divider(color: Theme.of(context).colorScheme.primary),
if (isOwner) const SizedBox(height: 16), if (isOwner) const SizedBox(height: 16),
_buildVision(context), _buildRisks(context),
const SizedBox(height: 16), const SizedBox(height: 16),
if (isOwner) if (isOwner)
Divider(color: Theme.of(context).colorScheme.primary), Divider(color: Theme.of(context).colorScheme.primary),
if (isOwner) const SizedBox(height: 16), if (isOwner) const SizedBox(height: 16),
_buildRisks(context), _buildVision(context),
const SizedBox(height: 16), const SizedBox(height: 16),
if (isOwner) if (isOwner)
Divider(color: Theme.of(context).colorScheme.primary), Divider(color: Theme.of(context).colorScheme.primary),
@ -295,7 +295,7 @@ class _UserProfilePageState extends State<UserProfilePage> {
CircleAvatar( CircleAvatar(
radius: 80, radius: 80,
backgroundImage: backgroundImage:
((profileImageUrl != null && profileImageUrl!.isNotEmpty)) (profileImageUrl != null && profileImageUrl!.isNotEmpty)
? NetworkImage(profileImageUrl!) ? NetworkImage(profileImageUrl!)
: null, : null,
child: (profileImageUrl == null || profileImageUrl!.isEmpty) child: (profileImageUrl == null || profileImageUrl!.isEmpty)
@ -535,7 +535,7 @@ class _UserProfilePageState extends State<UserProfilePage> {
); );
} }
Widget _buildVision(BuildContext context) { Widget _buildRisks(BuildContext context) {
return Column( return Column(
children: [ children: [
Align( Align(
@ -561,7 +561,7 @@ class _UserProfilePageState extends State<UserProfilePage> {
], ],
), ),
), ),
if (isOwner) _editButton(context, editUserVisionInfo), if (isOwner) _editButton(context, editUserRiskInfo),
], ],
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
@ -573,15 +573,12 @@ class _UserProfilePageState extends State<UserProfilePage> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
'Vision and Goals', 'Risk profile',
style: TextStyle( style: TextStyle(
color: Theme.of(context).colorScheme.primary, color: Theme.of(context).colorScheme.primary,
), ),
), ),
Text( Text(myData.risk.displayName,
myData.visions
.map((x) => x.displayName)
.join(',\n'),
style: const TextStyle(fontSize: 16)), style: const TextStyle(fontSize: 16)),
], ],
), ),
@ -595,7 +592,7 @@ class _UserProfilePageState extends State<UserProfilePage> {
); );
} }
Widget _buildRisks(BuildContext context) { Widget _buildVision(BuildContext context) {
return Column( return Column(
children: [ children: [
Align( Align(
@ -624,7 +621,7 @@ class _UserProfilePageState extends State<UserProfilePage> {
if (isOwner) if (isOwner)
Padding( Padding(
padding: const EdgeInsets.only(left: 8.0), padding: const EdgeInsets.only(left: 8.0),
child: _editButton(context, editUserCommunicationInfo), child: _editButton(context, editUserVisionInfo),
), ),
], ],
), ),
@ -637,12 +634,15 @@ class _UserProfilePageState extends State<UserProfilePage> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
'Risk profile', 'Vision and Goals',
style: TextStyle( style: TextStyle(
color: Theme.of(context).colorScheme.primary, color: Theme.of(context).colorScheme.primary,
), ),
), ),
Text(myData.risk.displayName, Text(
myData.visions
.map((x) => x.displayName)
.join(',\n'),
style: const TextStyle(fontSize: 16)), style: const TextStyle(fontSize: 16)),
], ],
), ),

View File

@ -5,7 +5,7 @@ import '../components/my_elevated_button.dart';
import '../components/text_bold.dart'; import '../components/text_bold.dart';
import '../constants.dart'; import '../constants.dart';
import '../enumerations.dart'; import '../enumerations.dart';
import '../forms/corporate_culture_form.dart'; import '../forms/risks_form.dart';
import '../services/auth/auth_service.dart'; import '../services/auth/auth_service.dart';
import '../utils/helper_dialogs.dart'; import '../utils/helper_dialogs.dart';
@ -27,7 +27,7 @@ class UserVisionPageState extends State<UserVisionPage> {
VisionOption.innovativeProduct: false, VisionOption.innovativeProduct: false,
VisionOption.exitStrategy: false, VisionOption.exitStrategy: false,
}; };
AvailabilityOption? availability; CommunicationPreference? communicationPreference;
final AuthService _authService = AuthService(); final AuthService _authService = AuthService();
@ -45,24 +45,24 @@ class UserVisionPageState extends State<UserVisionPage> {
if (snapshot.exists) { if (snapshot.exists) {
final data = snapshot.data(); final data = snapshot.data();
setState( setState(() {
() { if (data != null) {
// Load Communication Preference
if (data[Constants.dbFieldUsersCommunication] != null) {
communicationPreference = CommunicationPreference.values
.firstWhereOrNull((x) =>
x.toString() == data[Constants.dbFieldUsersCommunication]);
}
// Load Vision options // Load Vision options
if (data?[Constants.dbFieldUsersVisions] != null) { if (data[Constants.dbFieldUsersVisions] != null) {
for (var option in VisionOption.values) { for (var option in VisionOption.values) {
selectedVisionOptions[option] = selectedVisionOptions[option] =
data?[Constants.dbFieldUsersVisions] data[Constants.dbFieldUsersVisions]
.contains(option.toString()); .contains(option.toString());
} }
} }
// Load Availability option }
if (data?[Constants.dbFieldUsersAvailability] != null) { });
availability = AvailabilityOption.values.firstWhereOrNull(
(e) => e.toString() == data?[Constants.dbFieldUsersAvailability],
);
}
},
);
} }
} }
@ -74,11 +74,12 @@ class UserVisionPageState extends State<UserVisionPage> {
await userDoc.set( await userDoc.set(
{ {
Constants.dbFieldUsersCommunication:
communicationPreference?.toString(),
Constants.dbFieldUsersVisions: selectedVisionOptions.entries Constants.dbFieldUsersVisions: selectedVisionOptions.entries
.where((entry) => entry.value) .where((entry) => entry.value)
.map((entry) => entry.key.toString()) .map((entry) => entry.key.toString())
.toList(), .toList(),
Constants.dbFieldUsersAvailability: availability?.toString(),
}, },
SetOptions(merge: true), // avoid overwriting existing data SetOptions(merge: true), // avoid overwriting existing data
); );
@ -98,14 +99,15 @@ class UserVisionPageState extends State<UserVisionPage> {
} }
Future<void> handleSubmit() async { Future<void> handleSubmit() async {
if (communicationPreference == null) {
showErrorSnackBar(context, 'Please select a communication preference.');
return;
}
if (!isVisionSelected()) { if (!isVisionSelected()) {
_showSnackBar('Please select at least one long-term vision.'); _showSnackBar('Please select at least one long-term vision.');
return; return;
} }
if (availability == null) {
_showSnackBar('Please select an availability option.');
return;
}
// Handle the form submission logic here // Handle the form submission logic here
bool success = await _saveDataToFirebase(); bool success = await _saveDataToFirebase();
if (success) { if (success) {
@ -122,8 +124,11 @@ class UserVisionPageState extends State<UserVisionPage> {
MaterialPageRoute( MaterialPageRoute(
// //
// set following registration page HERE // set following registration page HERE
// this Page (UserVisionPage) is optional as of 22.06.24
// and therefore not called anymore during RegProcess
// //
builder: (context) => CultureValuesFormPage( //
builder: (context) => RisksFormPage(
isRegProcess: widget.isRegProcess, isRegProcess: widget.isRegProcess,
isEditMode: false, isEditMode: false,
), ),
@ -133,11 +138,11 @@ class UserVisionPageState extends State<UserVisionPage> {
if (widget.isEditMode == true) { if (widget.isEditMode == true) {
// pass selectedOptions data back to caller // pass selectedOptions data back to caller
Navigator.pop(context, { Navigator.pop(context, {
Constants.dbFieldUsersCommunication: communicationPreference,
Constants.dbFieldUsersVisions: selectedVisionOptions.entries Constants.dbFieldUsersVisions: selectedVisionOptions.entries
.where((entry) => entry.value) .where((entry) => entry.value)
.map((entry) => entry.key) .map((entry) => entry.key)
.toList(), .toList(),
Constants.dbFieldUsersAvailability: availability,
}); });
} else { } else {
Navigator.pop(context); Navigator.pop(context);
@ -164,18 +169,16 @@ class UserVisionPageState extends State<UserVisionPage> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
const TextBold(text: 'Availability and commitment'), const TextBold(text: 'Communication preference'),
const Text( const Text('How do you prefer to communicate in a team?'),
'How much time can you devote to the startup each week?', ...CommunicationPreference.values.map((option) {
),
...AvailabilityOption.values.map((option) {
return RadioListTile( return RadioListTile(
title: Text(option.displayName), title: Text(option.displayName),
value: option, value: option,
groupValue: availability, groupValue: communicationPreference,
onChanged: (AvailabilityOption? value) { onChanged: (CommunicationPreference? value) {
setState(() { setState(() {
availability = value; communicationPreference = value;
}); });
}, },
); );

View File

@ -59,15 +59,22 @@ class UserService {
} }
static List<SkillOption> convertSkillStringToEnum(List<dynamic>? skills) { static List<SkillOption> convertSkillStringToEnum(List<dynamic>? skills) {
List<SkillOption> userSkills = [];
if (skills != null && skills.isNotEmpty) { if (skills != null && skills.isNotEmpty) {
// Convert skills from strings to enum values // Convert skills from strings to enum values
List<SkillOption> userSkills = skills for (var skill in skills) {
.map((skill) => SkillOption.values try {
.firstWhere((x) => x.toString() == 'SkillOption.$skill')) SkillOption skillOption = SkillOption.values.firstWhere(
.toList(); (x) => x.toString() == 'SkillOption.$skill',
return userSkills; );
userSkills.add(skillOption);
} catch (e) {
// Ignore invalid values
continue;
}
}
} }
return []; return userSkills;
} }
static List<SectorOption> convertSectorStringToEnum(List<dynamic>? sectors) { static List<SectorOption> convertSectorStringToEnum(List<dynamic>? sectors) {