Merge pull request 'consol/feature/unit2/UNIT2-#41Fix_small_bugs_and_implement_assign_role_area__develop' (#53) from consol/feature/unit2/UNIT2-#41Fix_small_bugs_and_implement_assign_role_area__develop into develop
Reviewed-on: http://git.agusandelnorte.gov.ph:3000/SoftwareDevelopmentSection/unit2-null-safety-repository/pulls/53feature/passo/PASSO-#1-Sync-data-from-device-to-postgre-and-vice-versa
commit
b560340ebc
|
@ -26,6 +26,6 @@ subprojects {
|
||||||
project.evaluationDependsOn(':app')
|
project.evaluationDependsOn(':app')
|
||||||
}
|
}
|
||||||
|
|
||||||
task clean(type: Delete) {
|
tasks.register("clean", Delete) {
|
||||||
delete rootProject.buildDir
|
delete rootProject.buildDir
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import 'package:unit2/sevices/profile/profile_service.dart';
|
||||||
|
|
||||||
import '../../model/profile/basic_information/primary-information.dart';
|
import '../../model/profile/basic_information/primary-information.dart';
|
||||||
import '../../screens/profile/components/basic_information/profile_other_info.dart';
|
import '../../screens/profile/components/basic_information/profile_other_info.dart';
|
||||||
|
import '../../utils/global.dart';
|
||||||
part 'profile_event.dart';
|
part 'profile_event.dart';
|
||||||
part 'profile_state.dart';
|
part 'profile_state.dart';
|
||||||
|
|
||||||
|
@ -52,20 +53,24 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
|
||||||
.getProfile(event.token, event.userID);
|
.getProfile(event.token, event.userID);
|
||||||
globalProfileInformation = profileInformation;
|
globalProfileInformation = profileInformation;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit(ProfileLoaded(profileInformation: globalProfileInformation!));
|
emit(ProfileLoaded(profileInformation: globalProfileInformation!));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(ProfileErrorState(mesage: e.toString()));
|
emit(ProfileErrorState(mesage: e.toString()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
on<GetPrimaryBasicInfo>((event, emit) {
|
on<GetPrimaryBasicInfo>((event, emit) {
|
||||||
currentProfileInformation = event.primaryBasicInformation;
|
if (globalCurrentProfile != null) {
|
||||||
emit(BasicInformationProfileLoaded(
|
emit(BasicInformationProfileLoaded(
|
||||||
primaryBasicInformation: event.primaryBasicInformation));
|
primaryBasicInformation: globalCurrentProfile!));
|
||||||
|
} else {
|
||||||
|
currentProfileInformation = event.primaryBasicInformation;
|
||||||
|
emit(BasicInformationProfileLoaded(
|
||||||
|
primaryBasicInformation: currentProfileInformation!));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
on<LoadBasicPrimaryInfo>((event, emit) {
|
on<LoadBasicPrimaryInfo>((event, emit) {
|
||||||
emit(BasicInformationProfileLoaded(
|
emit(BasicInformationProfileLoaded(
|
||||||
primaryBasicInformation: currentProfileInformation!));
|
primaryBasicInformation: globalCurrentProfile!));
|
||||||
});
|
});
|
||||||
on<ShowPrimaryInfoEditForm>((event, emit) async {
|
on<ShowPrimaryInfoEditForm>((event, emit) async {
|
||||||
try {
|
try {
|
||||||
|
@ -132,6 +137,12 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
|
||||||
if (status['success']) {
|
if (status['success']) {
|
||||||
Profile profile = Profile.fromJson(status['data']);
|
Profile profile = Profile.fromJson(status['data']);
|
||||||
currentProfileInformation = profile;
|
currentProfileInformation = profile;
|
||||||
|
globalCurrentProfile = profile;
|
||||||
|
globalFistname = profile.firstName;
|
||||||
|
globalLastname = profile.lastName;
|
||||||
|
globalBday = profile.birthdate;
|
||||||
|
globalSex = profile.sex;
|
||||||
|
|
||||||
emit(BasicProfileInfoEditedState(response: status));
|
emit(BasicProfileInfoEditedState(response: status));
|
||||||
}
|
}
|
||||||
emit(BasicProfileInfoEditedState(response: status));
|
emit(BasicProfileInfoEditedState(response: status));
|
||||||
|
|
|
@ -0,0 +1,275 @@
|
||||||
|
import 'package:bloc/bloc.dart';
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
import 'package:unit2/bloc/role_assignment/role_assignment_bloc.dart';
|
||||||
|
import 'package:unit2/model/location/purok2.dart';
|
||||||
|
import 'package:unit2/model/rbac/assigned_role.dart';
|
||||||
|
import 'package:unit2/model/rbac/rbac.dart';
|
||||||
|
import 'package:unit2/model/rbac/rbac_station.dart';
|
||||||
|
import 'package:unit2/model/roles/pass_check/assign_role_area_type.dart';
|
||||||
|
import 'package:unit2/model/utils/agency.dart';
|
||||||
|
import 'package:unit2/sevices/roles/rbac_operations/assigned_area_services.dart';
|
||||||
|
import '../../../../model/location/barangay2.dart';
|
||||||
|
import '../../../../model/profile/assigned_area.dart';
|
||||||
|
import '../../../../model/profile/basic_information/primary-information.dart';
|
||||||
|
import '../../../../sevices/roles/rbac_operations/role_assignment_services.dart';
|
||||||
|
part 'assign_area_event.dart';
|
||||||
|
part 'assign_area_state.dart';
|
||||||
|
|
||||||
|
class AssignAreaBloc extends Bloc<AssignAreaEvent, AssignAreaState> {
|
||||||
|
AssignAreaBloc() : super(AssignAreaInitial()) {
|
||||||
|
String? fname;
|
||||||
|
String? lname;
|
||||||
|
String? fullname;
|
||||||
|
Profile? profile;
|
||||||
|
int id;
|
||||||
|
List<UserAssignedArea> userAssignedAreas = [];
|
||||||
|
List<AssignedRole> assignedRoles = [];
|
||||||
|
List<RBAC> roles = [];
|
||||||
|
on<GetAssignArea>((event, emit) async {
|
||||||
|
emit(AssignAreaLoadingState());
|
||||||
|
try {
|
||||||
|
profile = await RbacRoleAssignmentServices.instance.searchUser(
|
||||||
|
page: 1, name: event.firstname, lastname: event.lastname);
|
||||||
|
if (profile != null && profile!.id != null) {
|
||||||
|
fname = profile!.firstName;
|
||||||
|
lname = profile!.lastName;
|
||||||
|
fullname = profile!.lastName;
|
||||||
|
fullname = "${fname!} ${lname!}";
|
||||||
|
id = profile!.webuserId!;
|
||||||
|
userAssignedAreas = await RbacAssignedAreaServices.instance
|
||||||
|
.getAssignedArea(id: profile!.webuserId!);
|
||||||
|
|
||||||
|
assignedRoles = await RbacRoleAssignmentServices.instance
|
||||||
|
.getAssignedRoles(
|
||||||
|
firstname: event.firstname, lastname: event.lastname);
|
||||||
|
|
||||||
|
for (var role in assignedRoles) {
|
||||||
|
roles.add(role.role!);
|
||||||
|
}
|
||||||
|
emit(AssignedAreaLoadedState(
|
||||||
|
userAssignedAreas: userAssignedAreas,
|
||||||
|
fullname: fullname!,
|
||||||
|
roles: roles,
|
||||||
|
userId: id));
|
||||||
|
} else {
|
||||||
|
id = 0;
|
||||||
|
emit(UserNotExistError());
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
emit(AssignAreaErorState(message: e.toString()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
on<AddAssignArea>((event, emit) async {
|
||||||
|
// try {
|
||||||
|
emit(AssignAreaLoadingState());
|
||||||
|
Map<dynamic, dynamic> response = await RbacAssignedAreaServices.instance
|
||||||
|
.add(
|
||||||
|
userId: event.userId,
|
||||||
|
roleId: event.roleId,
|
||||||
|
areaTypeId: event.areaTypeId,
|
||||||
|
areaId: event.areaId);
|
||||||
|
if (response["success"]) {
|
||||||
|
UserAssignedArea? newAssignArea;
|
||||||
|
for (var userArea in userAssignedAreas) {
|
||||||
|
if (userArea.assignedRole?.role?.id == event.roleId &&
|
||||||
|
userArea.assignedRole?.user?.id == event.userId) {
|
||||||
|
newAssignArea = userArea;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// newAssignArea = userAssignedAreas.firstWhere((var element) {
|
||||||
|
// return element.assignedRole?.role?.id == event.roleId &&
|
||||||
|
// element.assignedRole?.user?.id == event.userId;
|
||||||
|
// });
|
||||||
|
|
||||||
|
if (newAssignArea?.assignedArea != null) {
|
||||||
|
userAssignedAreas.removeWhere((element) =>
|
||||||
|
element.assignedRole!.role!.id == event.roleId &&
|
||||||
|
element.assignedRole!.user!.id == event.userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
AssignedRole newAssignedRole =
|
||||||
|
AssignedRole.fromJson(response['data'][0]['assigned_role']);
|
||||||
|
AssignRoleAreaType newAssignRoleType = AssignRoleAreaType.fromJson(
|
||||||
|
response['data'][0]['assigned_role_area_type']);
|
||||||
|
UserAssignedArea temp = UserAssignedArea(
|
||||||
|
assignedRole: newAssignedRole,
|
||||||
|
assignedRoleAreaType: newAssignRoleType,
|
||||||
|
assignedArea: []);
|
||||||
|
newAssignArea = temp;
|
||||||
|
|
||||||
|
////barangay
|
||||||
|
if (event.areaTypeId == 1) {
|
||||||
|
List<dynamic> newAreas = [];
|
||||||
|
for (var area in response['data']) {
|
||||||
|
for (var assignedArea in area['assigned_area']) {
|
||||||
|
var newArea = {};
|
||||||
|
newArea.addAll({"id": assignedArea['id']});
|
||||||
|
newArea.addAll({'isactive': assignedArea['isactive']});
|
||||||
|
|
||||||
|
Barangay2 newBarangay = Barangay2.fromJson(assignedArea['area']);
|
||||||
|
|
||||||
|
newArea.addAll({
|
||||||
|
'area': {
|
||||||
|
"brgycode": newBarangay.brgycode,
|
||||||
|
"brgydesc": newBarangay.brgydesc,
|
||||||
|
"citymuncode": newBarangay.citymuncode
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
newAreas.add(newArea);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newAssignArea?.assignedArea = newAreas;
|
||||||
|
userAssignedAreas.add(newAssignArea!);
|
||||||
|
//// purok
|
||||||
|
}
|
||||||
|
if (event.areaTypeId == 2) {
|
||||||
|
List<dynamic> newAreas = [];
|
||||||
|
for (var area in response['data']) {
|
||||||
|
for (var assignedArea in area['assigned_area']) {
|
||||||
|
var newArea = {};
|
||||||
|
newArea.addAll({"id": assignedArea['id']});
|
||||||
|
newArea.addAll({'isactive': assignedArea['isactive']});
|
||||||
|
Purok2 newPurok = Purok2.fromJson(assignedArea['area']);
|
||||||
|
newArea.addAll({
|
||||||
|
'area': {
|
||||||
|
"purokid": newPurok.purokid,
|
||||||
|
"purokdesc": newPurok.purokdesc,
|
||||||
|
"brgy": {
|
||||||
|
"brgycode": newPurok.brgy?.brgycode,
|
||||||
|
"brgydesc": newPurok.brgy?.brgydesc,
|
||||||
|
"citymuncode": newPurok.brgy?.citymuncode,
|
||||||
|
},
|
||||||
|
"purok_leader": newPurok.purokLeader,
|
||||||
|
"writelock": newPurok.writelock,
|
||||||
|
"recordsignature": newPurok.recordsignature
|
||||||
|
}
|
||||||
|
});
|
||||||
|
newAreas.add(newArea);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newAssignArea?.assignedArea = newAreas;
|
||||||
|
userAssignedAreas.add(newAssignArea!);
|
||||||
|
}
|
||||||
|
////statiom
|
||||||
|
if (event.areaTypeId == 4) {
|
||||||
|
List<dynamic> newAreas = [];
|
||||||
|
for (var area in response['data']) {
|
||||||
|
for (var assignedArea in area['assigned_area']) {
|
||||||
|
var newArea = {};
|
||||||
|
newArea.addAll({"id": assignedArea['id']});
|
||||||
|
newArea.addAll({'isactive': assignedArea['isactive']});
|
||||||
|
RbacStation newStation =
|
||||||
|
RbacStation.fromJson(assignedArea['area']);
|
||||||
|
newArea.addAll({
|
||||||
|
"area": {
|
||||||
|
"id": newStation.id,
|
||||||
|
"station_name": newStation.stationName,
|
||||||
|
"station_type": {
|
||||||
|
"id": newStation.stationType?.id,
|
||||||
|
"type_name": newStation.stationType?.typeName,
|
||||||
|
"color": newStation.stationType?.color,
|
||||||
|
"order": newStation.stationType?.order,
|
||||||
|
"is_active": newStation.stationType?.isActive,
|
||||||
|
"group": null
|
||||||
|
},
|
||||||
|
"hierarchy_order_no": newStation.hierarchyOrderNo,
|
||||||
|
"head_position": newStation.headPosition,
|
||||||
|
"government_agency": {
|
||||||
|
"agencyid": newStation.governmentAgency?.agencycatid,
|
||||||
|
"agencyname": newStation.governmentAgency?.agencyname,
|
||||||
|
"agencycatid": newStation.governmentAgency?.agencycatid,
|
||||||
|
"private_entity":
|
||||||
|
newStation.governmentAgency?.privateEntity,
|
||||||
|
"contactinfoid": newStation.governmentAgency?.contactinfoid
|
||||||
|
},
|
||||||
|
"acronym": newStation.acronym,
|
||||||
|
"parent_station": newStation.parentStation,
|
||||||
|
"code": newStation.code,
|
||||||
|
"fullcode": newStation.fullcode,
|
||||||
|
"child_station_info": newStation.childStationInfo,
|
||||||
|
"islocation_under_parent": newStation.islocationUnderParent,
|
||||||
|
"main_parent_station": newStation.mainParentStation,
|
||||||
|
"description": newStation.description,
|
||||||
|
"ishospital": newStation.ishospital,
|
||||||
|
"isactive": newStation.isactive,
|
||||||
|
"selling_station": newStation.sellingStation
|
||||||
|
}
|
||||||
|
});
|
||||||
|
newAreas.add(newArea);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newAssignArea?.assignedArea = newAreas;
|
||||||
|
userAssignedAreas.add(newAssignArea!);
|
||||||
|
}
|
||||||
|
////agency
|
||||||
|
if (event.areaTypeId == 3) {
|
||||||
|
List<dynamic> newAreas = [];
|
||||||
|
for (var area in response['data']) {
|
||||||
|
for (var assignedArea in area['assigned_area']) {
|
||||||
|
var newArea = {};
|
||||||
|
newArea.addAll({"id": assignedArea['id']});
|
||||||
|
newArea.addAll({'isactive': assignedArea['isactive']});
|
||||||
|
Agency newAgency = Agency.fromJson(assignedArea['area']);
|
||||||
|
newArea.addAll({
|
||||||
|
"area": {
|
||||||
|
"id": newAgency.id,
|
||||||
|
"name": newAgency.name,
|
||||||
|
"category": {
|
||||||
|
"id": newAgency.category?.id,
|
||||||
|
"industry_class": {
|
||||||
|
"id": newAgency.category?.industryClass?.id,
|
||||||
|
"name": newAgency.category?.industryClass?.name,
|
||||||
|
"description":
|
||||||
|
newAgency.category?.industryClass?.description
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"private_entity": newAgency.privateEntity,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
newAreas.add(newArea);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newAssignArea?.assignedArea = newAreas;
|
||||||
|
userAssignedAreas.add(newAssignArea!);
|
||||||
|
}
|
||||||
|
emit(AssignAreaAddedState(response: response));
|
||||||
|
} else {
|
||||||
|
emit(AssignAreaAddedState(response: response));
|
||||||
|
}
|
||||||
|
// } catch (e) {
|
||||||
|
// emit(AssignAreaErorState(message: e.toString()));
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
on<LoadAssignedAreas>((event, emit) async {
|
||||||
|
emit(AssignedAreaLoadedState(
|
||||||
|
userAssignedAreas: userAssignedAreas,
|
||||||
|
fullname: fullname!,
|
||||||
|
roles: roles,
|
||||||
|
userId: event.userId));
|
||||||
|
});
|
||||||
|
on<DeleteAssignedArea>((event, emit) async {
|
||||||
|
emit(AssignAreaLoadingState());
|
||||||
|
try {
|
||||||
|
bool success = await RbacAssignedAreaServices.instance
|
||||||
|
.deleteAssignedArea(areaId: event.areaId);
|
||||||
|
if (success) {
|
||||||
|
for (var area in userAssignedAreas) {
|
||||||
|
area.assignedArea.removeWhere((var a) {
|
||||||
|
return a['id'] == event.areaId;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
emit(AssignedAreaDeletedState(success: success));
|
||||||
|
} else {
|
||||||
|
emit(AssignedAreaDeletedState(success: success));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
emit(AssignAreaErorState(message: e.toString()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
on<CallErrorState>((event, emit) {
|
||||||
|
emit(AssignAreaErorState(message: event.message));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
part of 'assign_area_bloc.dart';
|
||||||
|
|
||||||
|
class AssignAreaEvent extends Equatable {
|
||||||
|
const AssignAreaEvent();
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [];
|
||||||
|
}
|
||||||
|
|
||||||
|
class GetAssignArea extends AssignAreaEvent {
|
||||||
|
final String firstname;
|
||||||
|
final String lastname;
|
||||||
|
const GetAssignArea({required this.firstname, required this.lastname});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [firstname, lastname];
|
||||||
|
}
|
||||||
|
|
||||||
|
class DeleteAssignedArea extends AssignAreaEvent {
|
||||||
|
final int areaId;
|
||||||
|
const DeleteAssignedArea({required this.areaId});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [areaId];
|
||||||
|
}
|
||||||
|
|
||||||
|
class LoadAssignedAreas extends AssignAreaEvent {
|
||||||
|
final int userId;
|
||||||
|
const LoadAssignedAreas({required this.userId});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [userId];
|
||||||
|
}
|
||||||
|
|
||||||
|
class CallErrorState extends AssignAreaEvent {
|
||||||
|
final String message;
|
||||||
|
const CallErrorState({required this.message});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [message];
|
||||||
|
}
|
||||||
|
|
||||||
|
class AddAssignArea extends AssignAreaEvent {
|
||||||
|
final int userId;
|
||||||
|
final int roleId;
|
||||||
|
final int areaTypeId;
|
||||||
|
final String areaId;
|
||||||
|
|
||||||
|
const AddAssignArea(
|
||||||
|
{required this.areaId,
|
||||||
|
required this.areaTypeId,
|
||||||
|
required this.roleId,
|
||||||
|
required this.userId});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [userId, roleId, areaTypeId, areaId];
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
part of 'assign_area_bloc.dart';
|
||||||
|
|
||||||
|
class AssignAreaState extends Equatable {
|
||||||
|
const AssignAreaState();
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [];
|
||||||
|
}
|
||||||
|
|
||||||
|
class AssignedAreaLoadedState extends AssignAreaState{
|
||||||
|
final List<UserAssignedArea> userAssignedAreas;
|
||||||
|
final List<RBAC> roles;
|
||||||
|
final String fullname;
|
||||||
|
final int userId;
|
||||||
|
const AssignedAreaLoadedState({required this.userAssignedAreas, required this.fullname, required this.roles, required this.userId});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [userAssignedAreas,fullname,roles];
|
||||||
|
}
|
||||||
|
class AssignAreaErorState extends AssignAreaState {
|
||||||
|
final String message;
|
||||||
|
const AssignAreaErorState({required this.message});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [message];
|
||||||
|
}
|
||||||
|
class AssignAreaLoadingState extends AssignAreaState{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class UserNotExistError extends AssignAreaState{
|
||||||
|
|
||||||
|
}
|
||||||
|
class AssignAreaInitial extends AssignAreaState {}
|
||||||
|
class AssignedAreaDeletedState extends AssignAreaState{
|
||||||
|
final bool success;
|
||||||
|
const AssignedAreaDeletedState({required this.success});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [success];
|
||||||
|
}
|
||||||
|
class AssignAreaAddedState extends AssignAreaState {
|
||||||
|
final Map<dynamic,dynamic> response;
|
||||||
|
const AssignAreaAddedState({required this.response});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [response];
|
||||||
|
}
|
|
@ -65,6 +65,7 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
|
||||||
otherInputs: otherInputs!,
|
otherInputs: otherInputs!,
|
||||||
passerId: uuid!,
|
passerId: uuid!,
|
||||||
roleId: roleIdRoleName!.roleId,
|
roleId: roleIdRoleName!.roleId,
|
||||||
|
roleName: roleIdRoleName!.roleName,
|
||||||
stationId: stationId,
|
stationId: stationId,
|
||||||
temp: event.temp));
|
temp: event.temp));
|
||||||
});
|
});
|
||||||
|
@ -78,6 +79,7 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
|
||||||
otherInputs: otherInputs!,
|
otherInputs: otherInputs!,
|
||||||
passerId: uuid!,
|
passerId: uuid!,
|
||||||
roleId: roleIdRoleName!.roleId,
|
roleId: roleIdRoleName!.roleId,
|
||||||
|
roleName: roleIdRoleName!.roleName,
|
||||||
stationId: stationId,
|
stationId: stationId,
|
||||||
temp: null));
|
temp: null));
|
||||||
});
|
});
|
||||||
|
@ -123,6 +125,7 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
|
||||||
otherInputs: otherInputs!,
|
otherInputs: otherInputs!,
|
||||||
passerId: uuid!,
|
passerId: uuid!,
|
||||||
roleId: roleIdRoleName!.roleId,
|
roleId: roleIdRoleName!.roleId,
|
||||||
|
roleName: roleIdRoleName!.roleName,
|
||||||
stationId: stationId,
|
stationId: stationId,
|
||||||
temp: null));
|
temp: null));
|
||||||
}
|
}
|
||||||
|
@ -152,7 +155,7 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
|
||||||
stationId: event.stationId,
|
stationId: event.stationId,
|
||||||
cpId: event.cpId,
|
cpId: event.cpId,
|
||||||
otherInputs: event.otherInputs,
|
otherInputs: event.otherInputs,
|
||||||
roleid: event.roleId);
|
roleIdRoleName: roleIdRoleName!);
|
||||||
if (success) {
|
if (success) {
|
||||||
Fluttertoast.showToast(
|
Fluttertoast.showToast(
|
||||||
msg: "SUCCESSFULLY SAVED",
|
msg: "SUCCESSFULLY SAVED",
|
||||||
|
|
|
@ -44,6 +44,7 @@ class PerformPostLogs extends PassCheckEvent {
|
||||||
final int? stationId;
|
final int? stationId;
|
||||||
final String? destination;
|
final String? destination;
|
||||||
final double? temp;
|
final double? temp;
|
||||||
|
final String roleName;
|
||||||
final int roleId;
|
final int roleId;
|
||||||
const PerformPostLogs(
|
const PerformPostLogs(
|
||||||
{required this.checkerId,
|
{required this.checkerId,
|
||||||
|
@ -52,6 +53,7 @@ class PerformPostLogs extends PassCheckEvent {
|
||||||
required this.io,
|
required this.io,
|
||||||
required this.otherInputs,
|
required this.otherInputs,
|
||||||
required this.passerId,
|
required this.passerId,
|
||||||
|
required this.roleName,
|
||||||
required this.roleId,
|
required this.roleId,
|
||||||
required this.stationId,
|
required this.stationId,
|
||||||
required this.temp});
|
required this.temp});
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:bloc/bloc.dart';
|
import 'package:bloc/bloc.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
|
import 'package:unit2/utils/text_container.dart';
|
||||||
import '../../model/profile/basic_information/primary-information.dart';
|
import '../../model/profile/basic_information/primary-information.dart';
|
||||||
import '../../model/rbac/assigned_role.dart';
|
import '../../model/rbac/assigned_role.dart';
|
||||||
import '../../model/rbac/rbac.dart';
|
import '../../model/rbac/rbac.dart';
|
||||||
|
@ -21,27 +22,24 @@ class RoleAssignmentBloc
|
||||||
List<RBAC> roles = [];
|
List<RBAC> roles = [];
|
||||||
on<GetAssignedRoles>((event, emit) async {
|
on<GetAssignedRoles>((event, emit) async {
|
||||||
emit(RoleAssignmentLoadingState());
|
emit(RoleAssignmentLoadingState());
|
||||||
fname = event.firstname;
|
|
||||||
lname = event.lastname;
|
|
||||||
fullname = "${event.firstname} ${event.lastname}";
|
|
||||||
try {
|
try {
|
||||||
profile = await RbacRoleAssignmentServices.instance.searchUser(
|
profile = await RbacRoleAssignmentServices.instance.searchUser(
|
||||||
page: 1, name: event.firstname, lastname: event.lastname);
|
page: 1, name: event.firstname, lastname: event.lastname);
|
||||||
if (profile != null && profile?.id != null) {
|
if (profile != null && profile?.id != null) {
|
||||||
|
fname = profile!.firstName;
|
||||||
|
lname = profile!.lastName;
|
||||||
|
fullname = "${fname!} ${lname!}";
|
||||||
assignedRoles = await RbacRoleAssignmentServices.instance
|
assignedRoles = await RbacRoleAssignmentServices.instance
|
||||||
.getAssignedRoles(
|
.getAssignedRoles(firstname: event.firstname, lastname: event.lastname);
|
||||||
firstname: event.firstname, lastname: event.lastname);
|
|
||||||
|
|
||||||
if (roles.isEmpty) {
|
if (roles.isEmpty) {
|
||||||
roles = await RbacRoleServices.instance.getRbacRoles();
|
roles = await RbacRoleServices.instance.getRbacRoles();
|
||||||
}
|
}
|
||||||
emit(AssignedRoleLoaded(
|
emit(AssignedRoleLoaded(
|
||||||
assignedRoles: assignedRoles, fullname: fullname!, roles: roles));
|
assignedRoles: assignedRoles, fullname: fullname!, roles: roles));
|
||||||
} else {
|
} else {
|
||||||
emit(UserNotExistError());
|
emit(UserNotExistError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(RoleAssignmentErrorState(message: e.toString()));
|
emit(RoleAssignmentErrorState(message: e.toString()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,14 @@ import '../../utils/scanner.dart';
|
||||||
import '../../utils/text_container.dart';
|
import '../../utils/text_container.dart';
|
||||||
part 'user_event.dart';
|
part 'user_event.dart';
|
||||||
part 'user_state.dart';
|
part 'user_state.dart';
|
||||||
|
|
||||||
class UserBloc extends Bloc<UserEvent, UserState> {
|
class UserBloc extends Bloc<UserEvent, UserState> {
|
||||||
UserData? _userData;
|
UserData? _userData;
|
||||||
VersionInfo? _versionInfo;
|
VersionInfo? _versionInfo;
|
||||||
String? _apkVersion;
|
String? _apkVersion;
|
||||||
bool save = false;
|
bool save = false;
|
||||||
String? uuid;
|
String? uuid;
|
||||||
|
String? username;
|
||||||
|
String? password;
|
||||||
List<AssignedArea> establishmentPointPersonAssignedAreas = [];
|
List<AssignedArea> establishmentPointPersonAssignedAreas = [];
|
||||||
UserBloc() : super(UserInitial()) {
|
UserBloc() : super(UserInitial()) {
|
||||||
//// this event is called when opening the app to check if
|
//// this event is called when opening the app to check if
|
||||||
|
@ -37,8 +38,10 @@ class UserBloc extends Bloc<UserEvent, UserState> {
|
||||||
String apkVersion = await getAppVersion();
|
String apkVersion = await getAppVersion();
|
||||||
_apkVersion = apkVersion;
|
_apkVersion = apkVersion;
|
||||||
final String? saved = CREDENTIALS?.get('saved');
|
final String? saved = CREDENTIALS?.get('saved');
|
||||||
final String? username = CREDENTIALS?.get('username');
|
username = CREDENTIALS?.get('username');
|
||||||
final String? password = CREDENTIALS?.get('password');
|
password = CREDENTIALS?.get('password');
|
||||||
|
print(username);
|
||||||
|
print(password);
|
||||||
if (saved != null) {
|
if (saved != null) {
|
||||||
save = true;
|
save = true;
|
||||||
add(UserLogin(username: username, password: password));
|
add(UserLogin(username: username, password: password));
|
||||||
|
@ -46,8 +49,8 @@ class UserBloc extends Bloc<UserEvent, UserState> {
|
||||||
emit(VersionLoaded(
|
emit(VersionLoaded(
|
||||||
versionInfo: _versionInfo,
|
versionInfo: _versionInfo,
|
||||||
apkVersion: _apkVersion,
|
apkVersion: _apkVersion,
|
||||||
username: null,
|
username: event.username,
|
||||||
password: null));
|
password: event.password));
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(UserError(
|
emit(UserError(
|
||||||
|
@ -57,14 +60,18 @@ class UserBloc extends Bloc<UserEvent, UserState> {
|
||||||
});
|
});
|
||||||
////Loading the current version of the app
|
////Loading the current version of the app
|
||||||
on<LoadVersion>((event, emit) {
|
on<LoadVersion>((event, emit) {
|
||||||
|
username = event.username;
|
||||||
|
password = event.password;
|
||||||
emit(VersionLoaded(
|
emit(VersionLoaded(
|
||||||
versionInfo: _versionInfo,
|
versionInfo: _versionInfo,
|
||||||
apkVersion: _apkVersion,
|
apkVersion: _apkVersion,
|
||||||
username: event.username,
|
username: username,
|
||||||
password: event.password));
|
password: password));
|
||||||
});
|
});
|
||||||
////userlogin
|
////userlogin
|
||||||
on<UserLogin>((event, emit) async {
|
on<UserLogin>((event, emit) async {
|
||||||
|
username = event.username;
|
||||||
|
password = event.password;
|
||||||
try {
|
try {
|
||||||
Map<dynamic, dynamic> response = await AuthService.instance
|
Map<dynamic, dynamic> response = await AuthService.instance
|
||||||
.webLogin(username: event.username, password: event.password);
|
.webLogin(username: event.username, password: event.password);
|
||||||
|
|
|
@ -6,9 +6,11 @@ abstract class UserEvent extends Equatable {
|
||||||
}
|
}
|
||||||
|
|
||||||
class GetApkVersion extends UserEvent {
|
class GetApkVersion extends UserEvent {
|
||||||
GetApkVersion();
|
final String username;
|
||||||
|
final String password;
|
||||||
|
GetApkVersion({required this.password, required this.username});
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [];
|
List<Object> get props => [username,password];
|
||||||
}
|
}
|
||||||
|
|
||||||
class UserLogin extends UserEvent {
|
class UserLogin extends UserEvent {
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
// To parse this JSON data, do
|
||||||
|
//
|
||||||
|
// final barangay = barangayFromJson(jsonString);
|
||||||
|
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'city.dart';
|
||||||
|
import 'provinces.dart';
|
||||||
|
|
||||||
|
Barangay2 barangayFromJson(String str) => Barangay2.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String barangayToJson(Barangay2 data) => json.encode(data.toJson());
|
||||||
|
|
||||||
|
class Barangay2 {
|
||||||
|
Barangay2({
|
||||||
|
required this.brgycode,
|
||||||
|
required this.brgydesc,
|
||||||
|
required this.citymuncode,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String? brgycode;
|
||||||
|
final String? brgydesc;
|
||||||
|
final String? citymuncode;
|
||||||
|
|
||||||
|
factory Barangay2.fromJson(Map<String, dynamic> json) => Barangay2(
|
||||||
|
brgycode: json["brgycode"],
|
||||||
|
brgydesc: json["brgydesc"],
|
||||||
|
citymuncode: json['citymuncode']
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"brgycode": brgycode,
|
||||||
|
"brgydesc": brgydesc,
|
||||||
|
"citymuncode": citymuncode
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
// To parse this JSON data, do
|
||||||
|
//
|
||||||
|
// final purok = purokFromJson(jsonString);
|
||||||
|
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:unit2/model/location/barangay.dart';
|
||||||
|
|
||||||
|
Purok purokFromJson(String str) => Purok.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String purokToJson(Purok data) => json.encode(data.toJson());
|
||||||
|
|
||||||
|
class Purok {
|
||||||
|
final String code;
|
||||||
|
final String description;
|
||||||
|
final Barangay barangay;
|
||||||
|
|
||||||
|
Purok({
|
||||||
|
required this.code,
|
||||||
|
required this.description,
|
||||||
|
required this.barangay,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Purok.fromJson(Map<String, dynamic> json) => Purok(
|
||||||
|
code: json["code"],
|
||||||
|
description: json["description"],
|
||||||
|
barangay: Barangay.fromJson(json["barangay"]),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"code": code,
|
||||||
|
"description": description,
|
||||||
|
"barangay": barangay.toJson(),
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
|
||||||
|
|
||||||
|
import 'package:unit2/model/location/barangay2.dart';
|
||||||
|
|
||||||
|
class Purok2 {
|
||||||
|
final String purokid;
|
||||||
|
final String purokdesc;
|
||||||
|
final Barangay2? brgy;
|
||||||
|
final dynamic purokLeader;
|
||||||
|
final bool writelock;
|
||||||
|
final dynamic recordsignature;
|
||||||
|
|
||||||
|
Purok2({
|
||||||
|
required this.purokid,
|
||||||
|
required this.purokdesc,
|
||||||
|
required this.brgy,
|
||||||
|
required this.purokLeader,
|
||||||
|
required this.writelock,
|
||||||
|
required this.recordsignature,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Purok2.fromJson(Map<String, dynamic> json) => Purok2(
|
||||||
|
purokid: json["purokid"],
|
||||||
|
purokdesc: json["purokdesc"],
|
||||||
|
brgy: json['brgy'] == null?null: Barangay2.fromJson(json["brgy"]),
|
||||||
|
purokLeader: json["purok_leader"],
|
||||||
|
writelock: json["writelock"],
|
||||||
|
recordsignature: json["recordsignature"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"purokid": purokid,
|
||||||
|
"purokdesc": purokdesc,
|
||||||
|
"brgy": brgy?.toJson(),
|
||||||
|
"purok_leader": purokLeader,
|
||||||
|
"writelock": writelock,
|
||||||
|
"recordsignature": recordsignature,
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
import 'package:unit2/model/rbac/assigned_role.dart';
|
||||||
|
import 'package:unit2/model/rbac/rbac.dart';
|
||||||
|
|
||||||
|
import '../roles/pass_check/assign_role_area_type.dart';
|
||||||
|
|
||||||
|
class UserAssignedArea {
|
||||||
|
AssignedRole? assignedRole;
|
||||||
|
AssignRoleAreaType? assignedRoleAreaType;
|
||||||
|
dynamic assignedArea;
|
||||||
|
|
||||||
|
UserAssignedArea({
|
||||||
|
required this.assignedRole,
|
||||||
|
required this.assignedRoleAreaType,
|
||||||
|
required this.assignedArea,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory UserAssignedArea.fromJson(Map<String, dynamic> json) => UserAssignedArea(
|
||||||
|
assignedRole: json['assigned_role'] == null? null: AssignedRole.fromJson(json["assigned_role"]),
|
||||||
|
assignedRoleAreaType: json['assigned_role_area_type'] == null? null : AssignRoleAreaType.fromJson(json["assigned_role_area_type"]),
|
||||||
|
assignedArea: json["assigned_area"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"assigned_role": assignedRole?.toJson(),
|
||||||
|
"assigned_role_area_type": assignedRoleAreaType?.toJson(),
|
||||||
|
"assigned_area": assignedArea,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,15 @@
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:unit2/model/rbac/rbac.dart';
|
||||||
|
|
||||||
AssignedRole assignedRoleFromJson(String str) => AssignedRole.fromJson(json.decode(str));
|
AssignedRole assignedRoleFromJson(String str) => AssignedRole.fromJson(json.decode(str));
|
||||||
|
|
||||||
String assignedRoleToJson(AssignedRole data) => json.encode(data.toJson());
|
String assignedRoleToJson(AssignedRole data) => json.encode(data.toJson());
|
||||||
|
|
||||||
class AssignedRole {
|
class AssignedRole {
|
||||||
final int? id;
|
final int? id;
|
||||||
final Role? role;
|
final RBAC? role;
|
||||||
final CreatedBy? user;
|
final CreatedBy? user;
|
||||||
final DateTime? createdAt;
|
final DateTime? createdAt;
|
||||||
final DateTime? updatedAt;
|
final DateTime? updatedAt;
|
||||||
|
@ -30,7 +32,7 @@ class AssignedRole {
|
||||||
|
|
||||||
factory AssignedRole.fromJson(Map<String, dynamic> json) => AssignedRole(
|
factory AssignedRole.fromJson(Map<String, dynamic> json) => AssignedRole(
|
||||||
id: json["id"],
|
id: json["id"],
|
||||||
role: json['role'] == null?null: Role.fromJson(json["role"]),
|
role: json['role'] == null?null: RBAC.fromJson(json["role"]),
|
||||||
user: json['role'] == null?null: CreatedBy.fromJson(json["user"]),
|
user: json['role'] == null?null: CreatedBy.fromJson(json["user"]),
|
||||||
createdAt:json["created_at"] == null?null: DateTime.parse(json["created_at"]),
|
createdAt:json["created_at"] == null?null: DateTime.parse(json["created_at"]),
|
||||||
updatedAt: json["updated_at"] == null?null: DateTime.parse(json["updated_at"]),
|
updatedAt: json["updated_at"] == null?null: DateTime.parse(json["updated_at"]),
|
||||||
|
@ -84,47 +86,3 @@ class CreatedBy {
|
||||||
"is_active": isActive,
|
"is_active": isActive,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
class Role {
|
|
||||||
final int id;
|
|
||||||
final String name;
|
|
||||||
final String slug;
|
|
||||||
final String shorthand;
|
|
||||||
final DateTime createdAt;
|
|
||||||
final DateTime updatedAt;
|
|
||||||
final CreatedBy createdBy;
|
|
||||||
final CreatedBy updatedBy;
|
|
||||||
|
|
||||||
Role({
|
|
||||||
required this.id,
|
|
||||||
required this.name,
|
|
||||||
required this.slug,
|
|
||||||
required this.shorthand,
|
|
||||||
required this.createdAt,
|
|
||||||
required this.updatedAt,
|
|
||||||
required this.createdBy,
|
|
||||||
required this.updatedBy,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory Role.fromJson(Map<String, dynamic> json) => Role(
|
|
||||||
id: json["id"],
|
|
||||||
name: json["name"],
|
|
||||||
slug: json["slug"],
|
|
||||||
shorthand: json["shorthand"],
|
|
||||||
createdAt: DateTime.parse(json["created_at"]),
|
|
||||||
updatedAt: DateTime.parse(json["updated_at"]),
|
|
||||||
createdBy: CreatedBy.fromJson(json["created_by"]),
|
|
||||||
updatedBy: CreatedBy.fromJson(json["updated_by"]),
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
|
||||||
"id": id,
|
|
||||||
"name": name,
|
|
||||||
"slug": slug,
|
|
||||||
"shorthand": shorthand,
|
|
||||||
"created_at": createdAt.toIso8601String(),
|
|
||||||
"updated_at": updatedAt.toIso8601String(),
|
|
||||||
"created_by": createdBy.toJson(),
|
|
||||||
"updated_by": updatedBy.toJson(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import 'barangay_assign_area.dart';
|
import 'barangay_assign_area.dart';
|
||||||
|
|
||||||
class Purok {
|
class PassCheckPurok {
|
||||||
final String? purokid;
|
final String? purokid;
|
||||||
final String? purokdesc;
|
final String? purokdesc;
|
||||||
final BaragayAssignArea? brgy;
|
final BaragayAssignArea? brgy;
|
||||||
|
@ -10,7 +10,7 @@ class Purok {
|
||||||
final bool? writelock;
|
final bool? writelock;
|
||||||
final dynamic recordsignature;
|
final dynamic recordsignature;
|
||||||
|
|
||||||
Purok({
|
PassCheckPurok({
|
||||||
required this.purokid,
|
required this.purokid,
|
||||||
required this.purokdesc,
|
required this.purokdesc,
|
||||||
required this.brgy,
|
required this.brgy,
|
||||||
|
@ -19,7 +19,7 @@ class Purok {
|
||||||
required this.recordsignature,
|
required this.recordsignature,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory Purok.fromJson(Map<String, dynamic> json) => Purok(
|
factory PassCheckPurok.fromJson(Map<String, dynamic> json) => PassCheckPurok(
|
||||||
purokid: json["purokid"],
|
purokid: json["purokid"],
|
||||||
purokdesc: json["purokdesc"],
|
purokdesc: json["purokdesc"],
|
||||||
brgy: json["brgy"]==null?null:BaragayAssignArea.fromJson(json["brgy"]),
|
brgy: json["brgy"]==null?null:BaragayAssignArea.fromJson(json["brgy"]),
|
||||||
|
|
|
@ -24,6 +24,7 @@ class EditBasicProfileInfoScreen extends StatefulWidget {
|
||||||
State<EditBasicProfileInfoScreen> createState() =>
|
State<EditBasicProfileInfoScreen> createState() =>
|
||||||
_EditBasicProfileInfoScreenState();
|
_EditBasicProfileInfoScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
final bdayController = TextEditingController();
|
final bdayController = TextEditingController();
|
||||||
ProfileOtherInfo? selectedIndigency;
|
ProfileOtherInfo? selectedIndigency;
|
||||||
ProfileOtherInfo? selectedEthnicity;
|
ProfileOtherInfo? selectedEthnicity;
|
||||||
|
@ -36,13 +37,13 @@ String? selectedStatus;
|
||||||
String? selectedExtension;
|
String? selectedExtension;
|
||||||
final _formKey = GlobalKey<FormBuilderState>();
|
final _formKey = GlobalKey<FormBuilderState>();
|
||||||
|
|
||||||
|
|
||||||
class _EditBasicProfileInfoScreenState
|
class _EditBasicProfileInfoScreenState
|
||||||
extends State<EditBasicProfileInfoScreen> {
|
extends State<EditBasicProfileInfoScreen> {
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<ProfileBloc, ProfileState>(
|
return BlocBuilder<ProfileBloc, ProfileState>(
|
||||||
|
@ -52,7 +53,8 @@ class _EditBasicProfileInfoScreenState
|
||||||
selectedSex = state.sexes.firstWhere((element) =>
|
selectedSex = state.sexes.firstWhere((element) =>
|
||||||
element.toLowerCase() ==
|
element.toLowerCase() ==
|
||||||
state.primaryInformation.sex!.toLowerCase());
|
state.primaryInformation.sex!.toLowerCase());
|
||||||
if (state.primaryInformation.bloodType != null && state.primaryInformation.bloodType != "N/A") {
|
if (state.primaryInformation.bloodType != null &&
|
||||||
|
state.primaryInformation.bloodType != "N/A") {
|
||||||
selectedBloodType = state.bloodTypes.firstWhere((element) =>
|
selectedBloodType = state.bloodTypes.firstWhere((element) =>
|
||||||
element.toLowerCase() ==
|
element.toLowerCase() ==
|
||||||
state.primaryInformation.bloodType?.toLowerCase());
|
state.primaryInformation.bloodType?.toLowerCase());
|
||||||
|
@ -99,9 +101,6 @@ class _EditBasicProfileInfoScreenState
|
||||||
state.primaryInformation.disability!.toLowerCase());
|
state.primaryInformation.disability!.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32),
|
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32),
|
||||||
child: FormBuilder(
|
child: FormBuilder(
|
||||||
|
@ -116,9 +115,7 @@ class _EditBasicProfileInfoScreenState
|
||||||
),
|
),
|
||||||
FormBuilderTextField(
|
FormBuilderTextField(
|
||||||
name: "lastname",
|
name: "lastname",
|
||||||
inputFormatters: [
|
inputFormatters: [UpperCaseTextFormatter()],
|
||||||
UpperCaseTextFormatter()
|
|
||||||
],
|
|
||||||
initialValue: state.primaryInformation.lastName,
|
initialValue: state.primaryInformation.lastName,
|
||||||
decoration: normalTextFieldStyle("Last name *", ""),
|
decoration: normalTextFieldStyle("Last name *", ""),
|
||||||
validator: FormBuilderValidators.required(
|
validator: FormBuilderValidators.required(
|
||||||
|
@ -129,9 +126,7 @@ class _EditBasicProfileInfoScreenState
|
||||||
),
|
),
|
||||||
FormBuilderTextField(
|
FormBuilderTextField(
|
||||||
name: "firstname",
|
name: "firstname",
|
||||||
inputFormatters: [
|
inputFormatters: [UpperCaseTextFormatter()],
|
||||||
UpperCaseTextFormatter()
|
|
||||||
],
|
|
||||||
initialValue: state.primaryInformation.firstName,
|
initialValue: state.primaryInformation.firstName,
|
||||||
decoration: normalTextFieldStyle("First name *", ""),
|
decoration: normalTextFieldStyle("First name *", ""),
|
||||||
validator: FormBuilderValidators.required(
|
validator: FormBuilderValidators.required(
|
||||||
|
@ -146,12 +141,12 @@ class _EditBasicProfileInfoScreenState
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: FormBuilderTextField(
|
child: FormBuilderTextField(
|
||||||
inputFormatters: [
|
inputFormatters: [UpperCaseTextFormatter()],
|
||||||
UpperCaseTextFormatter()
|
|
||||||
],
|
|
||||||
name: "middlename",
|
name: "middlename",
|
||||||
initialValue: state.primaryInformation.middleName??'',
|
initialValue:
|
||||||
decoration: normalTextFieldStyle("Middle name", ""),
|
state.primaryInformation.middleName ?? '',
|
||||||
|
decoration:
|
||||||
|
normalTextFieldStyle("Middle name", ""),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
|
@ -164,13 +159,11 @@ class _EditBasicProfileInfoScreenState
|
||||||
value: selectedExtension,
|
value: selectedExtension,
|
||||||
decoration:
|
decoration:
|
||||||
normalTextFieldStyle("Name Extension", ""),
|
normalTextFieldStyle("Name Extension", ""),
|
||||||
|
|
||||||
items: state.extensions
|
items: state.extensions
|
||||||
.map((element) => DropdownMenuItem<String>(
|
.map((element) => DropdownMenuItem<String>(
|
||||||
value: element, child: Text(element)))
|
value: element, child: Text(element)))
|
||||||
.toList(),
|
.toList(),
|
||||||
onChanged: (e) {
|
onChanged: (e) {
|
||||||
|
|
||||||
selectedExtension = e;
|
selectedExtension = e;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -193,8 +186,9 @@ class _EditBasicProfileInfoScreenState
|
||||||
errorText: "This field is required"),
|
errorText: "This field is required"),
|
||||||
timeHintText: "Birthdate",
|
timeHintText: "Birthdate",
|
||||||
decoration:
|
decoration:
|
||||||
normalTextFieldStyle("Birthdate *", "*").copyWith(
|
normalTextFieldStyle("Birthdate *", "*")
|
||||||
prefixIcon: const Icon(
|
.copyWith(
|
||||||
|
prefixIcon: const Icon(
|
||||||
Icons.date_range,
|
Icons.date_range,
|
||||||
color: Colors.black87,
|
color: Colors.black87,
|
||||||
)),
|
)),
|
||||||
|
@ -206,7 +200,7 @@ class _EditBasicProfileInfoScreenState
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
width: 10,
|
width: 10,
|
||||||
),
|
),
|
||||||
|
|
||||||
////sex
|
////sex
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
|
@ -221,7 +215,7 @@ class _EditBasicProfileInfoScreenState
|
||||||
value: element, child: Text(element)))
|
value: element, child: Text(element)))
|
||||||
.toList(),
|
.toList(),
|
||||||
onChanged: (e) {
|
onChanged: (e) {
|
||||||
selectedSex= e;
|
selectedSex = e;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -238,9 +232,10 @@ class _EditBasicProfileInfoScreenState
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: FormBuilderDropdown<String>(
|
child: FormBuilderDropdown<String>(
|
||||||
initialValue: selectedBloodType,
|
initialValue: selectedBloodType,
|
||||||
validator: FormBuilderValidators.required(
|
validator: FormBuilderValidators.required(
|
||||||
errorText: "This field is required"),
|
errorText: "This field is required"),
|
||||||
decoration: normalTextFieldStyle("Blood type *", ""),
|
decoration:
|
||||||
|
normalTextFieldStyle("Blood type *", ""),
|
||||||
name: "bloodtype",
|
name: "bloodtype",
|
||||||
items: state.bloodTypes
|
items: state.bloodTypes
|
||||||
.map((element) => DropdownMenuItem<String>(
|
.map((element) => DropdownMenuItem<String>(
|
||||||
|
@ -259,8 +254,9 @@ class _EditBasicProfileInfoScreenState
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: FormBuilderDropdown<String>(
|
child: FormBuilderDropdown<String>(
|
||||||
initialValue: selectedStatus,
|
initialValue: selectedStatus,
|
||||||
decoration: normalTextFieldStyle("Civil status *", ""),
|
decoration:
|
||||||
validator: FormBuilderValidators.required(
|
normalTextFieldStyle("Civil status *", ""),
|
||||||
|
validator: FormBuilderValidators.required(
|
||||||
errorText: "This field is required"),
|
errorText: "This field is required"),
|
||||||
name: "extension",
|
name: "extension",
|
||||||
items: state.civilStatus
|
items: state.civilStatus
|
||||||
|
@ -305,11 +301,12 @@ class _EditBasicProfileInfoScreenState
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: FormBuilderTextField(
|
child: FormBuilderTextField(
|
||||||
name: "height",
|
name: "height",
|
||||||
validator: numericRequired,
|
validator: numericRequired,
|
||||||
initialValue: state.primaryInformation.heightM
|
initialValue: state.primaryInformation.heightM
|
||||||
.toString()
|
.toString()
|
||||||
.toString(),
|
.toString(),
|
||||||
decoration: normalTextFieldStyle("Height (Meter) *", ""),
|
decoration: normalTextFieldStyle(
|
||||||
|
"Height (Meter) *", ""),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
|
@ -317,13 +314,13 @@ class _EditBasicProfileInfoScreenState
|
||||||
),
|
),
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
|
|
||||||
child: FormBuilderTextField(
|
child: FormBuilderTextField(
|
||||||
validator: numericRequired,
|
validator: numericRequired,
|
||||||
name: "weigth",
|
name: "weigth",
|
||||||
initialValue:
|
initialValue: state.primaryInformation.weightKg!
|
||||||
state.primaryInformation.weightKg!.toString(),
|
.toString(),
|
||||||
decoration: normalTextFieldStyle("Weight (Kg) *", ""),
|
decoration:
|
||||||
|
normalTextFieldStyle("Weight (Kg) *", ""),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
|
@ -338,7 +335,8 @@ class _EditBasicProfileInfoScreenState
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: FormBuilderTextField(
|
child: FormBuilderTextField(
|
||||||
name: "prefix",
|
name: "prefix",
|
||||||
initialValue: state.primaryInformation.titlePrefix
|
initialValue: state
|
||||||
|
.primaryInformation.titlePrefix
|
||||||
.toString()
|
.toString()
|
||||||
.toString(),
|
.toString(),
|
||||||
decoration: normalTextFieldStyle(
|
decoration: normalTextFieldStyle(
|
||||||
|
@ -352,7 +350,8 @@ class _EditBasicProfileInfoScreenState
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: FormBuilderTextField(
|
child: FormBuilderTextField(
|
||||||
name: "suffix",
|
name: "suffix",
|
||||||
initialValue: state.primaryInformation.titleSuffix,
|
initialValue:
|
||||||
|
state.primaryInformation.titleSuffix,
|
||||||
decoration: normalTextFieldStyle(
|
decoration: normalTextFieldStyle(
|
||||||
"Title Suffix", "PhD.,MD.,MS.,CE"),
|
"Title Suffix", "PhD.,MD.,MS.,CE"),
|
||||||
),
|
),
|
||||||
|
@ -368,10 +367,11 @@ class _EditBasicProfileInfoScreenState
|
||||||
////Indigency
|
////Indigency
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: DropdownButtonFormField<ProfileOtherInfo>(
|
child: DropdownButtonFormField<ProfileOtherInfo>(
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
value: selectedIndigency,
|
value: selectedIndigency,
|
||||||
decoration: normalTextFieldStyle("Indigency", ""),
|
decoration:
|
||||||
|
normalTextFieldStyle("Indigency", ""),
|
||||||
items: state.indigenous
|
items: state.indigenous
|
||||||
.map((element) =>
|
.map((element) =>
|
||||||
DropdownMenuItem<ProfileOtherInfo>(
|
DropdownMenuItem<ProfileOtherInfo>(
|
||||||
|
@ -392,7 +392,8 @@ class _EditBasicProfileInfoScreenState
|
||||||
child: DropdownButtonFormField<ProfileOtherInfo>(
|
child: DropdownButtonFormField<ProfileOtherInfo>(
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
value: selectedEthnicity,
|
value: selectedEthnicity,
|
||||||
decoration: normalTextFieldStyle("Ethnicity", ""),
|
decoration:
|
||||||
|
normalTextFieldStyle("Ethnicity", ""),
|
||||||
items: state.ethnicity
|
items: state.ethnicity
|
||||||
.map((element) =>
|
.map((element) =>
|
||||||
DropdownMenuItem<ProfileOtherInfo>(
|
DropdownMenuItem<ProfileOtherInfo>(
|
||||||
|
@ -402,8 +403,7 @@ class _EditBasicProfileInfoScreenState
|
||||||
onChanged: (e) {
|
onChanged: (e) {
|
||||||
selectedEthnicity = e;
|
selectedEthnicity = e;
|
||||||
print(selectedEthnicity!.name);
|
print(selectedEthnicity!.name);
|
||||||
print(selectedEthnicity!
|
print(selectedEthnicity!.id);
|
||||||
.id);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -421,7 +421,8 @@ class _EditBasicProfileInfoScreenState
|
||||||
child: DropdownButtonFormField<ProfileOtherInfo>(
|
child: DropdownButtonFormField<ProfileOtherInfo>(
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
value: selectedReligion,
|
value: selectedReligion,
|
||||||
decoration: normalTextFieldStyle("Religion", ""),
|
decoration:
|
||||||
|
normalTextFieldStyle("Religion", ""),
|
||||||
items: state.religion
|
items: state.religion
|
||||||
.map((element) =>
|
.map((element) =>
|
||||||
DropdownMenuItem<ProfileOtherInfo>(
|
DropdownMenuItem<ProfileOtherInfo>(
|
||||||
|
@ -440,10 +441,10 @@ class _EditBasicProfileInfoScreenState
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: DropdownButtonFormField<ProfileOtherInfo>(
|
child: DropdownButtonFormField<ProfileOtherInfo>(
|
||||||
|
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
value: selectedDisability,
|
value: selectedDisability,
|
||||||
decoration: normalTextFieldStyle("Disability", ""),
|
decoration:
|
||||||
|
normalTextFieldStyle("Disability", ""),
|
||||||
items: state.disability
|
items: state.disability
|
||||||
.map((element) =>
|
.map((element) =>
|
||||||
DropdownMenuItem<ProfileOtherInfo>(
|
DropdownMenuItem<ProfileOtherInfo>(
|
||||||
|
@ -464,33 +465,36 @@ class _EditBasicProfileInfoScreenState
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: 60,
|
height: 60,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
style:
|
style: mainBtnStyle(
|
||||||
mainBtnStyle(primary, Colors.transparent, second),
|
primary, Colors.transparent, second),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (_formKey.currentState!.saveAndValidate()) {
|
if (_formKey.currentState!.saveAndValidate()) {
|
||||||
String lastName =
|
String lastName =
|
||||||
_formKey.currentState!.value['lastname'];
|
_formKey.currentState!.value['lastname'];
|
||||||
String firstName =
|
String firstName =
|
||||||
_formKey.currentState!.value['firstname'];
|
_formKey.currentState!.value['firstname'];
|
||||||
String? middleName =
|
String? middleName = _formKey
|
||||||
_formKey.currentState?.value['middlename'];
|
.currentState?.value['middlename'];
|
||||||
String? pref =
|
String? pref =
|
||||||
_formKey.currentState?.value['prefix'];
|
_formKey.currentState?.value['prefix'];
|
||||||
String suf = _formKey.currentState?.value['suffix'];
|
String suf =
|
||||||
|
_formKey.currentState?.value['suffix'];
|
||||||
DateTime birthdate =
|
DateTime birthdate =
|
||||||
DateTime.parse(bdayController.text);
|
DateTime.parse(bdayController.text);
|
||||||
double? hM =
|
double? hM =
|
||||||
_formKey.currentState!.value['height'] == null
|
_formKey.currentState!.value['height'] ==
|
||||||
|
null
|
||||||
? null
|
? null
|
||||||
: double.tryParse(
|
: double.tryParse(_formKey
|
||||||
_formKey.currentState?.value['height']);
|
.currentState?.value['height']);
|
||||||
double? wKg =
|
double? wKg =
|
||||||
_formKey.currentState!.value['weigth'] == null
|
_formKey.currentState!.value['weigth'] ==
|
||||||
|
null
|
||||||
? null
|
? null
|
||||||
: double.tryParse(
|
: double.tryParse(_formKey
|
||||||
_formKey.currentState?.value['weigth']);
|
.currentState?.value['weigth']);
|
||||||
Profile primaryInformation = Profile(
|
Profile primaryInformation = Profile(
|
||||||
webuserId: null,
|
webuserId: null,
|
||||||
id: state.primaryInformation.id,
|
id: state.primaryInformation.id,
|
||||||
lastName: lastName,
|
lastName: lastName,
|
||||||
firstName: firstName,
|
firstName: firstName,
|
||||||
|
@ -499,14 +503,21 @@ class _EditBasicProfileInfoScreenState
|
||||||
sex: selectedSex,
|
sex: selectedSex,
|
||||||
birthdate: birthdate,
|
birthdate: birthdate,
|
||||||
civilStatus: selectedStatus,
|
civilStatus: selectedStatus,
|
||||||
bloodType: selectedBloodType =="NONE"?null:selectedBloodType,
|
bloodType: selectedBloodType == "NONE"
|
||||||
|
? null
|
||||||
|
: selectedBloodType,
|
||||||
heightM: hM,
|
heightM: hM,
|
||||||
weightKg: wKg,
|
weightKg: wKg,
|
||||||
photoPath: state.primaryInformation.photoPath,
|
photoPath:
|
||||||
esigPath: state.primaryInformation.esigPath,
|
state.primaryInformation.photoPath,
|
||||||
maidenName: state.primaryInformation.maidenName,
|
esigPath:
|
||||||
deceased: state.primaryInformation.deceased,
|
state.primaryInformation.esigPath,
|
||||||
uuidQrcode: state.primaryInformation.uuidQrcode,
|
maidenName:
|
||||||
|
state.primaryInformation.maidenName,
|
||||||
|
deceased:
|
||||||
|
state.primaryInformation.deceased,
|
||||||
|
uuidQrcode:
|
||||||
|
state.primaryInformation.uuidQrcode,
|
||||||
titlePrefix: pref,
|
titlePrefix: pref,
|
||||||
titleSuffix: suf,
|
titleSuffix: suf,
|
||||||
showTitleId:
|
showTitleId:
|
||||||
|
@ -525,7 +536,8 @@ class _EditBasicProfileInfoScreenState
|
||||||
genderId: selectedGender?.id,
|
genderId: selectedGender?.id,
|
||||||
indigencyId: selectedIndigency?.id,
|
indigencyId: selectedIndigency?.id,
|
||||||
profileId: widget.profileId,
|
profileId: widget.profileId,
|
||||||
profileInformation: primaryInformation,
|
profileInformation:
|
||||||
|
primaryInformation,
|
||||||
religionId: selectedReligion?.id,
|
religionId: selectedReligion?.id,
|
||||||
token: widget.token));
|
token: widget.token));
|
||||||
}
|
}
|
||||||
|
@ -540,7 +552,7 @@ class _EditBasicProfileInfoScreenState
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Container();
|
return Container();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||||
|
@ -6,6 +5,8 @@ import 'package:flutter_progress_hud/flutter_progress_hud.dart';
|
||||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
||||||
|
import 'package:unit2/bloc/user/user_bloc.dart';
|
||||||
|
import 'package:unit2/model/profile/basic_information/primary-information.dart';
|
||||||
import 'package:unit2/screens/profile/components/basic_information/edit_basic_info_modal.dart';
|
import 'package:unit2/screens/profile/components/basic_information/edit_basic_info_modal.dart';
|
||||||
import 'package:unit2/theme-data.dart/colors.dart';
|
import 'package:unit2/theme-data.dart/colors.dart';
|
||||||
import 'package:unit2/theme-data.dart/form-style.dart';
|
import 'package:unit2/theme-data.dart/form-style.dart';
|
||||||
|
@ -30,6 +31,7 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
bool enabled = false;
|
bool enabled = false;
|
||||||
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
|
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
|
||||||
|
Profile? profile;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: context.watch<ProfileBloc>().state
|
title: context.watch<ProfileBloc>().state
|
||||||
|
@ -62,300 +64,420 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
|
||||||
padding: const EdgeInsets.all(24),
|
padding: const EdgeInsets.all(24),
|
||||||
backgroundColor: Colors.black87,
|
backgroundColor: Colors.black87,
|
||||||
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
|
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
|
||||||
child: BlocConsumer<ProfileBloc, ProfileState>(
|
child: BlocBuilder<UserBloc, UserState>(
|
||||||
listener: (context, state) {
|
|
||||||
if (state is BasicPrimaryInformationLoadingState) {
|
|
||||||
final progress = ProgressHUD.of(context);
|
|
||||||
progress!.showWithText("Please wait...");
|
|
||||||
}
|
|
||||||
if (state is BasicInformationProfileLoaded ||
|
|
||||||
state is BasicInformationEditingState ||
|
|
||||||
state is BasicPrimaryInformationErrorState ||
|
|
||||||
state is BasicProfileInfoEditedState) {
|
|
||||||
final progress = ProgressHUD.of(context);
|
|
||||||
progress!.dismiss();
|
|
||||||
}
|
|
||||||
if (state is BasicProfileInfoEditedState) {
|
|
||||||
if (state.response['success']) {
|
|
||||||
successAlert(context, "Updated Successfull!",
|
|
||||||
state.response['message'], () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
context.read<ProfileBloc>().add(LoadBasicPrimaryInfo());
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
errorAlert(context, "Update Failed",
|
|
||||||
"Something went wrong. Please try again.", () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
context.read<ProfileBloc>().add(LoadBasicPrimaryInfo());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state is BasicInformationProfileLoaded) {
|
if (state is UserLoggedIn) {
|
||||||
return Container(
|
return BlocConsumer<ProfileBloc, ProfileState>(
|
||||||
padding:
|
listener: (context, state) {
|
||||||
const EdgeInsets.symmetric(vertical: 24, horizontal: 24),
|
if (state is BasicPrimaryInformationLoadingState) {
|
||||||
child: Column(
|
final progress = ProgressHUD.of(context);
|
||||||
children: [
|
progress!.showWithText("Please wait...");
|
||||||
const SizedBox(
|
}
|
||||||
height: 28,
|
if (state is BasicInformationProfileLoaded ||
|
||||||
),
|
state is BasicInformationEditingState ||
|
||||||
FormBuilderTextField(
|
state is BasicPrimaryInformationErrorState ||
|
||||||
enabled: enabled,
|
state is BasicProfileInfoEditedState) {
|
||||||
name: lastname,
|
final progress = ProgressHUD.of(context);
|
||||||
initialValue: state.primaryBasicInformation.lastName!,
|
progress!.dismiss();
|
||||||
decoration: normalTextFieldStyle("Last name", ""),
|
}
|
||||||
),
|
if (state is BasicProfileInfoEditedState) {
|
||||||
const SizedBox(
|
profile = Profile.fromJson(state.response['data']);
|
||||||
height: 15,
|
if (state.response['success']) {
|
||||||
),
|
successAlert(context, "Updated Successfull!",
|
||||||
FormBuilderTextField(
|
state.response['message'], () {
|
||||||
enabled: enabled,
|
Navigator.of(context).pop();
|
||||||
name: firstname,
|
context
|
||||||
initialValue: state.primaryBasicInformation.firstName!,
|
.read<ProfileBloc>()
|
||||||
decoration: normalTextFieldStyle("First name", ""),
|
.add(LoadBasicPrimaryInfo());
|
||||||
),
|
});
|
||||||
const SizedBox(
|
} else {
|
||||||
height: 15,
|
errorAlert(context, "Update Failed",
|
||||||
),
|
"Something went wrong. Please try again.", () {
|
||||||
SizedBox(
|
Navigator.of(context).pop();
|
||||||
width: screenWidth,
|
context
|
||||||
child: Row(children: [
|
.read<ProfileBloc>()
|
||||||
Flexible(
|
.add(LoadBasicPrimaryInfo());
|
||||||
flex: 2,
|
});
|
||||||
child: FormBuilderTextField(
|
}
|
||||||
enabled: enabled,
|
}
|
||||||
name: middlename,
|
},
|
||||||
initialValue: state.primaryBasicInformation.middleName??''
|
builder: (context, state) {
|
||||||
,
|
if (state is BasicInformationProfileLoaded) {
|
||||||
decoration:
|
profile = state.primaryBasicInformation;
|
||||||
normalTextFieldStyle("Middle name", ""),
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 24, horizontal: 24),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
const SizedBox(
|
||||||
|
height: 28,
|
||||||
),
|
),
|
||||||
),
|
FormBuilderTextField(
|
||||||
const SizedBox(
|
enabled: false,
|
||||||
width: 10,
|
name: lastname,
|
||||||
),
|
|
||||||
Flexible(
|
|
||||||
flex: 1,
|
|
||||||
child: FormBuilderTextField(
|
|
||||||
enabled: enabled,
|
|
||||||
name: extensionName,
|
|
||||||
initialValue: state.primaryBasicInformation
|
|
||||||
.nameExtension ??= 'N/A',
|
|
||||||
decoration:
|
|
||||||
normalTextFieldStyle("Name extension", ""),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 15,
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: screenWidth,
|
|
||||||
child: Row(children: [
|
|
||||||
Flexible(
|
|
||||||
flex: 1,
|
|
||||||
child: FormBuilderTextField(
|
|
||||||
enabled: enabled,
|
|
||||||
name: extensionName,
|
|
||||||
initialValue: dteFormat2.format(
|
|
||||||
state.primaryBasicInformation.birthdate!),
|
|
||||||
decoration:
|
|
||||||
normalTextFieldStyle("Birth date", ""),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
width: 10,
|
|
||||||
),
|
|
||||||
Flexible(
|
|
||||||
flex: 1,
|
|
||||||
child: FormBuilderTextField(
|
|
||||||
enabled: enabled,
|
|
||||||
name: sex,
|
|
||||||
initialValue: state.primaryBasicInformation.sex!,
|
|
||||||
decoration: normalTextFieldStyle("Sex", ""),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 15,
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: screenWidth,
|
|
||||||
child: Row(children: [
|
|
||||||
Flexible(
|
|
||||||
flex: 1,
|
|
||||||
child: FormBuilderTextField(
|
|
||||||
enabled: enabled,
|
|
||||||
name: "bloodType",
|
|
||||||
initialValue:
|
initialValue:
|
||||||
state.primaryBasicInformation.bloodType!,
|
state.primaryBasicInformation.lastName!,
|
||||||
decoration:
|
style: const TextStyle(color: Colors.black),
|
||||||
normalTextFieldStyle("Blood type", ""),
|
decoration: normalTextFieldStyle("Last name", "")
|
||||||
|
.copyWith(
|
||||||
|
disabledBorder:
|
||||||
|
const OutlineInputBorder(),
|
||||||
|
labelStyle:
|
||||||
|
const TextStyle(color: Colors.black)),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(
|
||||||
const SizedBox(
|
height: 15,
|
||||||
width: 10,
|
),
|
||||||
),
|
FormBuilderTextField(
|
||||||
Flexible(
|
|
||||||
flex: 1,
|
|
||||||
child: FormBuilderTextField(
|
|
||||||
enabled: enabled,
|
enabled: enabled,
|
||||||
name: "civilStatus",
|
name: firstname,
|
||||||
initialValue:
|
initialValue:
|
||||||
state.primaryBasicInformation.civilStatus!,
|
state.primaryBasicInformation.firstName!,
|
||||||
decoration:
|
style: const TextStyle(color: Colors.black),
|
||||||
normalTextFieldStyle("Civil Status", ""),
|
decoration: normalTextFieldStyle("First name", "")
|
||||||
|
.copyWith(
|
||||||
|
disabledBorder:
|
||||||
|
const OutlineInputBorder(),
|
||||||
|
labelStyle:
|
||||||
|
const TextStyle(color: Colors.black)),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(
|
||||||
const SizedBox(
|
height: 15,
|
||||||
width: 10,
|
|
||||||
),
|
|
||||||
Flexible(
|
|
||||||
flex: 1,
|
|
||||||
child: FormBuilderTextField(
|
|
||||||
enabled: enabled,
|
|
||||||
name: "gender",
|
|
||||||
initialValue: state
|
|
||||||
.primaryBasicInformation.gender ??= "N/A",
|
|
||||||
decoration: normalTextFieldStyle("Gender", ""),
|
|
||||||
),
|
),
|
||||||
),
|
SizedBox(
|
||||||
]),
|
width: screenWidth,
|
||||||
),
|
child: Row(children: [
|
||||||
const SizedBox(
|
Flexible(
|
||||||
height: 15,
|
flex: 2,
|
||||||
),
|
child: FormBuilderTextField(
|
||||||
SizedBox(
|
enabled: enabled,
|
||||||
width: screenWidth,
|
name: middlename,
|
||||||
child: Row(children: [
|
initialValue: state.primaryBasicInformation
|
||||||
Flexible(
|
.middleName ??
|
||||||
flex: 1,
|
'',
|
||||||
child: FormBuilderTextField(
|
style: const TextStyle(color: Colors.black),
|
||||||
maxLines: 2,
|
decoration:
|
||||||
enabled: enabled,
|
normalTextFieldStyle("Middle name", "")
|
||||||
name: height,
|
.copyWith(
|
||||||
initialValue: state
|
disabledBorder:
|
||||||
.primaryBasicInformation.heightM!
|
const OutlineInputBorder(),
|
||||||
.toString(),
|
labelStyle: const TextStyle(
|
||||||
decoration: normalTextFieldStyle("Height", ""),
|
color: Colors.black)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 10,
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
flex: 1,
|
||||||
|
child: FormBuilderTextField(
|
||||||
|
enabled: enabled,
|
||||||
|
name: extensionName,
|
||||||
|
initialValue: state.primaryBasicInformation
|
||||||
|
.nameExtension ??= 'N/A',
|
||||||
|
style: const TextStyle(color: Colors.black),
|
||||||
|
decoration: normalTextFieldStyle(
|
||||||
|
"Name extension", "")
|
||||||
|
.copyWith(
|
||||||
|
disabledBorder:
|
||||||
|
const OutlineInputBorder(),
|
||||||
|
labelStyle: const TextStyle(
|
||||||
|
color: Colors.black)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
]),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(
|
||||||
const SizedBox(
|
height: 15,
|
||||||
width: 10,
|
|
||||||
),
|
|
||||||
Flexible(
|
|
||||||
flex: 1,
|
|
||||||
child: FormBuilderTextField(
|
|
||||||
enabled: enabled,
|
|
||||||
name: width,
|
|
||||||
initialValue: state
|
|
||||||
.primaryBasicInformation.weightKg!
|
|
||||||
.toString(),
|
|
||||||
decoration: normalTextFieldStyle("Weight", ""),
|
|
||||||
),
|
),
|
||||||
),
|
SizedBox(
|
||||||
const SizedBox(
|
width: screenWidth,
|
||||||
width: 10,
|
child: Row(children: [
|
||||||
),
|
Flexible(
|
||||||
Flexible(
|
flex: 1,
|
||||||
flex: 1,
|
child: FormBuilderTextField(
|
||||||
child: FormBuilderTextField(
|
enabled: enabled,
|
||||||
enabled: enabled,
|
name: extensionName,
|
||||||
name: prefixSuffix,
|
initialValue: dteFormat2.format(state
|
||||||
initialValue:
|
.primaryBasicInformation.birthdate!),
|
||||||
"${state.primaryBasicInformation.titlePrefix ??= "NA"} | ${state.primaryBasicInformation.titleSuffix ??= "N/A"}",
|
style: const TextStyle(color: Colors.black),
|
||||||
decoration: normalTextFieldStyle(
|
decoration:
|
||||||
"Title Prefix and Suffix", ""),
|
normalTextFieldStyle("Birth date", "")
|
||||||
|
.copyWith(
|
||||||
|
disabledBorder:
|
||||||
|
const OutlineInputBorder(),
|
||||||
|
labelStyle: const TextStyle(
|
||||||
|
color: Colors.black)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 10,
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
flex: 1,
|
||||||
|
child: FormBuilderTextField(
|
||||||
|
enabled: enabled,
|
||||||
|
name: sex,
|
||||||
|
initialValue:
|
||||||
|
state.primaryBasicInformation.sex!,
|
||||||
|
style: const TextStyle(color: Colors.black),
|
||||||
|
decoration: normalTextFieldStyle("Sex", "")
|
||||||
|
.copyWith(
|
||||||
|
disabledBorder:
|
||||||
|
const OutlineInputBorder(),
|
||||||
|
labelStyle: const TextStyle(
|
||||||
|
color: Colors.black)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
]),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(
|
||||||
]),
|
height: 15,
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 12,
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: screenWidth,
|
|
||||||
child: Row(children: [
|
|
||||||
Flexible(
|
|
||||||
flex: 1,
|
|
||||||
child: FormBuilderTextField(
|
|
||||||
maxLines: 2,
|
|
||||||
enabled: enabled,
|
|
||||||
name: height,
|
|
||||||
initialValue: state.primaryBasicInformation.ip ??=
|
|
||||||
"N/A",
|
|
||||||
decoration:
|
|
||||||
normalTextFieldStyle("Indigenous", ""),
|
|
||||||
),
|
),
|
||||||
),
|
SizedBox(
|
||||||
const SizedBox(
|
width: screenWidth,
|
||||||
width: 10,
|
child: Row(children: [
|
||||||
),
|
Flexible(
|
||||||
Flexible(
|
flex: 1,
|
||||||
flex: 1,
|
child: FormBuilderTextField(
|
||||||
child: FormBuilderTextField(
|
enabled: enabled,
|
||||||
enabled: enabled,
|
name: "bloodType",
|
||||||
name: width,
|
initialValue: state
|
||||||
initialValue: state
|
.primaryBasicInformation.bloodType!,
|
||||||
.primaryBasicInformation.ethnicity ??= "N/A",
|
style: const TextStyle(color: Colors.black),
|
||||||
decoration: normalTextFieldStyle("Ethnicity", ""),
|
decoration:
|
||||||
|
normalTextFieldStyle("Blood type", "")
|
||||||
|
.copyWith(
|
||||||
|
disabledBorder:
|
||||||
|
const OutlineInputBorder(),
|
||||||
|
labelStyle: const TextStyle(
|
||||||
|
color: Colors.black)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 10,
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
flex: 1,
|
||||||
|
child: FormBuilderTextField(
|
||||||
|
enabled: enabled,
|
||||||
|
name: "civilStatus",
|
||||||
|
initialValue: state
|
||||||
|
.primaryBasicInformation.civilStatus!,
|
||||||
|
style: const TextStyle(color: Colors.black),
|
||||||
|
decoration:
|
||||||
|
normalTextFieldStyle("Civil Status", "")
|
||||||
|
.copyWith(
|
||||||
|
disabledBorder:
|
||||||
|
const OutlineInputBorder(),
|
||||||
|
labelStyle: const TextStyle(
|
||||||
|
color: Colors.black)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 10,
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
flex: 1,
|
||||||
|
child: FormBuilderTextField(
|
||||||
|
enabled: enabled,
|
||||||
|
name: "gender",
|
||||||
|
initialValue: state.primaryBasicInformation
|
||||||
|
.gender ??= "N/A",
|
||||||
|
style: const TextStyle(color: Colors.black),
|
||||||
|
decoration:
|
||||||
|
normalTextFieldStyle("Gender", "")
|
||||||
|
.copyWith(
|
||||||
|
disabledBorder:
|
||||||
|
const OutlineInputBorder(),
|
||||||
|
labelStyle: const TextStyle(
|
||||||
|
color: Colors.black)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(
|
||||||
]),
|
height: 15,
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 12,
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: screenWidth,
|
|
||||||
child: Row(children: [
|
|
||||||
Flexible(
|
|
||||||
flex: 1,
|
|
||||||
child: FormBuilderTextField(
|
|
||||||
maxLines: 2,
|
|
||||||
enabled: enabled,
|
|
||||||
name: height,
|
|
||||||
initialValue: state
|
|
||||||
.primaryBasicInformation.religion ??= "N/A",
|
|
||||||
decoration: normalTextFieldStyle("Religion", ""),
|
|
||||||
),
|
),
|
||||||
),
|
SizedBox(
|
||||||
const SizedBox(
|
width: screenWidth,
|
||||||
width: 10,
|
child: Row(children: [
|
||||||
),
|
Flexible(
|
||||||
Flexible(
|
flex: 1,
|
||||||
flex: 1,
|
child: FormBuilderTextField(
|
||||||
child: FormBuilderTextField(
|
maxLines: 2,
|
||||||
maxLines: 2,
|
enabled: enabled,
|
||||||
enabled: enabled,
|
name: height,
|
||||||
name: width,
|
initialValue: state
|
||||||
initialValue: state
|
.primaryBasicInformation.heightM!
|
||||||
.primaryBasicInformation.disability ??= "N/A",
|
.toString(),
|
||||||
decoration:
|
style: const TextStyle(color: Colors.black),
|
||||||
normalTextFieldStyle("Disability", ""),
|
decoration:
|
||||||
|
normalTextFieldStyle("Height", "")
|
||||||
|
.copyWith(
|
||||||
|
disabledBorder:
|
||||||
|
const OutlineInputBorder(),
|
||||||
|
labelStyle: const TextStyle(
|
||||||
|
color: Colors.black)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 10,
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
flex: 1,
|
||||||
|
child: FormBuilderTextField(
|
||||||
|
enabled: enabled,
|
||||||
|
name: width,
|
||||||
|
initialValue: state
|
||||||
|
.primaryBasicInformation.weightKg!
|
||||||
|
.toString(),
|
||||||
|
style: const TextStyle(color: Colors.black),
|
||||||
|
decoration:
|
||||||
|
normalTextFieldStyle("Weight", "")
|
||||||
|
.copyWith(
|
||||||
|
disabledBorder:
|
||||||
|
const OutlineInputBorder(),
|
||||||
|
labelStyle: const TextStyle(
|
||||||
|
color: Colors.black)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 10,
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
flex: 1,
|
||||||
|
child: FormBuilderTextField(
|
||||||
|
enabled: enabled,
|
||||||
|
name: prefixSuffix,
|
||||||
|
initialValue:
|
||||||
|
"${state.primaryBasicInformation.titlePrefix ??= "NA"} | ${state.primaryBasicInformation.titleSuffix ??= "N/A"}",
|
||||||
|
style: const TextStyle(color: Colors.black),
|
||||||
|
decoration: normalTextFieldStyle(
|
||||||
|
"Title Prefix and Suffix", "")
|
||||||
|
.copyWith(
|
||||||
|
disabledBorder:
|
||||||
|
const OutlineInputBorder(),
|
||||||
|
labelStyle: const TextStyle(
|
||||||
|
color: Colors.black)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(
|
||||||
]),
|
height: 12,
|
||||||
),
|
),
|
||||||
],
|
SizedBox(
|
||||||
),
|
width: screenWidth,
|
||||||
|
child: Row(children: [
|
||||||
|
Flexible(
|
||||||
|
flex: 1,
|
||||||
|
child: FormBuilderTextField(
|
||||||
|
maxLines: 2,
|
||||||
|
enabled: enabled,
|
||||||
|
name: height,
|
||||||
|
initialValue: state
|
||||||
|
.primaryBasicInformation.ip ??= "N/A",
|
||||||
|
style: const TextStyle(color: Colors.black),
|
||||||
|
decoration:
|
||||||
|
normalTextFieldStyle("Indigenous", "")
|
||||||
|
.copyWith(
|
||||||
|
disabledBorder:
|
||||||
|
const OutlineInputBorder(),
|
||||||
|
labelStyle: const TextStyle(
|
||||||
|
color: Colors.black)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 10,
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
flex: 1,
|
||||||
|
child: FormBuilderTextField(
|
||||||
|
enabled: enabled,
|
||||||
|
name: width,
|
||||||
|
initialValue: state.primaryBasicInformation
|
||||||
|
.ethnicity ??= "N/A",
|
||||||
|
style: const TextStyle(color: Colors.black),
|
||||||
|
decoration:
|
||||||
|
normalTextFieldStyle("Ethnicity", "")
|
||||||
|
.copyWith(
|
||||||
|
disabledBorder:
|
||||||
|
const OutlineInputBorder(),
|
||||||
|
labelStyle: const TextStyle(
|
||||||
|
color: Colors.black)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 12,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: screenWidth,
|
||||||
|
child: Row(children: [
|
||||||
|
Flexible(
|
||||||
|
flex: 1,
|
||||||
|
child: FormBuilderTextField(
|
||||||
|
maxLines: 2,
|
||||||
|
enabled: enabled,
|
||||||
|
name: height,
|
||||||
|
initialValue: state.primaryBasicInformation
|
||||||
|
.religion ??= "N/A",
|
||||||
|
style: const TextStyle(color: Colors.black),
|
||||||
|
decoration:
|
||||||
|
normalTextFieldStyle("Religion", "")
|
||||||
|
.copyWith(
|
||||||
|
disabledBorder:
|
||||||
|
const OutlineInputBorder(),
|
||||||
|
labelStyle: const TextStyle(
|
||||||
|
color: Colors.black)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 10,
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
flex: 1,
|
||||||
|
child: FormBuilderTextField(
|
||||||
|
maxLines: 2,
|
||||||
|
enabled: enabled,
|
||||||
|
name: width,
|
||||||
|
initialValue: state.primaryBasicInformation
|
||||||
|
.disability ??= "N/A",
|
||||||
|
style: const TextStyle(color: Colors.black),
|
||||||
|
decoration:
|
||||||
|
normalTextFieldStyle("Disability", "")
|
||||||
|
.copyWith(
|
||||||
|
disabledBorder:
|
||||||
|
const OutlineInputBorder(),
|
||||||
|
labelStyle: const TextStyle(
|
||||||
|
color: Colors.black)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (state is BasicPrimaryInformationErrorState) {
|
||||||
|
return SomethingWentWrong(
|
||||||
|
message: state.message,
|
||||||
|
onpressed: () {
|
||||||
|
context
|
||||||
|
.read<ProfileBloc>()
|
||||||
|
.add(LoadBasicPrimaryInfo());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (state is BasicInformationEditingState) {
|
||||||
|
return EditBasicProfileInfoScreen(
|
||||||
|
profileId: widget.profileId, token: widget.token);
|
||||||
|
}
|
||||||
|
return Container();
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (state is BasicPrimaryInformationErrorState) {
|
|
||||||
return SomethingWentWrong(
|
|
||||||
message: state.message,
|
|
||||||
onpressed: () {
|
|
||||||
context.read<ProfileBloc>().add(LoadBasicPrimaryInfo());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (state is BasicInformationEditingState) {
|
|
||||||
return EditBasicProfileInfoScreen(
|
|
||||||
profileId: widget.profileId, token: widget.token);
|
|
||||||
}
|
|
||||||
return Container();
|
return Container();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
@ -30,6 +30,7 @@ import 'package:unit2/screens/profile/components/references_screen.dart';
|
||||||
import 'package:unit2/screens/profile/components/work_history_screen.dart';
|
import 'package:unit2/screens/profile/components/work_history_screen.dart';
|
||||||
import 'package:unit2/screens/profile/components/voluntary_works_screen.dart';
|
import 'package:unit2/screens/profile/components/voluntary_works_screen.dart';
|
||||||
import 'package:unit2/theme-data.dart/colors.dart';
|
import 'package:unit2/theme-data.dart/colors.dart';
|
||||||
|
import 'package:unit2/utils/global.dart';
|
||||||
import 'package:unit2/widgets/error_state.dart';
|
import 'package:unit2/widgets/error_state.dart';
|
||||||
import '../../bloc/profile/eligibility/eligibility_bloc.dart';
|
import '../../bloc/profile/eligibility/eligibility_bloc.dart';
|
||||||
import '../../bloc/profile/family/family_bloc.dart';
|
import '../../bloc/profile/family/family_bloc.dart';
|
||||||
|
@ -69,8 +70,12 @@ class ProfileInfo extends StatelessWidget {
|
||||||
if (state is UserLoggedIn) {
|
if (state is UserLoggedIn) {
|
||||||
profileId = state.userData!.user!.login!.user!.profileId;
|
profileId = state.userData!.user!.login!.user!.profileId;
|
||||||
token = state.userData!.user!.login!.token!;
|
token = state.userData!.user!.login!.token!;
|
||||||
profile = state.userData!.employeeInfo!.profile!;
|
if (globalCurrentProfile == null) {
|
||||||
|
profile = state.userData!.employeeInfo!.profile!;
|
||||||
|
} else {
|
||||||
|
profile = globalCurrentProfile!;
|
||||||
|
}
|
||||||
|
print(profile.lastName);
|
||||||
return BlocConsumer<ProfileBloc, ProfileState>(
|
return BlocConsumer<ProfileBloc, ProfileState>(
|
||||||
listener: (
|
listener: (
|
||||||
context,
|
context,
|
||||||
|
|
|
@ -172,7 +172,6 @@ class RbacAgencyScreen extends StatelessWidget {
|
||||||
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
|
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
|
||||||
child: BlocConsumer<AgencyBloc, AgencyState>(
|
child: BlocConsumer<AgencyBloc, AgencyState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
print(state);
|
|
||||||
if (state is AgencyLoadingState) {
|
if (state is AgencyLoadingState) {
|
||||||
final progress = ProgressHUD.of(context);
|
final progress = ProgressHUD.of(context);
|
||||||
progress!.showWithText("Please wait...");
|
progress!.showWithText("Please wait...");
|
||||||
|
@ -235,26 +234,25 @@ class RbacAgencyScreen extends StatelessWidget {
|
||||||
decoration: box1(),
|
decoration: box1(),
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 12, vertical: 8),
|
horizontal: 12, vertical: 8),
|
||||||
child: Expanded(
|
child: Row(
|
||||||
child: Row(
|
|
||||||
children: [
|
children: [
|
||||||
CircleAvatar(
|
CircleAvatar(
|
||||||
child: Text('${index + 1}'),
|
child: Text('${index + 1}'),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
width: 12,
|
width: 12,
|
||||||
),
|
),
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Text(state.agencies[index].name!,
|
child: Text(state.agencies[index].name!,
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.titleMedium!
|
.titleMedium!
|
||||||
.copyWith(
|
.copyWith(
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: primary)),
|
color: primary)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 5,
|
height: 5,
|
||||||
|
@ -266,8 +264,7 @@ class RbacAgencyScreen extends StatelessWidget {
|
||||||
return const EmptyData(
|
return const EmptyData(
|
||||||
message: "No Object available. Please click + to add.");
|
message: "No Object available. Please click + to add.");
|
||||||
}
|
}
|
||||||
}
|
}if (state is AgencyErrorState) {
|
||||||
if (state is AgencyErrorState) {
|
|
||||||
return SomethingWentWrong(
|
return SomethingWentWrong(
|
||||||
message: state.message,
|
message: state.message,
|
||||||
onpressed: () {
|
onpressed: () {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -213,7 +213,7 @@ class RbacRoleAssignment extends StatelessWidget {
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Text(
|
child: Text(
|
||||||
state.assignedRoles[index].role!
|
state.assignedRoles[index].role!
|
||||||
.name,
|
.name!,
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.titleMedium!
|
.titleMedium!
|
||||||
|
@ -262,8 +262,8 @@ class RbacRoleAssignment extends StatelessWidget {
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return const EmptyData(
|
return EmptyData(
|
||||||
message: "No Role available. Please click + to add.");
|
message: "No Role available for ${state.fullname}. Please click + to add.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (state is RoleAssignmentErrorState) {
|
if (state is RoleAssignmentErrorState) {
|
||||||
|
|
|
@ -46,46 +46,45 @@ class BasicInfo extends StatelessWidget {
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
children: [
|
children: [
|
||||||
const CoverImage(),
|
const CoverImage(),
|
||||||
Positioned(
|
// Positioned(
|
||||||
top: blockSizeVertical * 15.5,
|
// top: blockSizeVertical * 15.5,
|
||||||
child: Stack(
|
// child: Stack(
|
||||||
alignment: Alignment.center,
|
// alignment: Alignment.center,
|
||||||
children: [
|
// children: [
|
||||||
CachedNetworkImage(
|
// CachedNetworkImage(
|
||||||
imageUrl: fileUrl,
|
// imageUrl: fileUrl,
|
||||||
imageBuilder: (context, imageProvider) =>
|
// imageBuilder: (context, imageProvider) =>
|
||||||
Container(
|
// Container(
|
||||||
width: 160,
|
// width: 160,
|
||||||
height: 160,
|
// height: 160,
|
||||||
decoration: BoxDecoration(
|
// decoration: BoxDecoration(
|
||||||
border:
|
// border: Border.all(
|
||||||
Border.all(color: Colors.black26, width: 3),
|
// color: Colors.black26, width: 3),
|
||||||
shape: BoxShape.circle,
|
// shape: BoxShape.circle,
|
||||||
image: DecorationImage(
|
// image: DecorationImage(
|
||||||
image: imageProvider,
|
// image: imageProvider,
|
||||||
fit: BoxFit.cover),
|
// fit: BoxFit.cover),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
placeholder: (context, url) =>
|
// placeholder: (context, url) =>
|
||||||
const CircularProgressIndicator(),
|
// const CircularProgressIndicator(),
|
||||||
errorWidget: (context, url, error) =>
|
// errorWidget: (context, url, error) =>
|
||||||
Container(
|
// Container(
|
||||||
width: 160,
|
// width: 160,
|
||||||
height: 160,
|
// height: 160,
|
||||||
decoration: BoxDecoration(
|
// decoration: BoxDecoration(
|
||||||
border:
|
// border: Border.all(
|
||||||
Border.all(color: Colors.white, width: 3),
|
// color: Colors.white, width: 3),
|
||||||
shape: BoxShape.circle,
|
// shape: BoxShape.circle,
|
||||||
|
// ),
|
||||||
),
|
// child: SvgPicture.asset(
|
||||||
child: SvgPicture.asset(
|
// 'assets/svgs/male.svg',
|
||||||
'assets/svgs/male.svg',
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ],
|
||||||
],
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
|
||||||
Positioned(
|
Positioned(
|
||||||
top: 10,
|
top: 10,
|
||||||
left: 20,
|
left: 20,
|
||||||
|
@ -138,14 +137,15 @@ class BuildInformation extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
|
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
|
||||||
final String firstName =
|
globalFistname = globalFistname ?? userData.user!.login!.user!.firstName!.toUpperCase();
|
||||||
userData.user!.login!.user!.firstName!.toUpperCase();
|
globalLastname =globalLastname ?? userData.user!.login!.user!.lastName!.toUpperCase();
|
||||||
final String lastname = userData.user!.login!.user!.lastName!.toUpperCase();
|
globalMiddleName = globalMiddleName == null
|
||||||
final String? middlename = userData.employeeInfo == null
|
? (userData.employeeInfo == null
|
||||||
? ''
|
? ''
|
||||||
: userData.employeeInfo!.profile?.middleName?.toUpperCase();
|
: userData.employeeInfo!.profile?.middleName?.toUpperCase())
|
||||||
final String sex = userData.employeeInfo!.profile!.sex!.toUpperCase();
|
: '';
|
||||||
final DateTime? bday = userData.employeeInfo!.profile!.birthdate;
|
globalSex = globalSex ?? userData.employeeInfo!.profile!.sex!.toUpperCase();
|
||||||
|
globalBday = globalBday ?? userData.employeeInfo!.profile!.birthdate;
|
||||||
final uuid = userData.employeeInfo!.uuid;
|
final uuid = userData.employeeInfo!.uuid;
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 25),
|
padding: const EdgeInsets.symmetric(horizontal: 25),
|
||||||
|
@ -156,7 +156,7 @@ class BuildInformation extends StatelessWidget {
|
||||||
height: 25,
|
height: 25,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
"$firstName ${middlename ?? ''} $lastname",
|
"$globalFistname ${globalMiddleName ?? ''} $globalLastname",
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
|
@ -167,7 +167,7 @@ class BuildInformation extends StatelessWidget {
|
||||||
height: 10,
|
height: 10,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
"${dteFormat2.format(bday!)} | $sex",
|
"${dteFormat2.format(globalBday!)} | $sex",
|
||||||
style:
|
style:
|
||||||
Theme.of(context).textTheme.bodySmall!.copyWith(fontSize: 18),
|
Theme.of(context).textTheme.bodySmall!.copyWith(fontSize: 18),
|
||||||
),
|
),
|
||||||
|
|
|
@ -76,9 +76,6 @@ class _DashBoardState extends State<DashBoard> {
|
||||||
tempUnit2Cards = unit2Cards.sublist(0, 4);
|
tempUnit2Cards = unit2Cards.sublist(0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
superadminCards.forEach((el) {
|
|
||||||
print(el.object.name);
|
|
||||||
});
|
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
padding:
|
padding:
|
||||||
|
|
|
@ -24,11 +24,15 @@ IconData? iconGenerator({required String name}) {
|
||||||
return FontAwesome.box;
|
return FontAwesome.box;
|
||||||
} else if (name.toLowerCase() == 'permission') {
|
} else if (name.toLowerCase() == 'permission') {
|
||||||
return FontAwesome5.door_open;
|
return FontAwesome5.door_open;
|
||||||
} else if (name.toLowerCase() == 'station') {
|
} else if (name.toLowerCase() == 'permission assignment') {
|
||||||
|
return Icons.assignment_ind;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (name.toLowerCase() == 'station') {
|
||||||
return ModernPictograms.home;
|
return ModernPictograms.home;
|
||||||
} else if (name.toLowerCase() == 'purok') {
|
} else if (name.toLowerCase() == 'purok') {
|
||||||
return WebSymbols.list_numbered;
|
return WebSymbols.list_numbered;
|
||||||
} else if (name.toLowerCase() == 'barangay') {
|
} else if (name.toLowerCase() == 'baranggay') {
|
||||||
return Maki.industrial_building;
|
return Maki.industrial_building;
|
||||||
} else if (name.toLowerCase() == 'role module') {
|
} else if (name.toLowerCase() == 'role module') {
|
||||||
return FontAwesome5.person_booth;
|
return FontAwesome5.person_booth;
|
||||||
|
|
|
@ -4,6 +4,7 @@ import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||||
import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';
|
import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';
|
||||||
import 'package:form_builder_validators/form_builder_validators.dart';
|
import 'package:form_builder_validators/form_builder_validators.dart';
|
||||||
import 'package:unit2/bloc/rbac/rbac_operations/agency/agency_bloc.dart';
|
import 'package:unit2/bloc/rbac/rbac_operations/agency/agency_bloc.dart';
|
||||||
|
import 'package:unit2/bloc/rbac/rbac_operations/assign_area/assign_area_bloc.dart';
|
||||||
import 'package:unit2/bloc/rbac/rbac_operations/module/module_bloc.dart';
|
import 'package:unit2/bloc/rbac/rbac_operations/module/module_bloc.dart';
|
||||||
import 'package:unit2/bloc/rbac/rbac_operations/module_objects/module_objects_bloc.dart';
|
import 'package:unit2/bloc/rbac/rbac_operations/module_objects/module_objects_bloc.dart';
|
||||||
import 'package:unit2/bloc/rbac/rbac_operations/object/object_bloc.dart';
|
import 'package:unit2/bloc/rbac/rbac_operations/object/object_bloc.dart';
|
||||||
|
@ -15,6 +16,7 @@ import 'package:unit2/bloc/rbac/rbac_operations/role_module/role_module_bloc.dar
|
||||||
import 'package:unit2/bloc/rbac/rbac_operations/roles_under/roles_under_bloc.dart';
|
import 'package:unit2/bloc/rbac/rbac_operations/roles_under/roles_under_bloc.dart';
|
||||||
import 'package:unit2/bloc/rbac/rbac_operations/station/station_bloc.dart';
|
import 'package:unit2/bloc/rbac/rbac_operations/station/station_bloc.dart';
|
||||||
import 'package:unit2/bloc/role_assignment/role_assignment_bloc.dart';
|
import 'package:unit2/bloc/role_assignment/role_assignment_bloc.dart';
|
||||||
|
import 'package:unit2/screens/superadmin/assign_area/assign_area_screen.dart';
|
||||||
import 'package:unit2/screens/superadmin/module/module_screen.dart';
|
import 'package:unit2/screens/superadmin/module/module_screen.dart';
|
||||||
import 'package:unit2/screens/superadmin/object/object_screen.dart';
|
import 'package:unit2/screens/superadmin/object/object_screen.dart';
|
||||||
import 'package:unit2/screens/superadmin/operation/operation_screen.dart';
|
import 'package:unit2/screens/superadmin/operation/operation_screen.dart';
|
||||||
|
@ -49,6 +51,7 @@ class SuperAdminMenu extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final roleAssignmentKey = GlobalKey<FormBuilderState>();
|
final roleAssignmentKey = GlobalKey<FormBuilderState>();
|
||||||
|
final areaKey = GlobalKey<FormBuilderState>();
|
||||||
return AnimationConfiguration.staggeredGrid(
|
return AnimationConfiguration.staggeredGrid(
|
||||||
position: index,
|
position: index,
|
||||||
columnCount: columnCount,
|
columnCount: columnCount,
|
||||||
|
@ -74,12 +77,9 @@ class SuperAdminMenu extends StatelessWidget {
|
||||||
object.moduleName == 'superadmin'
|
object.moduleName == 'superadmin'
|
||||||
? CardLabel(
|
? CardLabel(
|
||||||
icon: iconGenerator(name: object.object.name!),
|
icon: iconGenerator(name: object.object.name!),
|
||||||
title:
|
title: object.object.name!,
|
||||||
object.object.name!,
|
|
||||||
ontap: () {
|
ontap: () {
|
||||||
|
|
||||||
if (object.object.name == 'Role') {
|
if (object.object.name == 'Role') {
|
||||||
|
|
||||||
Navigator.push(context, MaterialPageRoute(
|
Navigator.push(context, MaterialPageRoute(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
|
@ -156,9 +156,7 @@ class SuperAdminMenu extends StatelessWidget {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) =>
|
create: (context) =>
|
||||||
AgencyBloc()..add(GetAgencies()),
|
AgencyBloc()..add(GetAgencies()),
|
||||||
child: RbacAgencyScreen(
|
child: const RbacAgencyScreen(),
|
||||||
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@ -198,31 +196,126 @@ class SuperAdminMenu extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (object.object.name == 'Station') {
|
if (object.object.name == 'Station') {
|
||||||
Navigator.push(context, MaterialPageRoute(
|
Navigator.push(context, MaterialPageRoute(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) => StationBloc()
|
create: (context) => StationBloc()
|
||||||
..add(const GetStations(agencyId: 1)),
|
..add(const GetStations(agencyId: 1)),
|
||||||
child: const RbacStationScreen(
|
child: const RbacStationScreen(
|
||||||
agencyId: 1,
|
agencyId: 1,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
if (object.object.name == 'Role Member') {
|
////////////////////////////////
|
||||||
Navigator.of(context).pop();
|
if (object.object.name == 'Area') {
|
||||||
|
Navigator.of(context).pop();
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: Row(
|
title: Row(
|
||||||
children: [
|
children: [
|
||||||
const Expanded(child: Text("Search User")),
|
const Expanded(
|
||||||
IconButton(onPressed: (){
|
child: Text("Search User")),
|
||||||
Navigator.pop(context);
|
IconButton(
|
||||||
}, icon: const Icon(Icons.close))
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.close))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
content: FormBuilder(
|
||||||
|
key: areaKey,
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
FormBuilderTextField(
|
||||||
|
name: "firstname",
|
||||||
|
validator:
|
||||||
|
FormBuilderValidators.required(
|
||||||
|
errorText:
|
||||||
|
"This field is required"),
|
||||||
|
decoration: normalTextFieldStyle(
|
||||||
|
"First name", "first name"),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 8,
|
||||||
|
),
|
||||||
|
FormBuilderTextField(
|
||||||
|
validator:
|
||||||
|
FormBuilderValidators.required(
|
||||||
|
errorText:
|
||||||
|
"This field is required"),
|
||||||
|
name: "lastname",
|
||||||
|
decoration: normalTextFieldStyle(
|
||||||
|
"Last name", "last tname"),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 24,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 60,
|
||||||
|
width: double.maxFinite,
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
if (areaKey.currentState!
|
||||||
|
.saveAndValidate()) {
|
||||||
|
String fname =
|
||||||
|
areaKey
|
||||||
|
.currentState!
|
||||||
|
.value['firstname'];
|
||||||
|
String lname = areaKey
|
||||||
|
.currentState!
|
||||||
|
.value['lastname'];
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
Navigator.push(context,
|
||||||
|
MaterialPageRoute(builder:
|
||||||
|
(BuildContext
|
||||||
|
context) {
|
||||||
|
return BlocProvider(
|
||||||
|
create: (context) =>
|
||||||
|
AssignAreaBloc()
|
||||||
|
..add(
|
||||||
|
GetAssignArea(
|
||||||
|
firstname:
|
||||||
|
fname,
|
||||||
|
lastname:
|
||||||
|
lname),
|
||||||
|
),
|
||||||
|
child:
|
||||||
|
RbacAssignedAreaScreen(lname: lname,fname: fname,id: id,),
|
||||||
|
);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
style: mainBtnStyle(primary,
|
||||||
|
Colors.transparent, second),
|
||||||
|
child: const Text("Submit"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (object.object.name == 'Role Member') {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Row(
|
||||||
|
children: [
|
||||||
|
const Expanded(
|
||||||
|
child: Text("Search User")),
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.close))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
content: FormBuilder(
|
content: FormBuilder(
|
||||||
|
@ -262,7 +355,6 @@ class SuperAdminMenu extends StatelessWidget {
|
||||||
if (roleAssignmentKey
|
if (roleAssignmentKey
|
||||||
.currentState!
|
.currentState!
|
||||||
.saveAndValidate()) {
|
.saveAndValidate()) {
|
||||||
|
|
||||||
String fname =
|
String fname =
|
||||||
roleAssignmentKey
|
roleAssignmentKey
|
||||||
.currentState!
|
.currentState!
|
||||||
|
@ -271,19 +363,27 @@ class SuperAdminMenu extends StatelessWidget {
|
||||||
roleAssignmentKey
|
roleAssignmentKey
|
||||||
.currentState!
|
.currentState!
|
||||||
.value['lastname'];
|
.value['lastname'];
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
Navigator.push(context,
|
Navigator.push(context,
|
||||||
MaterialPageRoute(builder:
|
MaterialPageRoute(builder:
|
||||||
(BuildContext
|
(BuildContext
|
||||||
context) {
|
context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) =>
|
create: (context) =>
|
||||||
RoleAssignmentBloc()
|
RoleAssignmentBloc()
|
||||||
..add(GetAssignedRoles(
|
..add(
|
||||||
|
GetAssignedRoles(
|
||||||
firstname:
|
firstname:
|
||||||
fname,
|
fname,
|
||||||
lastname:
|
lastname:
|
||||||
lname),),child:RbacRoleAssignment(id:id,name: fname,lname: lname,) ,);
|
lname),
|
||||||
|
),
|
||||||
|
child: RbacRoleAssignment(
|
||||||
|
id: id,
|
||||||
|
name: fname,
|
||||||
|
lname: lname,
|
||||||
|
),
|
||||||
|
);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -17,9 +17,9 @@ class MenuScreen extends StatefulWidget {
|
||||||
class _MenuScreenState extends State<MenuScreen> {
|
class _MenuScreenState extends State<MenuScreen> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final String firstName =
|
final String firstName =globalFistname??
|
||||||
widget.userData!.user!.login!.user!.firstName!.toUpperCase();
|
widget.userData!.user!.login!.user!.firstName!.toUpperCase();
|
||||||
final String lastname =
|
final String lastname = globalLastname??
|
||||||
widget.userData!.user!.login!.user!.lastName!.toUpperCase();
|
widget.userData!.user!.login!.user!.lastName!.toUpperCase();
|
||||||
return Drawer(
|
return Drawer(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
|
|
|
@ -20,8 +20,10 @@ class _MainScreenState extends State<MainScreen> {
|
||||||
List<Role> roles = [];
|
List<Role> roles = [];
|
||||||
List<DisplayCard> cards = [];
|
List<DisplayCard> cards = [];
|
||||||
int? userId;
|
int? userId;
|
||||||
|
DateTime? ctime;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
cards.clear();
|
cards.clear();
|
||||||
cards=[];
|
cards=[];
|
||||||
|
@ -52,34 +54,49 @@ class _MainScreenState extends State<MainScreen> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Scaffold(
|
return WillPopScope(
|
||||||
appBar: AppBar(
|
onWillPop: () {
|
||||||
backgroundColor: primary,
|
DateTime now = DateTime.now();
|
||||||
leading: IconButton(
|
if (ctime == null || now.difference(ctime!) > const Duration(seconds: 2)) {
|
||||||
onPressed: () {
|
//add duration of press gap
|
||||||
ZoomDrawer.of(context)!.toggle();
|
ctime = now;
|
||||||
},
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
icon: const Icon(
|
const SnackBar(content: Text('Press Again to Exit',textAlign: TextAlign.center,))
|
||||||
Icons.menu,
|
);
|
||||||
color: Colors.white,
|
return Future.value(false);
|
||||||
),
|
}
|
||||||
),
|
|
||||||
centerTitle: true,
|
return Future.value(true);
|
||||||
title: const Text(
|
},
|
||||||
unit2ModuleScreen,
|
child: Scaffold(
|
||||||
style: TextStyle(
|
appBar: AppBar(
|
||||||
fontSize: 18.0,
|
backgroundColor: primary,
|
||||||
color: Colors.white,
|
leading: IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
ZoomDrawer.of(context)!.toggle();
|
||||||
|
},
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.menu,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
centerTitle: true,
|
||||||
|
title: const Text(
|
||||||
|
unit2ModuleScreen,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18.0,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
body: state.userData!.user!.login!.user!.roles!.isNotEmpty
|
||||||
|
? DashBoard(
|
||||||
|
estPersonAssignedArea: state.estPersonAssignedArea,
|
||||||
|
userId: userId!,
|
||||||
|
cards: cards,
|
||||||
|
)
|
||||||
|
: const NoModule(),
|
||||||
),
|
),
|
||||||
body: state.userData!.user!.login!.user!.roles!.isNotEmpty
|
|
||||||
? DashBoard(
|
|
||||||
estPersonAssignedArea: state.estPersonAssignedArea,
|
|
||||||
userId: userId!,
|
|
||||||
cards: cards,
|
|
||||||
)
|
|
||||||
: const NoModule(),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Container();
|
return Container();
|
||||||
|
|
|
@ -22,7 +22,6 @@ import '../../../theme-data.dart/colors.dart';
|
||||||
import '../../../theme-data.dart/form-style.dart';
|
import '../../../theme-data.dart/form-style.dart';
|
||||||
import '../../../theme-data.dart/btn-style.dart';
|
import '../../../theme-data.dart/btn-style.dart';
|
||||||
import './components/login-via-qr-label.dart';
|
import './components/login-via-qr-label.dart';
|
||||||
import './functions/press-again-to-exit.dart';
|
|
||||||
|
|
||||||
class UniT2Login extends StatefulWidget {
|
class UniT2Login extends StatefulWidget {
|
||||||
const UniT2Login({super.key});
|
const UniT2Login({super.key});
|
||||||
|
@ -37,17 +36,30 @@ class _UniT2LoginState extends State<UniT2Login> {
|
||||||
bool _showPassword = true;
|
bool _showPassword = true;
|
||||||
String? password;
|
String? password;
|
||||||
String? username;
|
String? username;
|
||||||
|
DateTime? ctime;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return WillPopScope(
|
return WillPopScope(
|
||||||
onWillPop: pressAgainToExit,
|
onWillPop: () {
|
||||||
|
DateTime now = DateTime.now();
|
||||||
|
if (ctime == null || now.difference(ctime!) > const Duration(seconds: 2)) {
|
||||||
|
ctime = now;
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(content: Text('Press Again to Exit',textAlign: TextAlign.center,))
|
||||||
|
);
|
||||||
|
return Future.value(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Future.value(true);
|
||||||
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
body: ProgressHUD(
|
body: ProgressHUD(
|
||||||
backgroundColor: Colors.black87,
|
backgroundColor: Colors.black87,
|
||||||
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
|
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
|
||||||
child: BlocConsumer<UserBloc, UserState>(listener: (context, state) {
|
child: BlocConsumer<UserBloc, UserState>(listener: (context, state) {
|
||||||
print(state);
|
if (state is UserLoggedIn ||
|
||||||
if (state is UserLoggedIn || state is UuidLoaded || state is LoginErrorState) {
|
state is UuidLoaded ||
|
||||||
|
state is LoginErrorState) {
|
||||||
final progress = ProgressHUD.of(context);
|
final progress = ProgressHUD.of(context);
|
||||||
progress!.dismiss();
|
progress!.dismiss();
|
||||||
}
|
}
|
||||||
|
@ -94,10 +106,9 @@ class _UniT2LoginState extends State<UniT2Login> {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}, builder: (context, state) {
|
}, builder: (context, state) {
|
||||||
print(state);
|
|
||||||
if (state is VersionLoaded) {
|
if (state is VersionLoaded) {
|
||||||
return Builder(builder: (context) {
|
return Builder(builder: (context) {
|
||||||
if (state.versionInfo!.version != state.apkVersion) {
|
if (state.versionInfo?.version != state.apkVersion) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Stack(
|
child: Stack(
|
||||||
|
@ -355,7 +366,7 @@ class _UniT2LoginState extends State<UniT2Login> {
|
||||||
onpressed: () {
|
onpressed: () {
|
||||||
BlocProvider.of<UserBloc>(
|
BlocProvider.of<UserBloc>(
|
||||||
NavigationService.navigatorKey.currentContext!)
|
NavigationService.navigatorKey.currentContext!)
|
||||||
.add(GetApkVersion());
|
.add(LoadVersion(username: username, password: password));
|
||||||
return MaterialPageRoute(builder: (_) {
|
return MaterialPageRoute(builder: (_) {
|
||||||
return const UniT2Login();
|
return const UniT2Login();
|
||||||
});
|
});
|
||||||
|
@ -374,14 +385,14 @@ class _UniT2LoginState extends State<UniT2Login> {
|
||||||
onpressed: () {
|
onpressed: () {
|
||||||
BlocProvider.of<UserBloc>(
|
BlocProvider.of<UserBloc>(
|
||||||
NavigationService.navigatorKey.currentContext!)
|
NavigationService.navigatorKey.currentContext!)
|
||||||
.add(GetApkVersion());
|
.add(LoadVersion(username: username, password: password));
|
||||||
return MaterialPageRoute(builder: (_) {
|
return MaterialPageRoute(builder: (_) {
|
||||||
return const UniT2Login();
|
return const UniT2Login();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Container();
|
return Container();
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -158,11 +158,11 @@ class EstPointPersonRoleAssignmentScreen extends StatelessWidget {
|
||||||
if (!assignedRoles.keys.contains(fullName)) {
|
if (!assignedRoles.keys.contains(fullName)) {
|
||||||
assignedRoles.addAll({fullName: []});
|
assignedRoles.addAll({fullName: []});
|
||||||
assignedRoles[fullName]!.add(Content(
|
assignedRoles[fullName]!.add(Content(
|
||||||
id: assignedRole.id!, name: assignedRole.role!.name));
|
id: assignedRole.id!, name: assignedRole.role!.name!));
|
||||||
} else {
|
} else {
|
||||||
assignedRoles[fullName]!.add(Content(
|
assignedRoles[fullName]!.add(Content(
|
||||||
id: assignedRole.id!,
|
id: assignedRole.id!,
|
||||||
name: assignedRole.role!.name));
|
name: assignedRole.role!.name!));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,9 +116,9 @@ class PassCheckServices {
|
||||||
}
|
}
|
||||||
////PUROK
|
////PUROK
|
||||||
if (assignRoleAreaType.areaTypeName.toLowerCase() == 'purok') {
|
if (assignRoleAreaType.areaTypeName.toLowerCase() == 'purok') {
|
||||||
List<Purok> assignedArea = [];
|
List<PassCheckPurok> assignedArea = [];
|
||||||
data['data'][0]['assigned_area'].forEach((var element) {
|
data['data'][0]['assigned_area'].forEach((var element) {
|
||||||
Purok purok = Purok.fromJson(element['area']);
|
PassCheckPurok purok = PassCheckPurok.fromJson(element['area']);
|
||||||
assignedArea.add(purok);
|
assignedArea.add(purok);
|
||||||
});
|
});
|
||||||
statusResponse = assignedArea;
|
statusResponse = assignedArea;
|
||||||
|
@ -172,7 +172,7 @@ class PassCheckServices {
|
||||||
double? temp,
|
double? temp,
|
||||||
int? stationId,
|
int? stationId,
|
||||||
String? cpId,
|
String? cpId,
|
||||||
required int roleid}) async {
|
required RoleIdRoleName roleIdRoleName}) async {
|
||||||
String path = Url.instance.postLogs();
|
String path = Url.instance.postLogs();
|
||||||
bool success;
|
bool success;
|
||||||
Map<String, String> headers = {
|
Map<String, String> headers = {
|
||||||
|
@ -182,9 +182,8 @@ class PassCheckServices {
|
||||||
};
|
};
|
||||||
Map body;
|
Map body;
|
||||||
if (otherInputs) {
|
if (otherInputs) {
|
||||||
if (roleid == 41 || roleid == 13 || roleid == 17 || roleid == 22) {
|
if (roleIdRoleName.roleName.toLowerCase() == "security guard" || roleIdRoleName.roleName.toLowerCase() == "qr code scanner") {
|
||||||
if (io == "i") {
|
if (io == "i") {
|
||||||
print("1");
|
|
||||||
body = {
|
body = {
|
||||||
"station_id": stationId,
|
"station_id": stationId,
|
||||||
"temperature": temp,
|
"temperature": temp,
|
||||||
|
@ -193,7 +192,6 @@ class PassCheckServices {
|
||||||
"io": io
|
"io": io
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
print("2");
|
|
||||||
body = {
|
body = {
|
||||||
"station_id": stationId,
|
"station_id": stationId,
|
||||||
"destination": destination,
|
"destination": destination,
|
||||||
|
@ -203,7 +201,6 @@ class PassCheckServices {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print("3");
|
|
||||||
if (io == "i") {
|
if (io == "i") {
|
||||||
body = {
|
body = {
|
||||||
"cp_id": cpId,
|
"cp_id": cpId,
|
||||||
|
@ -213,7 +210,6 @@ class PassCheckServices {
|
||||||
"io": io
|
"io": io
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
print("4");
|
|
||||||
body = {
|
body = {
|
||||||
"cp_id": cpId,
|
"cp_id": cpId,
|
||||||
"destination": destination,
|
"destination": destination,
|
||||||
|
@ -224,8 +220,7 @@ class PassCheckServices {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print("5");
|
if (roleIdRoleName.roleName.toLowerCase() == "security guard" || roleIdRoleName.roleName.toLowerCase() == "qr code scanner") {
|
||||||
if (roleid == 41 || roleid == 13 || roleid == 17 || roleid == 22) {
|
|
||||||
body = {
|
body = {
|
||||||
"station_id": stationId,
|
"station_id": stationId,
|
||||||
"passer": passerId,
|
"passer": passerId,
|
||||||
|
@ -233,7 +228,6 @@ class PassCheckServices {
|
||||||
"io": io
|
"io": io
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
print("6");
|
|
||||||
body = {
|
body = {
|
||||||
"cp_id": cpId,
|
"cp_id": cpId,
|
||||||
"temperature": temp,
|
"temperature": temp,
|
||||||
|
|
|
@ -0,0 +1,89 @@
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:unit2/model/profile/assigned_area.dart';
|
||||||
|
import 'package:unit2/utils/urls.dart';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
|
import '../../../utils/request.dart';
|
||||||
|
|
||||||
|
class RbacAssignedAreaServices {
|
||||||
|
static final RbacAssignedAreaServices _instance = RbacAssignedAreaServices();
|
||||||
|
static RbacAssignedAreaServices get instance => _instance;
|
||||||
|
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
|
||||||
|
String xClientKeySecret = "unitcYqAN7GGalyz";
|
||||||
|
Future<List<UserAssignedArea>> getAssignedArea({required int id}) async {
|
||||||
|
List<UserAssignedArea> userAssignedAreas = [];
|
||||||
|
String path = Url.instance.getAssignAreas();
|
||||||
|
Map<String, String> headers = {
|
||||||
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
|
'X-Client-Key': xClientKey,
|
||||||
|
'X-Client-Secret': xClientKeySecret
|
||||||
|
};
|
||||||
|
Map<String, String> param = {
|
||||||
|
"assigned_role__user__id": id.toString(),
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
http.Response response = await Request.instance
|
||||||
|
.getRequest(param: param, path: path, headers: headers);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
Map data = jsonDecode(response.body);
|
||||||
|
if (data['data'] != null) {
|
||||||
|
for (var assignedArea in data['data']) {
|
||||||
|
UserAssignedArea newArea = UserAssignedArea.fromJson(assignedArea);
|
||||||
|
userAssignedAreas.add(newArea);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
throw e.toString();
|
||||||
|
}
|
||||||
|
return userAssignedAreas;
|
||||||
|
}
|
||||||
|
Future<bool> deleteAssignedArea({required int areaId}) async {
|
||||||
|
bool success = false;
|
||||||
|
String path = "${Url.instance.getAssignAreas()}$areaId/";
|
||||||
|
Map<String, String> headers = {
|
||||||
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
|
'X-Client-Key': xClientKey,
|
||||||
|
'X-Client-Secret': xClientKeySecret
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
http.Response response = await Request.instance
|
||||||
|
.deleteRequest(path: path, headers: headers, body: {}, param: {});
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
success = true;
|
||||||
|
}else{
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
throw e.toString();
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
Future<Map<dynamic, dynamic>> add ({required int userId, required int roleId, required int areaTypeId, required String areaId}) async{
|
||||||
|
String path = Url.instance.getAssignAreas();
|
||||||
|
Map<String, String> headers = {
|
||||||
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
|
'X-Client-Key': xClientKey,
|
||||||
|
'X-Client-Secret': xClientKeySecret
|
||||||
|
};
|
||||||
|
Map<dynamic, dynamic>? responseStatus = {};
|
||||||
|
Map body = {
|
||||||
|
"user_id":userId,
|
||||||
|
"role_id":roleId,
|
||||||
|
"assigned_areas": [{"areatypeid":areaTypeId,"areaid":areaId}]
|
||||||
|
};
|
||||||
|
try{
|
||||||
|
http.Response response = await Request.instance.postRequest(path: path, headers: headers, body: body, param: {});
|
||||||
|
if(response.statusCode == 201){
|
||||||
|
Map data = jsonDecode(response.body);
|
||||||
|
responseStatus = data;
|
||||||
|
} else {
|
||||||
|
responseStatus.addAll({'success': false});
|
||||||
|
}
|
||||||
|
}catch(e){
|
||||||
|
throw e.toString();
|
||||||
|
}
|
||||||
|
return responseStatus;
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,7 +27,7 @@ class AppRouter {
|
||||||
case '/':
|
case '/':
|
||||||
BlocProvider.of<UserBloc>(
|
BlocProvider.of<UserBloc>(
|
||||||
NavigationService.navigatorKey.currentContext!)
|
NavigationService.navigatorKey.currentContext!)
|
||||||
.add(GetApkVersion());
|
.add(GetApkVersion(username: "", password: ""));
|
||||||
return MaterialPageRoute(builder: (_) {
|
return MaterialPageRoute(builder: (_) {
|
||||||
return const UniT2Login();
|
return const UniT2Login();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
|
|
||||||
|
import '../model/profile/basic_information/primary-information.dart';
|
||||||
|
|
||||||
double screenWidth = 0;
|
double screenWidth = 0;
|
||||||
double screenHeight = 0;
|
double screenHeight = 0;
|
||||||
double blockSizeHorizontal = 0;
|
double blockSizeHorizontal = 0;
|
||||||
|
@ -11,8 +13,12 @@ double safeBlockVertical = 0;
|
||||||
|
|
||||||
const xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
|
const xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
|
||||||
const xClientSecret = "unitcYqAN7GGalyz";
|
const xClientSecret = "unitcYqAN7GGalyz";
|
||||||
|
String? globalFistname;
|
||||||
|
String? globalLastname;
|
||||||
|
String? globalMiddleName;
|
||||||
|
DateTime? globalBday;
|
||||||
|
String? globalSex;
|
||||||
|
Profile? globalCurrentProfile;
|
||||||
|
|
||||||
//// hive boxes
|
//// hive boxes
|
||||||
Box? CREDENTIALS;
|
Box? CREDENTIALS;
|
||||||
|
|
|
@ -6,6 +6,7 @@ import 'package:unit2/model/location/city.dart';
|
||||||
import 'package:unit2/model/location/country.dart';
|
import 'package:unit2/model/location/country.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:unit2/model/location/provinces.dart';
|
import 'package:unit2/model/location/provinces.dart';
|
||||||
|
import 'package:unit2/model/location/purok.dart';
|
||||||
import 'package:unit2/utils/request.dart';
|
import 'package:unit2/utils/request.dart';
|
||||||
import 'package:unit2/utils/urls.dart';
|
import 'package:unit2/utils/urls.dart';
|
||||||
|
|
||||||
|
@ -23,20 +24,20 @@ class LocationUtils {
|
||||||
List<Country> countries = [];
|
List<Country> countries = [];
|
||||||
String path = Url.instance.getCounties();
|
String path = Url.instance.getCounties();
|
||||||
|
|
||||||
try{
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.getRequest(path: path, param: {}, headers: headers);
|
.getRequest(path: path, param: {}, headers: headers);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
Map data = jsonDecode(response.body);
|
Map data = jsonDecode(response.body);
|
||||||
if (data['data'] != null) {
|
if (data['data'] != null) {
|
||||||
data['data'].forEach((var country) {
|
data['data'].forEach((var country) {
|
||||||
Country newCOuntry = Country.fromJson(country);
|
Country newCOuntry = Country.fromJson(country);
|
||||||
countries.add(newCOuntry);
|
countries.add(newCOuntry);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (e) {
|
||||||
}catch(e){
|
throw (e.toString());
|
||||||
throw(e.toString());
|
|
||||||
}
|
}
|
||||||
return countries;
|
return countries;
|
||||||
}
|
}
|
||||||
|
@ -45,20 +46,20 @@ class LocationUtils {
|
||||||
List<Region> regions = [];
|
List<Region> regions = [];
|
||||||
String path = Url.instance.getRegions();
|
String path = Url.instance.getRegions();
|
||||||
|
|
||||||
try{
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.getRequest(path: path, param: {}, headers: headers);
|
.getRequest(path: path, param: {}, headers: headers);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
Map data = jsonDecode(response.body);
|
Map data = jsonDecode(response.body);
|
||||||
if (data['data'] != null) {
|
if (data['data'] != null) {
|
||||||
data['data'].forEach((var region) {
|
data['data'].forEach((var region) {
|
||||||
Region newRegion = Region.fromJson(region);
|
Region newRegion = Region.fromJson(region);
|
||||||
regions.add(newRegion);
|
regions.add(newRegion);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (e) {
|
||||||
}catch(e){
|
throw (e.toString());
|
||||||
throw(e.toString());
|
|
||||||
}
|
}
|
||||||
return regions;
|
return regions;
|
||||||
}
|
}
|
||||||
|
@ -70,12 +71,14 @@ class LocationUtils {
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.getRequest(path: path, param: {}, headers: headers);
|
.getRequest(path: path, param: {}, headers: headers);
|
||||||
Map data = jsonDecode(response.body);
|
if (response.statusCode == 200) {
|
||||||
if (data['data'] != null) {
|
Map data = jsonDecode(response.body);
|
||||||
data['data'].forEach((var province) {
|
if (data['data'] != null) {
|
||||||
Province newProvince = Province.fromJson(province);
|
data['data'].forEach((var province) {
|
||||||
provinces.add(newProvince);
|
Province newProvince = Province.fromJson(province);
|
||||||
});
|
provinces.add(newProvince);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw (e.toString());
|
throw (e.toString());
|
||||||
|
@ -89,12 +92,14 @@ class LocationUtils {
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.getRequest(path: path, param: {}, headers: headers);
|
.getRequest(path: path, param: {}, headers: headers);
|
||||||
Map data = jsonDecode(response.body);
|
if (response.statusCode == 200) {
|
||||||
if (data['data'] != null) {
|
Map data = jsonDecode(response.body);
|
||||||
data['data'].forEach((var city) {
|
if (data['data'] != null) {
|
||||||
CityMunicipality cityMun = CityMunicipality.fromJson(city);
|
data['data'].forEach((var city) {
|
||||||
cities.add(cityMun);
|
CityMunicipality cityMun = CityMunicipality.fromJson(city);
|
||||||
});
|
cities.add(cityMun);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw (e.toString());
|
throw (e.toString());
|
||||||
|
@ -102,41 +107,64 @@ class LocationUtils {
|
||||||
return cities;
|
return cities;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Barangay>> getBarangay({required String code}) async {
|
Future<List<Barangay>> getBarangay({required String code}) async {
|
||||||
List<Barangay> barangays = [];
|
List<Barangay> barangays = [];
|
||||||
String path = Url.instance.getBarangays() + code;
|
String path = Url.instance.getBarangays() + code;
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.getRequest(path: path, param: {}, headers: headers);
|
.getRequest(path: path, param: {}, headers: headers);
|
||||||
Map data = jsonDecode(response.body);
|
if (response.statusCode == 200) {
|
||||||
if (data['data'] != null) {
|
Map data = jsonDecode(response.body);
|
||||||
data['data'].forEach((var city) {
|
if (data['data'] != null) {
|
||||||
Barangay barangay = Barangay.fromJson(city);
|
data['data'].forEach((var city) {
|
||||||
barangays.add(barangay);
|
Barangay barangay = Barangay.fromJson(city);
|
||||||
});
|
barangays.add(barangay);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw (e.toString());
|
throw (e.toString());
|
||||||
}
|
}
|
||||||
return barangays;
|
return barangays;
|
||||||
}
|
}
|
||||||
Future<List<AddressCategory>>getAddressCategory()async{
|
|
||||||
|
Future<List<Purok>> getPurok({required String barangay}) async {
|
||||||
|
List<Purok> puroks = [];
|
||||||
|
String path = Url.instance.getPurok() + barangay;
|
||||||
|
try {
|
||||||
|
http.Response response = await Request.instance
|
||||||
|
.getRequest(path: path, param: {}, headers: headers);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
Map data = jsonDecode(response.body);
|
||||||
|
if (data['data'] != null) {
|
||||||
|
data['data'].forEach((var purok) {
|
||||||
|
Purok newPurok = Purok.fromJson(purok);
|
||||||
|
puroks.add(newPurok);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
throw (e.toString());
|
||||||
|
}
|
||||||
|
return puroks;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<AddressCategory>> getAddressCategory() async {
|
||||||
List<AddressCategory> categories = [];
|
List<AddressCategory> categories = [];
|
||||||
String path = Url.instance.getAddressCategory();
|
String path = Url.instance.getAddressCategory();
|
||||||
try{
|
try {
|
||||||
http.Response response = await Request.instance.getRequest(path: path,param: {},headers:headers );
|
http.Response response = await Request.instance
|
||||||
|
.getRequest(path: path, param: {}, headers: headers);
|
||||||
Map data = jsonDecode(response.body);
|
Map data = jsonDecode(response.body);
|
||||||
if(data['data'] != null){
|
if (data['data'] != null) {
|
||||||
data['data'].forEach((var cat){
|
data['data'].forEach((var cat) {
|
||||||
categories.add(AddressCategory.fromJson(cat));
|
categories.add(AddressCategory.fromJson(cat));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
categories;
|
categories;
|
||||||
return categories;
|
return categories;
|
||||||
}catch(e){
|
} catch (e) {
|
||||||
throw e.toString();
|
throw e.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,17 +5,17 @@ class Url {
|
||||||
|
|
||||||
String host() {
|
String host() {
|
||||||
// return '192.168.10.183:3000';
|
// return '192.168.10.183:3000';
|
||||||
// return 'agusandelnorte.gov.ph';
|
return 'agusandelnorte.gov.ph';
|
||||||
// return "192.168.10.219:3000";
|
// return "192.168.10.219:3000";
|
||||||
// return "192.168.10.241";
|
// return "192.168.10.241";
|
||||||
// return "192.168.10.221:3004";
|
// return "192.168.10.221:3004";
|
||||||
return "playweb.agusandelnorte.gov.ph";
|
// return "playweb.agusandelnorte.gov.ph";
|
||||||
// return 'devapi.agusandelnorte.gov.ph:3004';
|
// return 'devapi.agusandelnorte.gov.ph:3004';
|
||||||
// return "192.168.10.218:8000";
|
// return "192.168.10.218:8000";
|
||||||
}
|
}
|
||||||
|
|
||||||
String prefixHost() {
|
String prefixHost() {
|
||||||
return "https";
|
return "https";
|
||||||
// return "http";
|
// return "http";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,6 +320,10 @@ class Url {
|
||||||
return "/api/hrms_app/position_title/";
|
return "/api/hrms_app/position_title/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getAssignedAreas() {
|
||||||
|
return "/api/account/auth/assigned_role_area";
|
||||||
|
}
|
||||||
|
|
||||||
//// location utils path
|
//// location utils path
|
||||||
String getCounties() {
|
String getCounties() {
|
||||||
return "/api/jobnet_app/countries/";
|
return "/api/jobnet_app/countries/";
|
||||||
|
@ -340,6 +344,9 @@ class Url {
|
||||||
String getBarangays() {
|
String getBarangays() {
|
||||||
return "/api/web_app/location/barangay/";
|
return "/api/web_app/location/barangay/";
|
||||||
}
|
}
|
||||||
|
String getPurok(){
|
||||||
|
return "/api/web_app/location/purok/";
|
||||||
|
}
|
||||||
|
|
||||||
String getAddressCategory() {
|
String getAddressCategory() {
|
||||||
return "/api/jobnet_app/address_categories/";
|
return "/api/jobnet_app/address_categories/";
|
||||||
|
|
44
pubspec.lock
44
pubspec.lock
|
@ -25,6 +25,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.2"
|
version: "3.0.2"
|
||||||
|
animated_splash_screen:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: animated_splash_screen
|
||||||
|
sha256: f45634db6ec4e8cf034c53e03f3bd83898a16fe3c9286bf5510b6831dfcf2124
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.3.0"
|
||||||
app_popup_menu:
|
app_popup_menu:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -369,14 +377,6 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0"
|
version: "2.1.0"
|
||||||
device_frame:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: device_frame
|
|
||||||
sha256: afe76182aec178d171953d9b4a50a43c57c7cf3c77d8b09a48bf30c8fa04dd9d
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.1.0"
|
|
||||||
device_info:
|
device_info:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -409,14 +409,6 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "7.0.0"
|
version: "7.0.0"
|
||||||
device_preview:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: device_preview
|
|
||||||
sha256: "2f097bf31b929e15e6756dbe0ec1bcb63952ab9ed51c25dc5a2c722d2b21fdaf"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.1.0"
|
|
||||||
dio:
|
dio:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -685,14 +677,6 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "8.6.1"
|
version: "8.6.1"
|
||||||
freezed_annotation:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: freezed_annotation
|
|
||||||
sha256: c3fd9336eb55a38cc1bbd79ab17573113a8deccd0ecbbf926cca3c62803b5c2d
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.4.1"
|
|
||||||
frontend_server_client:
|
frontend_server_client:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -801,10 +785,10 @@ packages:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: intl
|
name: intl
|
||||||
sha256: "910f85bce16fb5c6f614e117efa303e85a1731bb0081edf3604a2ae6e9a3cc91"
|
sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.17.0"
|
version: "0.18.1"
|
||||||
io:
|
io:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -997,6 +981,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.1"
|
version: "2.0.1"
|
||||||
|
page_transition:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: page_transition
|
||||||
|
sha256: dee976b1f23de9bbef5cd512fe567e9f6278caee11f5eaca9a2115c19dc49ef6
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.0"
|
||||||
path:
|
path:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
12
pubspec.yaml
12
pubspec.yaml
|
@ -38,10 +38,9 @@ dependencies:
|
||||||
flutter_custom_clippers: ^2.0.0
|
flutter_custom_clippers: ^2.0.0
|
||||||
flutter_svg: ^1.1.6
|
flutter_svg: ^1.1.6
|
||||||
flutter_form_builder: ^7.7.0
|
flutter_form_builder: ^7.7.0
|
||||||
form_builder_validators: ^8.4.0
|
form_builder_validators: any
|
||||||
fluttericon: ^2.0.0
|
fluttericon: ^2.0.0
|
||||||
fluttertoast: ^8.1.1
|
fluttertoast: ^8.1.1
|
||||||
device_preview: ^1.1.0
|
|
||||||
flutter_zoom_drawer: ^3.0.3
|
flutter_zoom_drawer: ^3.0.3
|
||||||
cached_network_image: ^3.2.3
|
cached_network_image: ^3.2.3
|
||||||
auto_size_text: ^3.0.0
|
auto_size_text: ^3.0.0
|
||||||
|
@ -50,7 +49,7 @@ dependencies:
|
||||||
toggle_switch: ^2.0.1
|
toggle_switch: ^2.0.1
|
||||||
convex_bottom_bar: ^3.1.0+1
|
convex_bottom_bar: ^3.1.0+1
|
||||||
azlistview: ^2.0.0
|
azlistview: ^2.0.0
|
||||||
intl: ^0.17.0
|
intl: ^0.18.1
|
||||||
date_time_picker: ^2.1.0
|
date_time_picker: ^2.1.0
|
||||||
flutter_progress_hud: ^2.0.2
|
flutter_progress_hud: ^2.0.2
|
||||||
barcode_scan2: ^4.2.1
|
barcode_scan2: ^4.2.1
|
||||||
|
@ -85,7 +84,7 @@ dependencies:
|
||||||
flutter_speed_dial: ^6.2.0
|
flutter_speed_dial: ^6.2.0
|
||||||
im_stepper: ^1.0.1+1
|
im_stepper: ^1.0.1+1
|
||||||
shared_preferences: ^2.0.20
|
shared_preferences: ^2.0.20
|
||||||
multiselect: ^0.1.0
|
multiselect: any
|
||||||
multi_select_flutter: ^4.1.3
|
multi_select_flutter: ^4.1.3
|
||||||
flutter_custom_selector: ^0.0.3
|
flutter_custom_selector: ^0.0.3
|
||||||
flutter_staggered_animations: ^1.1.1
|
flutter_staggered_animations: ^1.1.1
|
||||||
|
@ -98,7 +97,10 @@ dependencies:
|
||||||
url_launcher: ^6.1.11
|
url_launcher: ^6.1.11
|
||||||
url_launcher_android: ^6.0.38
|
url_launcher_android: ^6.0.38
|
||||||
share_plus: ^7.1.0
|
share_plus: ^7.1.0
|
||||||
|
animated_splash_screen: ^1.3.0
|
||||||
|
dependency_overrides:
|
||||||
|
intl: ^0.18.0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
|
Loading…
Reference in New Issue