User changes
parent
b07c09d011
commit
ddeabac852
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:shayog/components/common/common_button.dart';
|
||||
import 'package:shayog/components/styles/textStyles.dart';
|
||||
import 'package:shayog/feature/presentation/widgets/text_view.dart';
|
||||
import '../../../../../../components/common/common_btn.dart';
|
||||
import '../../../../../../components/common/custom_drop_down.dart';
|
||||
|
@ -21,114 +22,7 @@ class AddInternalUser extends StatelessWidget {
|
|||
padding: EdgeInsets.all(16),
|
||||
color: AppColors.clrF2,
|
||||
child: allData(),
|
||||
// child: Row(
|
||||
// children: [
|
||||
// Expanded(child: Container(
|
||||
// padding: EdgeInsets.only(right: 16),
|
||||
// height: 150,
|
||||
// color: Colors.pink,
|
||||
// child: Column(
|
||||
// mainAxisAlignment: MainAxisAlignment.start,
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// TextView(
|
||||
// text: AppStrings.firstName,
|
||||
// isRequired: true,
|
||||
// ),
|
||||
// InputField(
|
||||
// errorTxtColor: controller.errorTextColor,
|
||||
// validator: Validations.checkValidations,
|
||||
// controller: controller.nameCtrl,
|
||||
// title: AppStrings.enterFirstName,
|
||||
// ),
|
||||
// TextView(
|
||||
// text: AppStrings.userType,
|
||||
// ),
|
||||
//
|
||||
// CustomDropdown(
|
||||
// initialValue: controller.userTypeList[1],
|
||||
// backClr: AppColors.clrD9,
|
||||
// borderClr: AppColors.clrGrey,
|
||||
// items: controller.userTypeList,
|
||||
// itemLabel: (item) => item,
|
||||
// onSelected: (selected) {
|
||||
// if (selected != null) {
|
||||
// controller.selectedValue.value = selected;
|
||||
// }
|
||||
// },
|
||||
// hintText: 'Select User Type',
|
||||
// ),
|
||||
// ],
|
||||
// ),)),
|
||||
// Expanded(child: Container(
|
||||
// padding: EdgeInsets.only(right: 16),
|
||||
// height: 150,
|
||||
// color: Colors.green,
|
||||
// child: Column(
|
||||
// mainAxisAlignment: MainAxisAlignment.start,
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// TextView(
|
||||
// text: AppStrings.lastName,
|
||||
// isRequired: true,
|
||||
// ),
|
||||
// InputField(
|
||||
// errorTxtColor: controller.errorTextColor,
|
||||
// validator: Validations.checkValidations,
|
||||
// controller: controller.lastNCtrl,
|
||||
// title: AppStrings.enterLastName,
|
||||
// ),
|
||||
// TextView(
|
||||
// text: AppStrings.status,
|
||||
// ),
|
||||
//
|
||||
// CustomDropdown(
|
||||
// initialValue: controller.status[0],
|
||||
// backClr: AppColors.clrD9,
|
||||
// borderClr: AppColors.clrGrey,
|
||||
// items: controller.status,
|
||||
// itemLabel: (item) => item,
|
||||
// onSelected: (selected) {
|
||||
// if (selected != null) {
|
||||
// controller.selectedStatus.value = selected;
|
||||
// }
|
||||
// },
|
||||
// hintText: 'Active'),
|
||||
// ],
|
||||
// ),)),
|
||||
// Expanded(child: Container(
|
||||
// height: 150,
|
||||
// color: Colors.yellow,
|
||||
// child: Column(
|
||||
// mainAxisAlignment: MainAxisAlignment.start,
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// TextView(
|
||||
// text: AppStrings.employeeCode,
|
||||
// isRequired: true,
|
||||
// ),
|
||||
// InputField(
|
||||
// errorTxtColor: controller.errorTextColor,
|
||||
// validator: Validations.checkValidations,
|
||||
// controller: controller.employeeCodeCtrl,
|
||||
// title: AppStrings.enterEmployeeCode,
|
||||
// ),
|
||||
// TextView(
|
||||
// text: AppStrings.emailAddress,
|
||||
// isRequired: true,
|
||||
// ),
|
||||
// //SizedBox(height: 8),
|
||||
// InputField(
|
||||
// errorTxtColor: controller.errorTextColor,
|
||||
// validator: Validations.checkEmailValidations,
|
||||
// controller: controller.emailCtrl,
|
||||
// title: AppStrings.enterEmailAddress,
|
||||
// ),
|
||||
//
|
||||
// ],
|
||||
// ),)),
|
||||
// ],
|
||||
// ),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -137,7 +31,7 @@ class AddInternalUser extends StatelessWidget {
|
|||
children: [
|
||||
Form(
|
||||
key: controller.formKey,
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
//autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
@ -199,6 +93,7 @@ class AddInternalUser extends StatelessWidget {
|
|||
)),
|
||||
],
|
||||
),
|
||||
SizedBox(height:8 ),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
|
@ -209,6 +104,7 @@ class AddInternalUser extends StatelessWidget {
|
|||
TextView(
|
||||
text: AppStrings.userType,
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
CustomDropdown(
|
||||
initialValue: controller.userTypeList[1],
|
||||
backClr: AppColors.clrD9,
|
||||
|
@ -222,6 +118,15 @@ class AddInternalUser extends StatelessWidget {
|
|||
},
|
||||
hintText: 'Select User Type',
|
||||
),
|
||||
Obx(() => controller.validateAdduser.value == true ?
|
||||
TextView(
|
||||
margin: EdgeInsets.only(top: 4),
|
||||
text: "Required",
|
||||
style: 10.txtTransparent,
|
||||
|
||||
) :
|
||||
SizedBox.shrink(
|
||||
))
|
||||
],
|
||||
)),
|
||||
SizedBox(width: 16),
|
||||
|
@ -233,8 +138,10 @@ class AddInternalUser extends StatelessWidget {
|
|||
TextView(
|
||||
text: AppStrings.status,
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
CustomDropdown(
|
||||
initialValue: controller.status[0],
|
||||
//initialValue: controller.status[0],
|
||||
initialValue: "Active",
|
||||
backClr: AppColors.clrD9,
|
||||
borderClr: AppColors.clrGrey,
|
||||
items: controller.status,
|
||||
|
@ -245,6 +152,16 @@ class AddInternalUser extends StatelessWidget {
|
|||
}
|
||||
},
|
||||
hintText: 'Active'),
|
||||
Obx(() => controller.validateAdduser.value == true ?
|
||||
TextView(
|
||||
margin: EdgeInsets.only(top: 4),
|
||||
text: "Required",
|
||||
style: 10.txtTransparent,
|
||||
|
||||
) :
|
||||
SizedBox.shrink(
|
||||
))
|
||||
|
||||
],
|
||||
)),
|
||||
SizedBox(width: 16),
|
||||
|
@ -310,26 +227,7 @@ class AddInternalUser extends StatelessWidget {
|
|||
clickAction: () {
|
||||
controller.createUser();
|
||||
}
|
||||
// if(controller.formKey.currentState!.validate()){
|
||||
// controller.createUser();
|
||||
// } else {
|
||||
// controller.validatePlants.value == true;
|
||||
//
|
||||
// }
|
||||
// if (controller.formKey.currentState
|
||||
// ?.validate() ??
|
||||
// false) {
|
||||
// ScaffoldMessenger.of(context)
|
||||
// .showSnackBar(
|
||||
// SnackBar(
|
||||
// content: Text(
|
||||
// 'Form submitted successfully!')),
|
||||
// );
|
||||
// controller.createUser();
|
||||
// } else {
|
||||
// controller.showE.value = true;
|
||||
// }
|
||||
// }
|
||||
|
||||
)
|
||||
: CommonButton(
|
||||
height: 30,
|
||||
|
|
|
@ -11,7 +11,7 @@ import '../../../../../components/styles/app_strings.dart';
|
|||
import '../../transporter/widgets/common_card.dart';
|
||||
|
||||
class InternalUserRoleMapping extends StatefulWidget {
|
||||
InternalUserRoleMapping({super.key});
|
||||
const InternalUserRoleMapping({super.key});
|
||||
|
||||
@override
|
||||
State<InternalUserRoleMapping> createState() => _InternalUserRoleMappingState();
|
||||
|
@ -19,35 +19,7 @@ class InternalUserRoleMapping extends StatefulWidget {
|
|||
|
||||
class _InternalUserRoleMappingState extends State<InternalUserRoleMapping> {
|
||||
final ctrl = Get.put(DashboardCtrl());
|
||||
String? selectedEmail;
|
||||
|
||||
// Error message
|
||||
String? errorText;
|
||||
|
||||
// List of emails for the dropdown
|
||||
final List<String> emails = ['email1@example.com', 'email2@example.com', 'email3@example.com'];
|
||||
|
||||
// Function for when the email is selected
|
||||
void onEmailSelected(String? email) {
|
||||
setState(() {
|
||||
selectedEmail = email;
|
||||
});
|
||||
}
|
||||
void onSaveClick() {
|
||||
// Validate that an email is selected
|
||||
if (selectedEmail == null || selectedEmail!.isEmpty) {
|
||||
setState(() {
|
||||
errorText = "Please select an email."; // Set the error message
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
errorText = null; // Clear the error message if selection is valid
|
||||
});
|
||||
|
||||
// Perform your save action (e.g., API call, navigation, etc.)
|
||||
print('Email Selected: $selectedEmail');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -63,23 +35,7 @@ class _InternalUserRoleMappingState extends State<InternalUserRoleMapping> {
|
|||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
// CustomDropdown<String>(
|
||||
// backClr: AppColors.clrD9,
|
||||
// borderClr: AppColors.clrGrey,
|
||||
// items: emails,
|
||||
// itemLabel: (item) => item,
|
||||
// onSelected: onEmailSelected,
|
||||
// hintText: "Select Email",
|
||||
// ),
|
||||
// // Error message for the dropdown if no value is selected
|
||||
// if (errorText != null)
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.only(top: 8.0),
|
||||
// child: Text(
|
||||
// errorText!,
|
||||
// style: TextStyle(color: Colors.red, fontSize: 12),
|
||||
// ),
|
||||
// ),
|
||||
|
||||
|
||||
Container(
|
||||
color: AppColors.clrF2,
|
||||
|
@ -106,21 +62,22 @@ class _InternalUserRoleMappingState extends State<InternalUserRoleMapping> {
|
|||
onSelected: (selected) {
|
||||
if (selected != null) {
|
||||
ctrl.selectedEmpCode.value = selected;
|
||||
ctrl.validateRoleMapCode.value = false;
|
||||
|
||||
}
|
||||
},
|
||||
hintText: "Select Employee Code",
|
||||
),
|
||||
SizedBox(height: 5),
|
||||
ctrl.validateRoleMapCode.value == true ? TextView(
|
||||
ctrl.validateRoleEmail.value == true ? TextView(
|
||||
text: "Required",
|
||||
style: 10.txtSBoldRed,
|
||||
style: 10.txtTransparent,
|
||||
|
||||
) : TextView(
|
||||
text: "ABC",
|
||||
style: 10.txtTransparent,
|
||||
|
||||
),
|
||||
|
||||
],
|
||||
)),
|
||||
SizedBox(width: 16),
|
||||
|
@ -184,12 +141,12 @@ class _InternalUserRoleMappingState extends State<InternalUserRoleMapping> {
|
|||
width: 100,
|
||||
text: AppStrings.submit,
|
||||
clickAction: () {
|
||||
if(ctrl.selectedEmail.value == "Select Email" ||ctrl.selectedEmpCode.value == "Select Employee Code" ){
|
||||
if(ctrl.selectedEmail.value == "Select Email" ){
|
||||
ctrl.validateRoleEmail.value = true;
|
||||
ctrl.validateRoleMapCode.value = true;
|
||||
|
||||
} else{
|
||||
ctrl.validateRoleEmail.value = false;
|
||||
ctrl.validateRoleMapCode.value = false;
|
||||
|
||||
ctrl.getRoleMappingData();
|
||||
|
||||
}
|
||||
|
|
|
@ -181,6 +181,7 @@ class ManageUser extends StatelessWidget {
|
|||
text: AppStrings.cancel,
|
||||
clickAction: () {
|
||||
controller.isSelected.value = false;
|
||||
controller.clearUserData();
|
||||
},
|
||||
),
|
||||
SizedBox(width: 16),
|
||||
|
@ -219,7 +220,7 @@ class ManageUser extends StatelessWidget {
|
|||
children: [
|
||||
Container(
|
||||
margin: EdgeInsets.only(bottom: 16, top: 16),
|
||||
height: MediaQuery.of(context).size.height * 0.6,
|
||||
height: MediaQuery.of(context).size.height * 0.4,
|
||||
child: RawScrollbar(
|
||||
thumbColor: AppColors.clrD9,
|
||||
radius: Radius.circular(2),
|
||||
|
|
|
@ -52,15 +52,16 @@ class UserPlantMapping extends StatelessWidget {
|
|||
hintText: 'Select Employee Code',
|
||||
),
|
||||
SizedBox(height: 5),
|
||||
ctrl.validatePlantCode.value == true ? TextView(
|
||||
ctrl.validatePlantEmail.value == true ? TextView(
|
||||
text: "Required",
|
||||
style: 10.txtSBoldRed,
|
||||
style: 10.txtTransparent,
|
||||
|
||||
) : TextView(
|
||||
text: "ABC",
|
||||
style: 10.txtTransparent,
|
||||
|
||||
),
|
||||
|
||||
],
|
||||
)),
|
||||
|
||||
|
@ -129,20 +130,18 @@ class UserPlantMapping extends StatelessWidget {
|
|||
text: AppStrings.submit,
|
||||
clickAction: () {
|
||||
|
||||
if(ctrl.selectPlantEmail.value == "Select Email" ||ctrl.selectedCode.value == "Select Employee Code" ){
|
||||
if(ctrl.selectPlantEmail.value == "Select Email"){
|
||||
ctrl.validatePlantEmail.value = true;
|
||||
ctrl.validatePlantCode.value = true;
|
||||
|
||||
} else{
|
||||
ctrl.validatePlantEmail.value = false;
|
||||
ctrl.validatePlantCode.value = false;
|
||||
|
||||
ctrl.getPlantMapping();
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
// clickAction: () {
|
||||
// ctrl.checkPlants();
|
||||
// },
|
||||
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -187,9 +186,9 @@ class UserPlantMapping extends StatelessWidget {
|
|||
value ?? false);
|
||||
},
|
||||
activeColor: AppColors.primaryClr,
|
||||
// Custom color when selected
|
||||
|
||||
checkColor: Colors.white,
|
||||
// Custom color for check mark
|
||||
|
||||
materialTapTargetSize: MaterialTapTargetSize
|
||||
.shrinkWrap,
|
||||
),
|
||||
|
|
|
@ -20,9 +20,7 @@ class UserScreen extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(bottom: 16),
|
||||
margin: EdgeInsets.all(16),
|
||||
child: Column(
|
||||
|
@ -43,12 +41,10 @@ class UserScreen extends StatelessWidget {
|
|||
ctrl.selectedUser.value = index;
|
||||
ctrl.clearPrefillData();
|
||||
ctrl.isSelected.value = false;
|
||||
ctrl.validateRoleMapCode.value = false;
|
||||
|
||||
ctrl.validateRoleEmail.value = false;
|
||||
ctrl.validatePlantEmail.value = false;
|
||||
ctrl.validatePlantCode.value = false;
|
||||
ctrl.validateUserStatus.value = false;
|
||||
ctrl.validateUserType.value = false;
|
||||
|
||||
|
||||
if (ctrl.selectedUser.value == 0) {
|
||||
|
||||
|
@ -154,8 +150,6 @@ class UserScreen extends StatelessWidget {
|
|||
}),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -44,16 +44,7 @@ class UserType extends StatelessWidget {
|
|||
controller: controller.userTypeCtrl,
|
||||
title: "Enter User Type",
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
controller.validateUserType.value == true ? TextView(
|
||||
text: "Required",
|
||||
style: 10.txtSBoldRed,
|
||||
|
||||
) : TextView(
|
||||
text: "ABC",
|
||||
style: 10.txtTransparent,
|
||||
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
|
@ -82,16 +73,7 @@ class UserType extends StatelessWidget {
|
|||
}
|
||||
},
|
||||
hintText: 'Select Status'),
|
||||
SizedBox(height: 8),
|
||||
controller.validateUserType.value == true ? TextView(
|
||||
text: "Required",
|
||||
style: 10.txtSBoldRed,
|
||||
|
||||
) : TextView(
|
||||
text: "ABC",
|
||||
style: 10.txtTransparent,
|
||||
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
|
@ -123,15 +105,8 @@ SizedBox(height: 8),
|
|||
|
||||
|
||||
clickAction: () {
|
||||
if(controller.userTypeCtrl.text.isEmpty ||controller.selectStatus.value == "Select Status" ){
|
||||
controller.validateUserStatus.value = true;
|
||||
controller.validateUserType.value = true;
|
||||
} else{
|
||||
controller.validateUserStatus.value = false;
|
||||
controller.validateUserType.value = false;
|
||||
controller.createUserType();
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
),
|
||||
|
@ -269,116 +244,6 @@ SizedBox(height: 8),
|
|||
],
|
||||
);
|
||||
}
|
||||
data(){
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TextView(text:
|
||||
"Add User Type",isRequired: true,
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
InputField(
|
||||
controller: controller.userTypeCtrl,
|
||||
title: "Enter User Type",
|
||||
),
|
||||
|
||||
controller.validateUserType.value == true ? TextView(
|
||||
text: "Required",
|
||||
style: 10.txtSBoldRed,
|
||||
|
||||
) : TextView(
|
||||
text: "ABC",
|
||||
style: 10.txtTransparent,
|
||||
|
||||
),
|
||||
],
|
||||
)),
|
||||
SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TextView(
|
||||
text:
|
||||
"Status Type",isRequired: true,
|
||||
),
|
||||
|
||||
CustomDropdown(
|
||||
initialValue: controller.selectStatus.value,
|
||||
backClr: AppColors.clrD9,
|
||||
borderClr: AppColors.clrGrey,
|
||||
items: controller.userTypeStatus,
|
||||
itemLabel: (item) => item,
|
||||
onSelected: (selected) {
|
||||
if (selected != null) {
|
||||
controller.selectStatus.value = selected;
|
||||
}
|
||||
},
|
||||
hintText: 'Select Status'),
|
||||
|
||||
controller.validateUserType.value == true ? TextView(
|
||||
text: "Required",
|
||||
style: 10.txtSBoldRed,
|
||||
|
||||
) : TextView(
|
||||
text: "ABC",
|
||||
style: 10.txtTransparent,
|
||||
|
||||
),
|
||||
],
|
||||
)),
|
||||
SizedBox(width: 16),
|
||||
Expanded(
|
||||
//flex: 2,
|
||||
child: Column(
|
||||
children: [
|
||||
TextView(text:
|
||||
"",
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
CommonBtn(
|
||||
bkClr: Colors.white,
|
||||
text: AppStrings.cancel,
|
||||
clickAction: () {},
|
||||
),
|
||||
SizedBox(width: 16),
|
||||
CommonButton(
|
||||
isLoading: controller.userTypeLoading,
|
||||
height: 28,
|
||||
borderRadius: 4,
|
||||
width: 100,
|
||||
text: AppStrings.submit,
|
||||
|
||||
|
||||
clickAction: () {
|
||||
if(controller.userTypeCtrl.text.isEmpty ||controller.selectStatus.value == "Select Status" ){
|
||||
controller.validateUserStatus.value = true;
|
||||
controller.validateUserType.value = true;
|
||||
} else{
|
||||
controller.validateUserStatus.value = false;
|
||||
controller.validateUserType.value = false;
|
||||
controller.createUserType();
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
))
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ class DashboardCtrl extends GetxController {
|
|||
@override
|
||||
void onInit() {
|
||||
getManageUser();
|
||||
getDropDownData();
|
||||
getPlantEmailCode();
|
||||
getEmailCodeOfRoleMapping();
|
||||
userTypeDetails();
|
||||
super.onInit();
|
||||
|
@ -135,7 +135,7 @@ var userEmail =[].obs;
|
|||
|
||||
Map<String, String> requestBody = {
|
||||
"userName": selectUser.value == "Select User Name" ? "" : selectUser.value,
|
||||
"userTypeName": selectUser.value == "Select User Name" ? "" : selectUser.value,
|
||||
"userTypeName": selectType.value == "Select UserType" ? "" : selectType.value,
|
||||
"Email": selectEmail.value == "Select Email" ?"": selectEmail.value,
|
||||
"EmployeeTransCode":
|
||||
selectCode.value == "Select Employee Code" ? "" : selectCode.value,
|
||||
|
@ -168,7 +168,14 @@ var userEmail =[].obs;
|
|||
userLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
clearUserData(){
|
||||
selectUser.value = "Select User Name";
|
||||
selectEmail.value = "Select Email";
|
||||
selectCode.value = "Select Employee Code";
|
||||
selectType.value = "Select UserType";
|
||||
selectedStatus.value = "Select Status";
|
||||
getManageUser();
|
||||
}
|
||||
void nextPage() {
|
||||
if (currentPage.value < totalPages.value) {
|
||||
currentPage.value++;
|
||||
|
@ -226,14 +233,15 @@ var userEmail =[].obs;
|
|||
var status = ['Active', 'In-Active'];
|
||||
var selectedStatus = 'Select Status'.obs;
|
||||
var selectedValue = 'Select User Type'.obs;
|
||||
var isValidate = false.obs;
|
||||
|
||||
Color errorTextColor = Colors.red;
|
||||
|
||||
void createUser() {
|
||||
if (formKey.currentState!.validate()) {
|
||||
validateAdduser.value = false;
|
||||
addInternalUser();
|
||||
} else {
|
||||
isValidate.value = true;
|
||||
validateAdduser.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,6 +272,8 @@ var userEmail =[].obs;
|
|||
onclick: () {
|
||||
Get.back();
|
||||
getManageUser();
|
||||
getEmailCodeOfRoleMapping();
|
||||
getPlantEmailCode();
|
||||
clearPrefillData();
|
||||
selectedUser.value = 0;
|
||||
});
|
||||
|
@ -370,7 +380,7 @@ var userEmail =[].obs;
|
|||
var employeeCode = [].obs;
|
||||
var userEmails = [].obs;
|
||||
|
||||
getDropDownData() async {
|
||||
getPlantEmailCode() async {
|
||||
try {
|
||||
dropDownLoader.value = true;
|
||||
|
||||
|
@ -394,18 +404,7 @@ var userEmail =[].obs;
|
|||
selectPlantCode.value.isEmpty;
|
||||
}
|
||||
|
||||
checkPlants() {
|
||||
if (selectPlantEmail.value == "Select Email" ||
|
||||
selectPlantCode.value == "Select Employee Code") {
|
||||
CommonDialog.showDialog(
|
||||
message: "Select all mandatory fields",
|
||||
onclick: () {
|
||||
Get.back();
|
||||
});
|
||||
} else {
|
||||
getPlantMapping();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
clearRoleMapping() {
|
||||
selectedEmail.value.isEmpty;
|
||||
|
@ -436,7 +435,7 @@ var userEmail =[].obs;
|
|||
var fetchEmailsNCodesLoading = false.obs;
|
||||
var statusMessage = "".obs;
|
||||
|
||||
// rolemapping
|
||||
// roleMappingEmailCode
|
||||
getRoleMappingData() async {
|
||||
try {
|
||||
fetchEmailsNCodesLoading.value = true;
|
||||
|
@ -444,13 +443,14 @@ var userEmail =[].obs;
|
|||
"email": selectedEmail.value,
|
||||
"employeeTransCode": selectedEmpCode.value,
|
||||
};
|
||||
var response = await PostRequests.fetchEmailsAndEmpCodes(requestBody);
|
||||
var response = await PostRequests.fetchEmailsAndEmpCodes(requestBody,statusMessage.value);
|
||||
if (response != null) {
|
||||
roleMappingData.value = response.data!;
|
||||
showRolesSection.value = true;
|
||||
statusMessage.value = response.status.toString();
|
||||
|
||||
} else {
|
||||
print("cdg");
|
||||
|
||||
//print("cdg");
|
||||
// AppAlerts.alert(message: "sxjs");
|
||||
}
|
||||
} finally {
|
||||
|
@ -579,11 +579,10 @@ var userEmail =[].obs;
|
|||
}
|
||||
|
||||
RxBool validateRoleEmail = false.obs;
|
||||
RxBool validateRoleMapCode = false.obs;
|
||||
|
||||
RxBool validatePlantEmail = false.obs;
|
||||
RxBool validatePlantCode = false.obs;
|
||||
RxBool validateUserStatus = false.obs;
|
||||
RxBool validateUserType = false.obs;
|
||||
RxBool validateAdduser = false.obs;
|
||||
|
||||
|
||||
searchEmpCode(String enterValue) {
|
||||
print('-----typing ---- ${enterValue}');
|
||||
|
@ -607,26 +606,6 @@ var userEmail =[].obs;
|
|||
}
|
||||
RxString? validateEmail;
|
||||
|
||||
// Error message
|
||||
RxString? showErrorText;
|
||||
void onEmailSelected(dynamic email) {
|
||||
|
||||
selectedEmail.value = email;
|
||||
|
||||
}
|
||||
void onSaveClick() {
|
||||
// Validate that an email is selected
|
||||
if (selectedEmail.value.isEmpty) {
|
||||
|
||||
errorText.value = "Required"; // Set the error message
|
||||
|
||||
} else {
|
||||
|
||||
errorText.value = ""; // Clear the error message if selection is valid
|
||||
|
||||
|
||||
// Perform your save action (e.g., API call, navigation, etc.)
|
||||
print('Email Selected: $selectedEmail');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,17 +155,26 @@ class PostRequests {
|
|||
}
|
||||
}
|
||||
|
||||
// static Future<FetchInternalUserModel?> fetchEmailsAndEmpCodes(
|
||||
// Map<String, String> requestBody) async {
|
||||
// var apiResponse = await RemoteService.postUser(
|
||||
// requestBody, ApiUrls.fetchEmailsAndEmpCode);
|
||||
// if (apiResponse != null) {
|
||||
// return fetchInternalUserModelFromJson(apiResponse.response!);
|
||||
// } else {
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
static Future<FetchInternalUserModel?> fetchEmailsAndEmpCodes(
|
||||
Map<String, String> requestBody) async {
|
||||
var apiResponse = await RemoteService.postUser(
|
||||
requestBody, ApiUrls.fetchEmailsAndEmpCode);
|
||||
Map<String, String> requestBody,String message) async {
|
||||
var apiResponse = await RemoteService.postMethod(
|
||||
requestBody, ApiUrls.fetchEmailsAndEmpCode,message);
|
||||
if (apiResponse != null) {
|
||||
return fetchInternalUserModelFromJson(apiResponse.response!);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<SelectAssignRoleModel?> selectAssignRole(
|
||||
Map<String, dynamic> requestBody) async {
|
||||
var apiResponse =
|
||||
|
|
|
@ -287,6 +287,33 @@ class RemoteService {
|
|||
try {
|
||||
final map = jsonDecode(response.body) as Map<String, dynamic>;
|
||||
// AppAlerts.alert(message: '${map['message']}');
|
||||
throw map['message'];
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
static Future<CommonResModel?> postMethod(
|
||||
Map<String, dynamic> requestBody, String endUrl,String message) async {
|
||||
var body = json.encode(requestBody);
|
||||
final response =
|
||||
await http.post(Uri.parse(endUrl), headers: getHeaders(), body: body);
|
||||
print('${response.body}response');
|
||||
print(endUrl);
|
||||
print('${response.statusCode}response');
|
||||
var responseCode = response.statusCode;
|
||||
|
||||
if (Helpers.isResponseSuccessful(responseCode)) {
|
||||
return CommonResModel(statusCode: responseCode, response: response.body);
|
||||
} else {
|
||||
print(response.body);
|
||||
|
||||
try {
|
||||
final map = jsonDecode(response.body) as Map<String, dynamic>;
|
||||
message = '${map['message']}';
|
||||
print("message?????${message}");
|
||||
|
||||
|
||||
throw map['message'];
|
||||
} catch (e) {
|
||||
return null;
|
||||
|
|
Loading…
Reference in New Issue