Registration: corporate culture
parent
017cf363d4
commit
2a2a82d71d
|
@ -20,6 +20,8 @@ class Constants {
|
||||||
static const String dbFieldUsersSkillsSought = 'skills_sought';
|
static const String dbFieldUsersSkillsSought = 'skills_sought';
|
||||||
static const String dbFieldUsersAvailability = 'availability';
|
static const String dbFieldUsersAvailability = 'availability';
|
||||||
static const String dbFieldUsersVisions = 'visions';
|
static const String dbFieldUsersVisions = 'visions';
|
||||||
|
static const String dbFieldUsersWorkValues = 'work_values';
|
||||||
|
static const String dbFieldUsersCorpCulture = 'corp_culture';
|
||||||
|
|
||||||
static const String pathLanguagesJson = 'lib/assets/languages.json';
|
static const String pathLanguagesJson = 'lib/assets/languages.json';
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,3 +76,43 @@ enum AvailabilityOption {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum WorkValueOption {
|
||||||
|
transparency,
|
||||||
|
innovation,
|
||||||
|
teamwork,
|
||||||
|
workLifeBalance;
|
||||||
|
|
||||||
|
String get displayName {
|
||||||
|
switch (this) {
|
||||||
|
case WorkValueOption.transparency:
|
||||||
|
return 'Transparency and openness';
|
||||||
|
case WorkValueOption.innovation:
|
||||||
|
return 'Innovation and creativity';
|
||||||
|
case WorkValueOption.teamwork:
|
||||||
|
return 'Teamwork and collaboration';
|
||||||
|
case WorkValueOption.workLifeBalance:
|
||||||
|
return 'Work-life balance';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum CultureOption {
|
||||||
|
performanceOriented,
|
||||||
|
supportive,
|
||||||
|
flexible,
|
||||||
|
traditional;
|
||||||
|
|
||||||
|
String get displayName {
|
||||||
|
switch (this) {
|
||||||
|
case CultureOption.performanceOriented:
|
||||||
|
return 'Performance-oriented and competitive';
|
||||||
|
case CultureOption.supportive:
|
||||||
|
return 'Supportive and collegial';
|
||||||
|
case CultureOption.flexible:
|
||||||
|
return 'Flexible and adaptable';
|
||||||
|
case CultureOption.traditional:
|
||||||
|
return 'Traditional and structured';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,191 @@
|
||||||
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../constants.dart';
|
||||||
|
import '../enumerations.dart';
|
||||||
|
import '../pages/registration_complete_page.dart';
|
||||||
|
import '../services/auth/auth_service.dart';
|
||||||
|
|
||||||
|
class CultureValuesFormPage extends StatefulWidget {
|
||||||
|
const CultureValuesFormPage({super.key, required this.isRegProcess});
|
||||||
|
|
||||||
|
final bool isRegProcess;
|
||||||
|
|
||||||
|
@override
|
||||||
|
CultureValuesFormPageState createState() => CultureValuesFormPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class CultureValuesFormPageState extends State<CultureValuesFormPage> {
|
||||||
|
Map<WorkValueOption, bool> selectedValueOptions = {
|
||||||
|
WorkValueOption.transparency: false,
|
||||||
|
WorkValueOption.innovation: false,
|
||||||
|
WorkValueOption.teamwork: false,
|
||||||
|
WorkValueOption.workLifeBalance: false,
|
||||||
|
};
|
||||||
|
CultureOption? selectedCultureOption;
|
||||||
|
|
||||||
|
final AuthService _authService = AuthService();
|
||||||
|
|
||||||
|
final int minWorkValueOption = 1;
|
||||||
|
final int maxWorkValueOption = 2;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_loadDataFromFirebase();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadDataFromFirebase() async {
|
||||||
|
final userDoc = FirebaseFirestore.instance
|
||||||
|
.collection(Constants.dbCollectionUsers)
|
||||||
|
.doc(_authService.getCurrentUser()!.uid);
|
||||||
|
final snapshot = await userDoc.get();
|
||||||
|
|
||||||
|
if (snapshot.exists) {
|
||||||
|
final data = snapshot.data();
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
// Load WorkValue options
|
||||||
|
if (data != null) {
|
||||||
|
if (data[Constants.dbFieldUsersWorkValues] != null) {
|
||||||
|
for (var option in WorkValueOption.values) {
|
||||||
|
selectedValueOptions[option] =
|
||||||
|
data[Constants.dbFieldUsersWorkValues]
|
||||||
|
.contains(option.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Load Culture option
|
||||||
|
if (data[Constants.dbFieldUsersCorpCulture] != null) {
|
||||||
|
selectedCultureOption = CultureOption.values.firstWhere(
|
||||||
|
(e) => e.toString() == data[Constants.dbFieldUsersCorpCulture],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _saveDataToFirebase() async {
|
||||||
|
final userDoc = FirebaseFirestore.instance
|
||||||
|
.collection(Constants.dbCollectionUsers)
|
||||||
|
.doc(_authService.getCurrentUser()!.uid);
|
||||||
|
|
||||||
|
await userDoc.set(
|
||||||
|
{
|
||||||
|
Constants.dbFieldUsersWorkValues: selectedValueOptions.entries
|
||||||
|
.where((entry) => entry.value)
|
||||||
|
.map((entry) => entry.key.toString())
|
||||||
|
.toList(),
|
||||||
|
Constants.dbFieldUsersCorpCulture: selectedCultureOption?.toString(),
|
||||||
|
},
|
||||||
|
SetOptions(merge: true),
|
||||||
|
); // avoid overwriting existing data
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isWorkValueSelected() {
|
||||||
|
int selectedCount =
|
||||||
|
selectedValueOptions.values.where((value) => value).length;
|
||||||
|
return selectedCount >= minWorkValueOption &&
|
||||||
|
selectedCount <= maxWorkValueOption;
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleSubmit() {
|
||||||
|
if (!isWorkValueSelected()) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
|
content: Text(
|
||||||
|
'Please select at least ${minWorkValueOption.toString()} and at most ${maxWorkValueOption.toString()} work life values.'),
|
||||||
|
));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (selectedCultureOption == null) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
||||||
|
content: Text('Please select a corporate culture.'),
|
||||||
|
));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_saveDataToFirebase();
|
||||||
|
// Handle the form submission logic here
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
//
|
||||||
|
// TODO set following registration page HERE
|
||||||
|
//
|
||||||
|
builder: (context) => const RegistrationCompletePage(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Personal preferences'),
|
||||||
|
),
|
||||||
|
body: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
'Work life and corporate culture',
|
||||||
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
const Text(
|
||||||
|
'What values are most important to you in your working environment?',
|
||||||
|
),
|
||||||
|
...WorkValueOption.values.map((option) {
|
||||||
|
return CheckboxListTile(
|
||||||
|
title: Text(option.displayName),
|
||||||
|
value: selectedValueOptions[option],
|
||||||
|
onChanged: (bool? value) {
|
||||||
|
setState(() {
|
||||||
|
int selectedCount = selectedValueOptions.values
|
||||||
|
.where((value) => value)
|
||||||
|
.length;
|
||||||
|
if (value == false ||
|
||||||
|
selectedCount < maxWorkValueOption) {
|
||||||
|
selectedValueOptions[option] = value!;
|
||||||
|
} else if (value == true &&
|
||||||
|
selectedCount >= maxWorkValueOption) {
|
||||||
|
ScaffoldMessenger.of(context)
|
||||||
|
.showSnackBar(const SnackBar(
|
||||||
|
content: Text(
|
||||||
|
'You can only select a maximum of two values.',
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
const SizedBox(height: 40),
|
||||||
|
const Align(
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
child: Text('Which corporate culture suits you best?')),
|
||||||
|
DropdownButton<CultureOption>(
|
||||||
|
hint: const Text('Choose a corporate culture'),
|
||||||
|
value: selectedCultureOption,
|
||||||
|
onChanged: (CultureOption? newValue) {
|
||||||
|
setState(() {
|
||||||
|
selectedCultureOption = newValue;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
items: CultureOption.values.map((CultureOption option) {
|
||||||
|
return DropdownMenuItem<CultureOption>(
|
||||||
|
value: option,
|
||||||
|
child: Text(option.displayName),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: handleSubmit,
|
||||||
|
child: Text(widget.isRegProcess ? 'Save and continue' : 'Save'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ import "package:cloud_firestore/cloud_firestore.dart";
|
||||||
import "package:flutter/material.dart";
|
import "package:flutter/material.dart";
|
||||||
import "../constants.dart";
|
import "../constants.dart";
|
||||||
import "../enumerations.dart";
|
import "../enumerations.dart";
|
||||||
import "registration_complete_page.dart";
|
import "../forms/corporate_culture_form.dart";
|
||||||
import "../services/auth/auth_service.dart";
|
import "../services/auth/auth_service.dart";
|
||||||
|
|
||||||
class MatchingForm extends StatefulWidget {
|
class MatchingForm extends StatefulWidget {
|
||||||
|
@ -82,7 +82,7 @@ class MatchingFormState extends State<MatchingForm> {
|
||||||
void handleSubmit() {
|
void handleSubmit() {
|
||||||
if (!isVisionSelected()) {
|
if (!isVisionSelected()) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
||||||
content: Text('Please choose at least one long-term vision.'),
|
content: Text('Please select at least one long-term vision.'),
|
||||||
));
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -97,8 +97,12 @@ class MatchingFormState extends State<MatchingForm> {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
// TODO set following registration page HERE
|
//
|
||||||
builder: (context) => const RegistrationCompletePage(),
|
// set following registration page HERE
|
||||||
|
//
|
||||||
|
builder: (context) => CultureValuesFormPage(
|
||||||
|
isRegProcess: widget.isRegProcess,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -111,59 +115,59 @@ class MatchingFormState extends State<MatchingForm> {
|
||||||
),
|
),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Column(
|
child: SingleChildScrollView(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: Column(
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
const Text(
|
children: [
|
||||||
'Vision and goals',
|
const Text(
|
||||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
'Vision and goals',
|
||||||
),
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||||
const Text('What is your long-term vision for a startup?'),
|
),
|
||||||
...VisionOption.values.map((option) {
|
const Text('What is your long-term vision for a startup?'),
|
||||||
return CheckboxListTile(
|
...VisionOption.values.map((option) {
|
||||||
title: Text(option.displayName),
|
return CheckboxListTile(
|
||||||
value: selectedVisionOptions[option],
|
title: Text(option.displayName),
|
||||||
controlAffinity: ListTileControlAffinity.platform,
|
value: selectedVisionOptions[option],
|
||||||
onChanged: (bool? value) {
|
controlAffinity: ListTileControlAffinity.platform,
|
||||||
if (value != null) {
|
onChanged: (bool? value) {
|
||||||
setState(() {
|
if (value != null) {
|
||||||
selectedVisionOptions[option] = value;
|
setState(() {
|
||||||
});
|
selectedVisionOptions[option] = value;
|
||||||
}
|
});
|
||||||
},
|
}
|
||||||
);
|
},
|
||||||
}),
|
);
|
||||||
const SizedBox(height: 40),
|
}),
|
||||||
const Align(
|
const SizedBox(height: 40),
|
||||||
alignment: Alignment.centerLeft,
|
const Text(
|
||||||
child: Text(
|
|
||||||
'Availability and commitment',
|
'Availability and commitment',
|
||||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
),
|
const Text(
|
||||||
const Text(
|
'How much time can you devote to the startup each week?',
|
||||||
'How much time can you devote to the startup each week?',
|
|
||||||
),
|
|
||||||
...AvailabilityOption.values.map((option) {
|
|
||||||
return RadioListTile(
|
|
||||||
title: Text(option.displayName),
|
|
||||||
value: option,
|
|
||||||
groupValue: availability,
|
|
||||||
onChanged: (AvailabilityOption? value) {
|
|
||||||
setState(() {
|
|
||||||
availability = value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
Center(
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: handleSubmit,
|
|
||||||
child: Text(widget.isRegProcess ? 'Save and continue' : 'Save'),
|
|
||||||
),
|
),
|
||||||
),
|
...AvailabilityOption.values.map((option) {
|
||||||
],
|
return RadioListTile(
|
||||||
|
title: Text(option.displayName),
|
||||||
|
value: option,
|
||||||
|
groupValue: availability,
|
||||||
|
onChanged: (AvailabilityOption? value) {
|
||||||
|
setState(() {
|
||||||
|
availability = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
Center(
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: handleSubmit,
|
||||||
|
child:
|
||||||
|
Text(widget.isRegProcess ? 'Save and continue' : 'Save'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue