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')
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
tasks.register("clean", Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import 'package:unit2/sevices/profile/profile_service.dart';
|
|||
|
||||
import '../../model/profile/basic_information/primary-information.dart';
|
||||
import '../../screens/profile/components/basic_information/profile_other_info.dart';
|
||||
import '../../utils/global.dart';
|
||||
part 'profile_event.dart';
|
||||
part 'profile_state.dart';
|
||||
|
||||
|
@ -52,20 +53,24 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
|
|||
.getProfile(event.token, event.userID);
|
||||
globalProfileInformation = profileInformation;
|
||||
}
|
||||
|
||||
emit(ProfileLoaded(profileInformation: globalProfileInformation!));
|
||||
} catch (e) {
|
||||
emit(ProfileErrorState(mesage: e.toString()));
|
||||
}
|
||||
});
|
||||
on<GetPrimaryBasicInfo>((event, emit) {
|
||||
if (globalCurrentProfile != null) {
|
||||
emit(BasicInformationProfileLoaded(
|
||||
primaryBasicInformation: globalCurrentProfile!));
|
||||
} else {
|
||||
currentProfileInformation = event.primaryBasicInformation;
|
||||
emit(BasicInformationProfileLoaded(
|
||||
primaryBasicInformation: event.primaryBasicInformation));
|
||||
primaryBasicInformation: currentProfileInformation!));
|
||||
}
|
||||
});
|
||||
on<LoadBasicPrimaryInfo>((event, emit) {
|
||||
emit(BasicInformationProfileLoaded(
|
||||
primaryBasicInformation: currentProfileInformation!));
|
||||
primaryBasicInformation: globalCurrentProfile!));
|
||||
});
|
||||
on<ShowPrimaryInfoEditForm>((event, emit) async {
|
||||
try {
|
||||
|
@ -132,6 +137,12 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
|
|||
if (status['success']) {
|
||||
Profile profile = Profile.fromJson(status['data']);
|
||||
currentProfileInformation = profile;
|
||||
globalCurrentProfile = profile;
|
||||
globalFistname = profile.firstName;
|
||||
globalLastname = profile.lastName;
|
||||
globalBday = profile.birthdate;
|
||||
globalSex = profile.sex;
|
||||
|
||||
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!,
|
||||
passerId: uuid!,
|
||||
roleId: roleIdRoleName!.roleId,
|
||||
roleName: roleIdRoleName!.roleName,
|
||||
stationId: stationId,
|
||||
temp: event.temp));
|
||||
});
|
||||
|
@ -78,6 +79,7 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
|
|||
otherInputs: otherInputs!,
|
||||
passerId: uuid!,
|
||||
roleId: roleIdRoleName!.roleId,
|
||||
roleName: roleIdRoleName!.roleName,
|
||||
stationId: stationId,
|
||||
temp: null));
|
||||
});
|
||||
|
@ -123,6 +125,7 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
|
|||
otherInputs: otherInputs!,
|
||||
passerId: uuid!,
|
||||
roleId: roleIdRoleName!.roleId,
|
||||
roleName: roleIdRoleName!.roleName,
|
||||
stationId: stationId,
|
||||
temp: null));
|
||||
}
|
||||
|
@ -152,7 +155,7 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
|
|||
stationId: event.stationId,
|
||||
cpId: event.cpId,
|
||||
otherInputs: event.otherInputs,
|
||||
roleid: event.roleId);
|
||||
roleIdRoleName: roleIdRoleName!);
|
||||
if (success) {
|
||||
Fluttertoast.showToast(
|
||||
msg: "SUCCESSFULLY SAVED",
|
||||
|
|
|
@ -44,6 +44,7 @@ class PerformPostLogs extends PassCheckEvent {
|
|||
final int? stationId;
|
||||
final String? destination;
|
||||
final double? temp;
|
||||
final String roleName;
|
||||
final int roleId;
|
||||
const PerformPostLogs(
|
||||
{required this.checkerId,
|
||||
|
@ -52,6 +53,7 @@ class PerformPostLogs extends PassCheckEvent {
|
|||
required this.io,
|
||||
required this.otherInputs,
|
||||
required this.passerId,
|
||||
required this.roleName,
|
||||
required this.roleId,
|
||||
required this.stationId,
|
||||
required this.temp});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:unit2/utils/text_container.dart';
|
||||
import '../../model/profile/basic_information/primary-information.dart';
|
||||
import '../../model/rbac/assigned_role.dart';
|
||||
import '../../model/rbac/rbac.dart';
|
||||
|
@ -21,16 +22,15 @@ class RoleAssignmentBloc
|
|||
List<RBAC> roles = [];
|
||||
on<GetAssignedRoles>((event, emit) async {
|
||||
emit(RoleAssignmentLoadingState());
|
||||
fname = event.firstname;
|
||||
lname = event.lastname;
|
||||
fullname = "${event.firstname} ${event.lastname}";
|
||||
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 = "${fname!} ${lname!}";
|
||||
assignedRoles = await RbacRoleAssignmentServices.instance
|
||||
.getAssignedRoles(
|
||||
firstname: event.firstname, lastname: event.lastname);
|
||||
.getAssignedRoles(firstname: event.firstname, lastname: event.lastname);
|
||||
|
||||
if (roles.isEmpty) {
|
||||
roles = await RbacRoleServices.instance.getRbacRoles();
|
||||
|
@ -40,8 +40,6 @@ class RoleAssignmentBloc
|
|||
} else {
|
||||
emit(UserNotExistError());
|
||||
}
|
||||
|
||||
|
||||
} catch (e) {
|
||||
emit(RoleAssignmentErrorState(message: e.toString()));
|
||||
}
|
||||
|
|
|
@ -15,13 +15,14 @@ import '../../utils/scanner.dart';
|
|||
import '../../utils/text_container.dart';
|
||||
part 'user_event.dart';
|
||||
part 'user_state.dart';
|
||||
|
||||
class UserBloc extends Bloc<UserEvent, UserState> {
|
||||
UserData? _userData;
|
||||
VersionInfo? _versionInfo;
|
||||
String? _apkVersion;
|
||||
bool save = false;
|
||||
String? uuid;
|
||||
String? username;
|
||||
String? password;
|
||||
List<AssignedArea> establishmentPointPersonAssignedAreas = [];
|
||||
UserBloc() : super(UserInitial()) {
|
||||
//// 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();
|
||||
_apkVersion = apkVersion;
|
||||
final String? saved = CREDENTIALS?.get('saved');
|
||||
final String? username = CREDENTIALS?.get('username');
|
||||
final String? password = CREDENTIALS?.get('password');
|
||||
username = CREDENTIALS?.get('username');
|
||||
password = CREDENTIALS?.get('password');
|
||||
print(username);
|
||||
print(password);
|
||||
if (saved != null) {
|
||||
save = true;
|
||||
add(UserLogin(username: username, password: password));
|
||||
|
@ -46,8 +49,8 @@ class UserBloc extends Bloc<UserEvent, UserState> {
|
|||
emit(VersionLoaded(
|
||||
versionInfo: _versionInfo,
|
||||
apkVersion: _apkVersion,
|
||||
username: null,
|
||||
password: null));
|
||||
username: event.username,
|
||||
password: event.password));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(UserError(
|
||||
|
@ -57,14 +60,18 @@ class UserBloc extends Bloc<UserEvent, UserState> {
|
|||
});
|
||||
////Loading the current version of the app
|
||||
on<LoadVersion>((event, emit) {
|
||||
username = event.username;
|
||||
password = event.password;
|
||||
emit(VersionLoaded(
|
||||
versionInfo: _versionInfo,
|
||||
apkVersion: _apkVersion,
|
||||
username: event.username,
|
||||
password: event.password));
|
||||
username: username,
|
||||
password: password));
|
||||
});
|
||||
////userlogin
|
||||
on<UserLogin>((event, emit) async {
|
||||
username = event.username;
|
||||
password = event.password;
|
||||
try {
|
||||
Map<dynamic, dynamic> response = await AuthService.instance
|
||||
.webLogin(username: event.username, password: event.password);
|
||||
|
|
|
@ -6,9 +6,11 @@ abstract class UserEvent extends Equatable {
|
|||
}
|
||||
|
||||
class GetApkVersion extends UserEvent {
|
||||
GetApkVersion();
|
||||
final String username;
|
||||
final String password;
|
||||
GetApkVersion({required this.password, required this.username});
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
List<Object> get props => [username,password];
|
||||
}
|
||||
|
||||
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 'dart:convert';
|
||||
|
||||
import 'package:unit2/model/rbac/rbac.dart';
|
||||
|
||||
AssignedRole assignedRoleFromJson(String str) => AssignedRole.fromJson(json.decode(str));
|
||||
|
||||
String assignedRoleToJson(AssignedRole data) => json.encode(data.toJson());
|
||||
|
||||
class AssignedRole {
|
||||
final int? id;
|
||||
final Role? role;
|
||||
final RBAC? role;
|
||||
final CreatedBy? user;
|
||||
final DateTime? createdAt;
|
||||
final DateTime? updatedAt;
|
||||
|
@ -30,7 +32,7 @@ class AssignedRole {
|
|||
|
||||
factory AssignedRole.fromJson(Map<String, dynamic> json) => AssignedRole(
|
||||
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"]),
|
||||
createdAt:json["created_at"] == null?null: DateTime.parse(json["created_at"]),
|
||||
updatedAt: json["updated_at"] == null?null: DateTime.parse(json["updated_at"]),
|
||||
|
@ -84,47 +86,3 @@ class CreatedBy {
|
|||
"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';
|
||||
|
||||
class Purok {
|
||||
class PassCheckPurok {
|
||||
final String? purokid;
|
||||
final String? purokdesc;
|
||||
final BaragayAssignArea? brgy;
|
||||
|
@ -10,7 +10,7 @@ class Purok {
|
|||
final bool? writelock;
|
||||
final dynamic recordsignature;
|
||||
|
||||
Purok({
|
||||
PassCheckPurok({
|
||||
required this.purokid,
|
||||
required this.purokdesc,
|
||||
required this.brgy,
|
||||
|
@ -19,7 +19,7 @@ class Purok {
|
|||
required this.recordsignature,
|
||||
});
|
||||
|
||||
factory Purok.fromJson(Map<String, dynamic> json) => Purok(
|
||||
factory PassCheckPurok.fromJson(Map<String, dynamic> json) => PassCheckPurok(
|
||||
purokid: json["purokid"],
|
||||
purokdesc: json["purokdesc"],
|
||||
brgy: json["brgy"]==null?null:BaragayAssignArea.fromJson(json["brgy"]),
|
||||
|
|
|
@ -24,6 +24,7 @@ class EditBasicProfileInfoScreen extends StatefulWidget {
|
|||
State<EditBasicProfileInfoScreen> createState() =>
|
||||
_EditBasicProfileInfoScreenState();
|
||||
}
|
||||
|
||||
final bdayController = TextEditingController();
|
||||
ProfileOtherInfo? selectedIndigency;
|
||||
ProfileOtherInfo? selectedEthnicity;
|
||||
|
@ -36,13 +37,13 @@ String? selectedStatus;
|
|||
String? selectedExtension;
|
||||
final _formKey = GlobalKey<FormBuilderState>();
|
||||
|
||||
|
||||
class _EditBasicProfileInfoScreenState
|
||||
extends State<EditBasicProfileInfoScreen> {
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<ProfileBloc, ProfileState>(
|
||||
|
@ -52,7 +53,8 @@ class _EditBasicProfileInfoScreenState
|
|||
selectedSex = state.sexes.firstWhere((element) =>
|
||||
element.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) =>
|
||||
element.toLowerCase() ==
|
||||
state.primaryInformation.bloodType?.toLowerCase());
|
||||
|
@ -99,9 +101,6 @@ class _EditBasicProfileInfoScreenState
|
|||
state.primaryInformation.disability!.toLowerCase());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32),
|
||||
child: FormBuilder(
|
||||
|
@ -116,9 +115,7 @@ class _EditBasicProfileInfoScreenState
|
|||
),
|
||||
FormBuilderTextField(
|
||||
name: "lastname",
|
||||
inputFormatters: [
|
||||
UpperCaseTextFormatter()
|
||||
],
|
||||
inputFormatters: [UpperCaseTextFormatter()],
|
||||
initialValue: state.primaryInformation.lastName,
|
||||
decoration: normalTextFieldStyle("Last name *", ""),
|
||||
validator: FormBuilderValidators.required(
|
||||
|
@ -129,9 +126,7 @@ class _EditBasicProfileInfoScreenState
|
|||
),
|
||||
FormBuilderTextField(
|
||||
name: "firstname",
|
||||
inputFormatters: [
|
||||
UpperCaseTextFormatter()
|
||||
],
|
||||
inputFormatters: [UpperCaseTextFormatter()],
|
||||
initialValue: state.primaryInformation.firstName,
|
||||
decoration: normalTextFieldStyle("First name *", ""),
|
||||
validator: FormBuilderValidators.required(
|
||||
|
@ -146,12 +141,12 @@ class _EditBasicProfileInfoScreenState
|
|||
Flexible(
|
||||
flex: 2,
|
||||
child: FormBuilderTextField(
|
||||
inputFormatters: [
|
||||
UpperCaseTextFormatter()
|
||||
],
|
||||
inputFormatters: [UpperCaseTextFormatter()],
|
||||
name: "middlename",
|
||||
initialValue: state.primaryInformation.middleName??'',
|
||||
decoration: normalTextFieldStyle("Middle name", ""),
|
||||
initialValue:
|
||||
state.primaryInformation.middleName ?? '',
|
||||
decoration:
|
||||
normalTextFieldStyle("Middle name", ""),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
|
@ -164,13 +159,11 @@ class _EditBasicProfileInfoScreenState
|
|||
value: selectedExtension,
|
||||
decoration:
|
||||
normalTextFieldStyle("Name Extension", ""),
|
||||
|
||||
items: state.extensions
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
value: element, child: Text(element)))
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
|
||||
selectedExtension = e;
|
||||
},
|
||||
),
|
||||
|
@ -193,7 +186,8 @@ class _EditBasicProfileInfoScreenState
|
|||
errorText: "This field is required"),
|
||||
timeHintText: "Birthdate",
|
||||
decoration:
|
||||
normalTextFieldStyle("Birthdate *", "*").copyWith(
|
||||
normalTextFieldStyle("Birthdate *", "*")
|
||||
.copyWith(
|
||||
prefixIcon: const Icon(
|
||||
Icons.date_range,
|
||||
color: Colors.black87,
|
||||
|
@ -240,7 +234,8 @@ class _EditBasicProfileInfoScreenState
|
|||
initialValue: selectedBloodType,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
decoration: normalTextFieldStyle("Blood type *", ""),
|
||||
decoration:
|
||||
normalTextFieldStyle("Blood type *", ""),
|
||||
name: "bloodtype",
|
||||
items: state.bloodTypes
|
||||
.map((element) => DropdownMenuItem<String>(
|
||||
|
@ -259,7 +254,8 @@ class _EditBasicProfileInfoScreenState
|
|||
flex: 1,
|
||||
child: FormBuilderDropdown<String>(
|
||||
initialValue: selectedStatus,
|
||||
decoration: normalTextFieldStyle("Civil status *", ""),
|
||||
decoration:
|
||||
normalTextFieldStyle("Civil status *", ""),
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: "This field is required"),
|
||||
name: "extension",
|
||||
|
@ -309,7 +305,8 @@ class _EditBasicProfileInfoScreenState
|
|||
initialValue: state.primaryInformation.heightM
|
||||
.toString()
|
||||
.toString(),
|
||||
decoration: normalTextFieldStyle("Height (Meter) *", ""),
|
||||
decoration: normalTextFieldStyle(
|
||||
"Height (Meter) *", ""),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
|
@ -317,13 +314,13 @@ class _EditBasicProfileInfoScreenState
|
|||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
|
||||
child: FormBuilderTextField(
|
||||
validator: numericRequired,
|
||||
name: "weigth",
|
||||
initialValue:
|
||||
state.primaryInformation.weightKg!.toString(),
|
||||
decoration: normalTextFieldStyle("Weight (Kg) *", ""),
|
||||
initialValue: state.primaryInformation.weightKg!
|
||||
.toString(),
|
||||
decoration:
|
||||
normalTextFieldStyle("Weight (Kg) *", ""),
|
||||
),
|
||||
),
|
||||
]),
|
||||
|
@ -338,7 +335,8 @@ class _EditBasicProfileInfoScreenState
|
|||
flex: 1,
|
||||
child: FormBuilderTextField(
|
||||
name: "prefix",
|
||||
initialValue: state.primaryInformation.titlePrefix
|
||||
initialValue: state
|
||||
.primaryInformation.titlePrefix
|
||||
.toString()
|
||||
.toString(),
|
||||
decoration: normalTextFieldStyle(
|
||||
|
@ -352,7 +350,8 @@ class _EditBasicProfileInfoScreenState
|
|||
flex: 1,
|
||||
child: FormBuilderTextField(
|
||||
name: "suffix",
|
||||
initialValue: state.primaryInformation.titleSuffix,
|
||||
initialValue:
|
||||
state.primaryInformation.titleSuffix,
|
||||
decoration: normalTextFieldStyle(
|
||||
"Title Suffix", "PhD.,MD.,MS.,CE"),
|
||||
),
|
||||
|
@ -371,7 +370,8 @@ class _EditBasicProfileInfoScreenState
|
|||
child: DropdownButtonFormField<ProfileOtherInfo>(
|
||||
isExpanded: true,
|
||||
value: selectedIndigency,
|
||||
decoration: normalTextFieldStyle("Indigency", ""),
|
||||
decoration:
|
||||
normalTextFieldStyle("Indigency", ""),
|
||||
items: state.indigenous
|
||||
.map((element) =>
|
||||
DropdownMenuItem<ProfileOtherInfo>(
|
||||
|
@ -392,7 +392,8 @@ class _EditBasicProfileInfoScreenState
|
|||
child: DropdownButtonFormField<ProfileOtherInfo>(
|
||||
isExpanded: true,
|
||||
value: selectedEthnicity,
|
||||
decoration: normalTextFieldStyle("Ethnicity", ""),
|
||||
decoration:
|
||||
normalTextFieldStyle("Ethnicity", ""),
|
||||
items: state.ethnicity
|
||||
.map((element) =>
|
||||
DropdownMenuItem<ProfileOtherInfo>(
|
||||
|
@ -402,8 +403,7 @@ class _EditBasicProfileInfoScreenState
|
|||
onChanged: (e) {
|
||||
selectedEthnicity = e;
|
||||
print(selectedEthnicity!.name);
|
||||
print(selectedEthnicity!
|
||||
.id);
|
||||
print(selectedEthnicity!.id);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
@ -421,7 +421,8 @@ class _EditBasicProfileInfoScreenState
|
|||
child: DropdownButtonFormField<ProfileOtherInfo>(
|
||||
isExpanded: true,
|
||||
value: selectedReligion,
|
||||
decoration: normalTextFieldStyle("Religion", ""),
|
||||
decoration:
|
||||
normalTextFieldStyle("Religion", ""),
|
||||
items: state.religion
|
||||
.map((element) =>
|
||||
DropdownMenuItem<ProfileOtherInfo>(
|
||||
|
@ -440,10 +441,10 @@ class _EditBasicProfileInfoScreenState
|
|||
Flexible(
|
||||
flex: 1,
|
||||
child: DropdownButtonFormField<ProfileOtherInfo>(
|
||||
|
||||
isExpanded: true,
|
||||
value: selectedDisability,
|
||||
decoration: normalTextFieldStyle("Disability", ""),
|
||||
decoration:
|
||||
normalTextFieldStyle("Disability", ""),
|
||||
items: state.disability
|
||||
.map((element) =>
|
||||
DropdownMenuItem<ProfileOtherInfo>(
|
||||
|
@ -464,31 +465,34 @@ class _EditBasicProfileInfoScreenState
|
|||
width: double.infinity,
|
||||
height: 60,
|
||||
child: ElevatedButton(
|
||||
style:
|
||||
mainBtnStyle(primary, Colors.transparent, second),
|
||||
style: mainBtnStyle(
|
||||
primary, Colors.transparent, second),
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.saveAndValidate()) {
|
||||
String lastName =
|
||||
_formKey.currentState!.value['lastname'];
|
||||
String firstName =
|
||||
_formKey.currentState!.value['firstname'];
|
||||
String? middleName =
|
||||
_formKey.currentState?.value['middlename'];
|
||||
String? middleName = _formKey
|
||||
.currentState?.value['middlename'];
|
||||
String? pref =
|
||||
_formKey.currentState?.value['prefix'];
|
||||
String suf = _formKey.currentState?.value['suffix'];
|
||||
String suf =
|
||||
_formKey.currentState?.value['suffix'];
|
||||
DateTime birthdate =
|
||||
DateTime.parse(bdayController.text);
|
||||
double? hM =
|
||||
_formKey.currentState!.value['height'] == null
|
||||
_formKey.currentState!.value['height'] ==
|
||||
null
|
||||
? null
|
||||
: double.tryParse(
|
||||
_formKey.currentState?.value['height']);
|
||||
: double.tryParse(_formKey
|
||||
.currentState?.value['height']);
|
||||
double? wKg =
|
||||
_formKey.currentState!.value['weigth'] == null
|
||||
_formKey.currentState!.value['weigth'] ==
|
||||
null
|
||||
? null
|
||||
: double.tryParse(
|
||||
_formKey.currentState?.value['weigth']);
|
||||
: double.tryParse(_formKey
|
||||
.currentState?.value['weigth']);
|
||||
Profile primaryInformation = Profile(
|
||||
webuserId: null,
|
||||
id: state.primaryInformation.id,
|
||||
|
@ -499,14 +503,21 @@ class _EditBasicProfileInfoScreenState
|
|||
sex: selectedSex,
|
||||
birthdate: birthdate,
|
||||
civilStatus: selectedStatus,
|
||||
bloodType: selectedBloodType =="NONE"?null:selectedBloodType,
|
||||
bloodType: selectedBloodType == "NONE"
|
||||
? null
|
||||
: selectedBloodType,
|
||||
heightM: hM,
|
||||
weightKg: wKg,
|
||||
photoPath: state.primaryInformation.photoPath,
|
||||
esigPath: state.primaryInformation.esigPath,
|
||||
maidenName: state.primaryInformation.maidenName,
|
||||
deceased: state.primaryInformation.deceased,
|
||||
uuidQrcode: state.primaryInformation.uuidQrcode,
|
||||
photoPath:
|
||||
state.primaryInformation.photoPath,
|
||||
esigPath:
|
||||
state.primaryInformation.esigPath,
|
||||
maidenName:
|
||||
state.primaryInformation.maidenName,
|
||||
deceased:
|
||||
state.primaryInformation.deceased,
|
||||
uuidQrcode:
|
||||
state.primaryInformation.uuidQrcode,
|
||||
titlePrefix: pref,
|
||||
titleSuffix: suf,
|
||||
showTitleId:
|
||||
|
@ -525,7 +536,8 @@ class _EditBasicProfileInfoScreenState
|
|||
genderId: selectedGender?.id,
|
||||
indigencyId: selectedIndigency?.id,
|
||||
profileId: widget.profileId,
|
||||
profileInformation: primaryInformation,
|
||||
profileInformation:
|
||||
primaryInformation,
|
||||
religionId: selectedReligion?.id,
|
||||
token: widget.token));
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.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:intl/intl.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/theme-data.dart/colors.dart';
|
||||
import 'package:unit2/theme-data.dart/form-style.dart';
|
||||
|
@ -30,6 +31,7 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
|
|||
Widget build(BuildContext context) {
|
||||
bool enabled = false;
|
||||
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
|
||||
Profile? profile;
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: context.watch<ProfileBloc>().state
|
||||
|
@ -62,7 +64,10 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
|
|||
padding: const EdgeInsets.all(24),
|
||||
backgroundColor: Colors.black87,
|
||||
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
|
||||
child: BlocConsumer<ProfileBloc, ProfileState>(
|
||||
child: BlocBuilder<UserBloc, UserState>(
|
||||
builder: (context, state) {
|
||||
if (state is UserLoggedIn) {
|
||||
return BlocConsumer<ProfileBloc, ProfileState>(
|
||||
listener: (context, state) {
|
||||
if (state is BasicPrimaryInformationLoadingState) {
|
||||
final progress = ProgressHUD.of(context);
|
||||
|
@ -76,36 +81,49 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
|
|||
progress!.dismiss();
|
||||
}
|
||||
if (state is BasicProfileInfoEditedState) {
|
||||
profile = Profile.fromJson(state.response['data']);
|
||||
if (state.response['success']) {
|
||||
successAlert(context, "Updated Successfull!",
|
||||
state.response['message'], () {
|
||||
Navigator.of(context).pop();
|
||||
context.read<ProfileBloc>().add(LoadBasicPrimaryInfo());
|
||||
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());
|
||||
context
|
||||
.read<ProfileBloc>()
|
||||
.add(LoadBasicPrimaryInfo());
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
if (state is BasicInformationProfileLoaded) {
|
||||
profile = state.primaryBasicInformation;
|
||||
return Container(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 24, horizontal: 24),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 24, horizontal: 24),
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 28,
|
||||
),
|
||||
FormBuilderTextField(
|
||||
enabled: enabled,
|
||||
enabled: false,
|
||||
name: lastname,
|
||||
initialValue: state.primaryBasicInformation.lastName!,
|
||||
decoration: normalTextFieldStyle("Last name", ""),
|
||||
initialValue:
|
||||
state.primaryBasicInformation.lastName!,
|
||||
style: const TextStyle(color: Colors.black),
|
||||
decoration: normalTextFieldStyle("Last name", "")
|
||||
.copyWith(
|
||||
disabledBorder:
|
||||
const OutlineInputBorder(),
|
||||
labelStyle:
|
||||
const TextStyle(color: Colors.black)),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
|
@ -113,8 +131,15 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
|
|||
FormBuilderTextField(
|
||||
enabled: enabled,
|
||||
name: firstname,
|
||||
initialValue: state.primaryBasicInformation.firstName!,
|
||||
decoration: normalTextFieldStyle("First name", ""),
|
||||
initialValue:
|
||||
state.primaryBasicInformation.firstName!,
|
||||
style: const TextStyle(color: Colors.black),
|
||||
decoration: normalTextFieldStyle("First name", "")
|
||||
.copyWith(
|
||||
disabledBorder:
|
||||
const OutlineInputBorder(),
|
||||
labelStyle:
|
||||
const TextStyle(color: Colors.black)),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
|
@ -127,10 +152,17 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
|
|||
child: FormBuilderTextField(
|
||||
enabled: enabled,
|
||||
name: middlename,
|
||||
initialValue: state.primaryBasicInformation.middleName??''
|
||||
,
|
||||
initialValue: state.primaryBasicInformation
|
||||
.middleName ??
|
||||
'',
|
||||
style: const TextStyle(color: Colors.black),
|
||||
decoration:
|
||||
normalTextFieldStyle("Middle name", ""),
|
||||
normalTextFieldStyle("Middle name", "")
|
||||
.copyWith(
|
||||
disabledBorder:
|
||||
const OutlineInputBorder(),
|
||||
labelStyle: const TextStyle(
|
||||
color: Colors.black)),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
|
@ -143,8 +175,14 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
|
|||
name: extensionName,
|
||||
initialValue: state.primaryBasicInformation
|
||||
.nameExtension ??= 'N/A',
|
||||
decoration:
|
||||
normalTextFieldStyle("Name extension", ""),
|
||||
style: const TextStyle(color: Colors.black),
|
||||
decoration: normalTextFieldStyle(
|
||||
"Name extension", "")
|
||||
.copyWith(
|
||||
disabledBorder:
|
||||
const OutlineInputBorder(),
|
||||
labelStyle: const TextStyle(
|
||||
color: Colors.black)),
|
||||
),
|
||||
)
|
||||
]),
|
||||
|
@ -160,10 +198,16 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
|
|||
child: FormBuilderTextField(
|
||||
enabled: enabled,
|
||||
name: extensionName,
|
||||
initialValue: dteFormat2.format(
|
||||
state.primaryBasicInformation.birthdate!),
|
||||
initialValue: dteFormat2.format(state
|
||||
.primaryBasicInformation.birthdate!),
|
||||
style: const TextStyle(color: Colors.black),
|
||||
decoration:
|
||||
normalTextFieldStyle("Birth date", ""),
|
||||
normalTextFieldStyle("Birth date", "")
|
||||
.copyWith(
|
||||
disabledBorder:
|
||||
const OutlineInputBorder(),
|
||||
labelStyle: const TextStyle(
|
||||
color: Colors.black)),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
|
@ -174,8 +218,15 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
|
|||
child: FormBuilderTextField(
|
||||
enabled: enabled,
|
||||
name: sex,
|
||||
initialValue: state.primaryBasicInformation.sex!,
|
||||
decoration: normalTextFieldStyle("Sex", ""),
|
||||
initialValue:
|
||||
state.primaryBasicInformation.sex!,
|
||||
style: const TextStyle(color: Colors.black),
|
||||
decoration: normalTextFieldStyle("Sex", "")
|
||||
.copyWith(
|
||||
disabledBorder:
|
||||
const OutlineInputBorder(),
|
||||
labelStyle: const TextStyle(
|
||||
color: Colors.black)),
|
||||
),
|
||||
)
|
||||
]),
|
||||
|
@ -191,10 +242,16 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
|
|||
child: FormBuilderTextField(
|
||||
enabled: enabled,
|
||||
name: "bloodType",
|
||||
initialValue:
|
||||
state.primaryBasicInformation.bloodType!,
|
||||
initialValue: state
|
||||
.primaryBasicInformation.bloodType!,
|
||||
style: const TextStyle(color: Colors.black),
|
||||
decoration:
|
||||
normalTextFieldStyle("Blood type", ""),
|
||||
normalTextFieldStyle("Blood type", "")
|
||||
.copyWith(
|
||||
disabledBorder:
|
||||
const OutlineInputBorder(),
|
||||
labelStyle: const TextStyle(
|
||||
color: Colors.black)),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
|
@ -205,10 +262,16 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
|
|||
child: FormBuilderTextField(
|
||||
enabled: enabled,
|
||||
name: "civilStatus",
|
||||
initialValue:
|
||||
state.primaryBasicInformation.civilStatus!,
|
||||
initialValue: state
|
||||
.primaryBasicInformation.civilStatus!,
|
||||
style: const TextStyle(color: Colors.black),
|
||||
decoration:
|
||||
normalTextFieldStyle("Civil Status", ""),
|
||||
normalTextFieldStyle("Civil Status", "")
|
||||
.copyWith(
|
||||
disabledBorder:
|
||||
const OutlineInputBorder(),
|
||||
labelStyle: const TextStyle(
|
||||
color: Colors.black)),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
|
@ -219,9 +282,16 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
|
|||
child: FormBuilderTextField(
|
||||
enabled: enabled,
|
||||
name: "gender",
|
||||
initialValue: state
|
||||
.primaryBasicInformation.gender ??= "N/A",
|
||||
decoration: normalTextFieldStyle("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)),
|
||||
),
|
||||
),
|
||||
]),
|
||||
|
@ -241,7 +311,14 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
|
|||
initialValue: state
|
||||
.primaryBasicInformation.heightM!
|
||||
.toString(),
|
||||
decoration: normalTextFieldStyle("Height", ""),
|
||||
style: const TextStyle(color: Colors.black),
|
||||
decoration:
|
||||
normalTextFieldStyle("Height", "")
|
||||
.copyWith(
|
||||
disabledBorder:
|
||||
const OutlineInputBorder(),
|
||||
labelStyle: const TextStyle(
|
||||
color: Colors.black)),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
|
@ -255,7 +332,14 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
|
|||
initialValue: state
|
||||
.primaryBasicInformation.weightKg!
|
||||
.toString(),
|
||||
decoration: normalTextFieldStyle("Weight", ""),
|
||||
style: const TextStyle(color: Colors.black),
|
||||
decoration:
|
||||
normalTextFieldStyle("Weight", "")
|
||||
.copyWith(
|
||||
disabledBorder:
|
||||
const OutlineInputBorder(),
|
||||
labelStyle: const TextStyle(
|
||||
color: Colors.black)),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
|
@ -268,41 +352,14 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
|
|||
name: prefixSuffix,
|
||||
initialValue:
|
||||
"${state.primaryBasicInformation.titlePrefix ??= "NA"} | ${state.primaryBasicInformation.titleSuffix ??= "N/A"}",
|
||||
style: const TextStyle(color: Colors.black),
|
||||
decoration: normalTextFieldStyle(
|
||||
"Title Prefix and Suffix", ""),
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
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", ""),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FormBuilderTextField(
|
||||
enabled: enabled,
|
||||
name: width,
|
||||
initialValue: state
|
||||
.primaryBasicInformation.ethnicity ??= "N/A",
|
||||
decoration: normalTextFieldStyle("Ethnicity", ""),
|
||||
"Title Prefix and Suffix", "")
|
||||
.copyWith(
|
||||
disabledBorder:
|
||||
const OutlineInputBorder(),
|
||||
labelStyle: const TextStyle(
|
||||
color: Colors.black)),
|
||||
),
|
||||
),
|
||||
]),
|
||||
|
@ -320,8 +377,61 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
|
|||
enabled: enabled,
|
||||
name: height,
|
||||
initialValue: state
|
||||
.primaryBasicInformation.religion ??= "N/A",
|
||||
decoration: normalTextFieldStyle("Religion", ""),
|
||||
.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(
|
||||
|
@ -333,10 +443,16 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
|
|||
maxLines: 2,
|
||||
enabled: enabled,
|
||||
name: width,
|
||||
initialValue: state
|
||||
.primaryBasicInformation.disability ??= "N/A",
|
||||
initialValue: state.primaryBasicInformation
|
||||
.disability ??= "N/A",
|
||||
style: const TextStyle(color: Colors.black),
|
||||
decoration:
|
||||
normalTextFieldStyle("Disability", ""),
|
||||
normalTextFieldStyle("Disability", "")
|
||||
.copyWith(
|
||||
disabledBorder:
|
||||
const OutlineInputBorder(),
|
||||
labelStyle: const TextStyle(
|
||||
color: Colors.black)),
|
||||
),
|
||||
),
|
||||
]),
|
||||
|
@ -349,7 +465,9 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
|
|||
return SomethingWentWrong(
|
||||
message: state.message,
|
||||
onpressed: () {
|
||||
context.read<ProfileBloc>().add(LoadBasicPrimaryInfo());
|
||||
context
|
||||
.read<ProfileBloc>()
|
||||
.add(LoadBasicPrimaryInfo());
|
||||
});
|
||||
}
|
||||
if (state is BasicInformationEditingState) {
|
||||
|
@ -358,6 +476,10 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
|
|||
}
|
||||
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/voluntary_works_screen.dart';
|
||||
import 'package:unit2/theme-data.dart/colors.dart';
|
||||
import 'package:unit2/utils/global.dart';
|
||||
import 'package:unit2/widgets/error_state.dart';
|
||||
import '../../bloc/profile/eligibility/eligibility_bloc.dart';
|
||||
import '../../bloc/profile/family/family_bloc.dart';
|
||||
|
@ -69,8 +70,12 @@ class ProfileInfo extends StatelessWidget {
|
|||
if (state is UserLoggedIn) {
|
||||
profileId = state.userData!.user!.login!.user!.profileId;
|
||||
token = state.userData!.user!.login!.token!;
|
||||
if (globalCurrentProfile == null) {
|
||||
profile = state.userData!.employeeInfo!.profile!;
|
||||
|
||||
} else {
|
||||
profile = globalCurrentProfile!;
|
||||
}
|
||||
print(profile.lastName);
|
||||
return BlocConsumer<ProfileBloc, ProfileState>(
|
||||
listener: (
|
||||
context,
|
||||
|
|
|
@ -172,7 +172,6 @@ class RbacAgencyScreen extends StatelessWidget {
|
|||
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
|
||||
child: BlocConsumer<AgencyBloc, AgencyState>(
|
||||
listener: (context, state) {
|
||||
print(state);
|
||||
if (state is AgencyLoadingState) {
|
||||
final progress = ProgressHUD.of(context);
|
||||
progress!.showWithText("Please wait...");
|
||||
|
@ -235,7 +234,6 @@ class RbacAgencyScreen extends StatelessWidget {
|
|||
decoration: box1(),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12, vertical: 8),
|
||||
child: Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
|
@ -254,7 +252,7 @@ class RbacAgencyScreen extends StatelessWidget {
|
|||
color: primary)),
|
||||
),
|
||||
],
|
||||
)),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
|
@ -266,8 +264,7 @@ class RbacAgencyScreen extends StatelessWidget {
|
|||
return const EmptyData(
|
||||
message: "No Object available. Please click + to add.");
|
||||
}
|
||||
}
|
||||
if (state is AgencyErrorState) {
|
||||
}if (state is AgencyErrorState) {
|
||||
return SomethingWentWrong(
|
||||
message: state.message,
|
||||
onpressed: () {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -213,7 +213,7 @@ class RbacRoleAssignment extends StatelessWidget {
|
|||
Flexible(
|
||||
child: Text(
|
||||
state.assignedRoles[index].role!
|
||||
.name,
|
||||
.name!,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium!
|
||||
|
@ -262,8 +262,8 @@ class RbacRoleAssignment extends StatelessWidget {
|
|||
],
|
||||
);
|
||||
} else {
|
||||
return const EmptyData(
|
||||
message: "No Role available. Please click + to add.");
|
||||
return EmptyData(
|
||||
message: "No Role available for ${state.fullname}. Please click + to add.");
|
||||
}
|
||||
}
|
||||
if (state is RoleAssignmentErrorState) {
|
||||
|
|
|
@ -46,46 +46,45 @@ class BasicInfo extends StatelessWidget {
|
|||
alignment: Alignment.center,
|
||||
children: [
|
||||
const CoverImage(),
|
||||
Positioned(
|
||||
top: blockSizeVertical * 15.5,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
CachedNetworkImage(
|
||||
imageUrl: fileUrl,
|
||||
imageBuilder: (context, imageProvider) =>
|
||||
Container(
|
||||
width: 160,
|
||||
height: 160,
|
||||
decoration: BoxDecoration(
|
||||
border:
|
||||
Border.all(color: Colors.black26, width: 3),
|
||||
shape: BoxShape.circle,
|
||||
image: DecorationImage(
|
||||
image: imageProvider,
|
||||
fit: BoxFit.cover),
|
||||
),
|
||||
),
|
||||
placeholder: (context, url) =>
|
||||
const CircularProgressIndicator(),
|
||||
errorWidget: (context, url, error) =>
|
||||
Container(
|
||||
width: 160,
|
||||
height: 160,
|
||||
decoration: BoxDecoration(
|
||||
border:
|
||||
Border.all(color: Colors.white, width: 3),
|
||||
shape: BoxShape.circle,
|
||||
|
||||
),
|
||||
child: SvgPicture.asset(
|
||||
'assets/svgs/male.svg',
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Positioned(
|
||||
// top: blockSizeVertical * 15.5,
|
||||
// child: Stack(
|
||||
// alignment: Alignment.center,
|
||||
// children: [
|
||||
// CachedNetworkImage(
|
||||
// imageUrl: fileUrl,
|
||||
// imageBuilder: (context, imageProvider) =>
|
||||
// Container(
|
||||
// width: 160,
|
||||
// height: 160,
|
||||
// decoration: BoxDecoration(
|
||||
// border: Border.all(
|
||||
// color: Colors.black26, width: 3),
|
||||
// shape: BoxShape.circle,
|
||||
// image: DecorationImage(
|
||||
// image: imageProvider,
|
||||
// fit: BoxFit.cover),
|
||||
// ),
|
||||
// ),
|
||||
// placeholder: (context, url) =>
|
||||
// const CircularProgressIndicator(),
|
||||
// errorWidget: (context, url, error) =>
|
||||
// Container(
|
||||
// width: 160,
|
||||
// height: 160,
|
||||
// decoration: BoxDecoration(
|
||||
// border: Border.all(
|
||||
// color: Colors.white, width: 3),
|
||||
// shape: BoxShape.circle,
|
||||
// ),
|
||||
// child: SvgPicture.asset(
|
||||
// 'assets/svgs/male.svg',
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
Positioned(
|
||||
top: 10,
|
||||
left: 20,
|
||||
|
@ -138,14 +137,15 @@ class BuildInformation extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
|
||||
final String firstName =
|
||||
userData.user!.login!.user!.firstName!.toUpperCase();
|
||||
final String lastname = userData.user!.login!.user!.lastName!.toUpperCase();
|
||||
final String? middlename = userData.employeeInfo == null
|
||||
globalFistname = globalFistname ?? userData.user!.login!.user!.firstName!.toUpperCase();
|
||||
globalLastname =globalLastname ?? userData.user!.login!.user!.lastName!.toUpperCase();
|
||||
globalMiddleName = globalMiddleName == null
|
||||
? (userData.employeeInfo == null
|
||||
? ''
|
||||
: userData.employeeInfo!.profile?.middleName?.toUpperCase();
|
||||
final String sex = userData.employeeInfo!.profile!.sex!.toUpperCase();
|
||||
final DateTime? bday = userData.employeeInfo!.profile!.birthdate;
|
||||
: userData.employeeInfo!.profile?.middleName?.toUpperCase())
|
||||
: '';
|
||||
globalSex = globalSex ?? userData.employeeInfo!.profile!.sex!.toUpperCase();
|
||||
globalBday = globalBday ?? userData.employeeInfo!.profile!.birthdate;
|
||||
final uuid = userData.employeeInfo!.uuid;
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 25),
|
||||
|
@ -156,7 +156,7 @@ class BuildInformation extends StatelessWidget {
|
|||
height: 25,
|
||||
),
|
||||
Text(
|
||||
"$firstName ${middlename ?? ''} $lastname",
|
||||
"$globalFistname ${globalMiddleName ?? ''} $globalLastname",
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
|
@ -167,7 +167,7 @@ class BuildInformation extends StatelessWidget {
|
|||
height: 10,
|
||||
),
|
||||
Text(
|
||||
"${dteFormat2.format(bday!)} | $sex",
|
||||
"${dteFormat2.format(globalBday!)} | $sex",
|
||||
style:
|
||||
Theme.of(context).textTheme.bodySmall!.copyWith(fontSize: 18),
|
||||
),
|
||||
|
|
|
@ -76,9 +76,6 @@ class _DashBoardState extends State<DashBoard> {
|
|||
tempUnit2Cards = unit2Cards.sublist(0, 4);
|
||||
}
|
||||
|
||||
superadminCards.forEach((el) {
|
||||
print(el.object.name);
|
||||
});
|
||||
|
||||
return Container(
|
||||
padding:
|
||||
|
|
|
@ -24,11 +24,15 @@ IconData? iconGenerator({required String name}) {
|
|||
return FontAwesome.box;
|
||||
} else if (name.toLowerCase() == 'permission') {
|
||||
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;
|
||||
} else if (name.toLowerCase() == 'purok') {
|
||||
return WebSymbols.list_numbered;
|
||||
} else if (name.toLowerCase() == 'barangay') {
|
||||
} else if (name.toLowerCase() == 'baranggay') {
|
||||
return Maki.industrial_building;
|
||||
} else if (name.toLowerCase() == 'role module') {
|
||||
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: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/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_objects/module_objects_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/station/station_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/object/object_screen.dart';
|
||||
import 'package:unit2/screens/superadmin/operation/operation_screen.dart';
|
||||
|
@ -49,6 +51,7 @@ class SuperAdminMenu extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final roleAssignmentKey = GlobalKey<FormBuilderState>();
|
||||
final areaKey = GlobalKey<FormBuilderState>();
|
||||
return AnimationConfiguration.staggeredGrid(
|
||||
position: index,
|
||||
columnCount: columnCount,
|
||||
|
@ -74,12 +77,9 @@ class SuperAdminMenu extends StatelessWidget {
|
|||
object.moduleName == 'superadmin'
|
||||
? CardLabel(
|
||||
icon: iconGenerator(name: object.object.name!),
|
||||
title:
|
||||
object.object.name!,
|
||||
title: object.object.name!,
|
||||
ontap: () {
|
||||
|
||||
if (object.object.name == 'Role') {
|
||||
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return BlocProvider(
|
||||
|
@ -156,9 +156,7 @@ class SuperAdminMenu extends StatelessWidget {
|
|||
return BlocProvider(
|
||||
create: (context) =>
|
||||
AgencyBloc()..add(GetAgencies()),
|
||||
child: RbacAgencyScreen(
|
||||
|
||||
),
|
||||
child: const RbacAgencyScreen(),
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
@ -211,6 +209,98 @@ class SuperAdminMenu extends StatelessWidget {
|
|||
);
|
||||
}));
|
||||
}
|
||||
////////////////////////////////
|
||||
if (object.object.name == 'Area') {
|
||||
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(
|
||||
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(
|
||||
|
@ -219,10 +309,13 @@ class SuperAdminMenu extends StatelessWidget {
|
|||
return AlertDialog(
|
||||
title: Row(
|
||||
children: [
|
||||
const Expanded(child: Text("Search User")),
|
||||
IconButton(onPressed: (){
|
||||
const Expanded(
|
||||
child: Text("Search User")),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
}, icon: const Icon(Icons.close))
|
||||
},
|
||||
icon: const Icon(Icons.close))
|
||||
],
|
||||
),
|
||||
content: FormBuilder(
|
||||
|
@ -262,7 +355,6 @@ class SuperAdminMenu extends StatelessWidget {
|
|||
if (roleAssignmentKey
|
||||
.currentState!
|
||||
.saveAndValidate()) {
|
||||
|
||||
String fname =
|
||||
roleAssignmentKey
|
||||
.currentState!
|
||||
|
@ -279,11 +371,19 @@ class SuperAdminMenu extends StatelessWidget {
|
|||
return BlocProvider(
|
||||
create: (context) =>
|
||||
RoleAssignmentBloc()
|
||||
..add(GetAssignedRoles(
|
||||
..add(
|
||||
GetAssignedRoles(
|
||||
firstname:
|
||||
fname,
|
||||
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> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final String firstName =
|
||||
final String firstName =globalFistname??
|
||||
widget.userData!.user!.login!.user!.firstName!.toUpperCase();
|
||||
final String lastname =
|
||||
final String lastname = globalLastname??
|
||||
widget.userData!.user!.login!.user!.lastName!.toUpperCase();
|
||||
return Drawer(
|
||||
child: SizedBox(
|
||||
|
|
|
@ -20,8 +20,10 @@ class _MainScreenState extends State<MainScreen> {
|
|||
List<Role> roles = [];
|
||||
List<DisplayCard> cards = [];
|
||||
int? userId;
|
||||
DateTime? ctime;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
setState(() {
|
||||
cards.clear();
|
||||
cards=[];
|
||||
|
@ -52,7 +54,21 @@ class _MainScreenState extends State<MainScreen> {
|
|||
}
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
return WillPopScope(
|
||||
onWillPop: () {
|
||||
DateTime now = DateTime.now();
|
||||
if (ctime == null || now.difference(ctime!) > const Duration(seconds: 2)) {
|
||||
//add duration of press gap
|
||||
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(
|
||||
appBar: AppBar(
|
||||
backgroundColor: primary,
|
||||
leading: IconButton(
|
||||
|
@ -80,6 +96,7 @@ class _MainScreenState extends State<MainScreen> {
|
|||
cards: cards,
|
||||
)
|
||||
: const NoModule(),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
|
|
|
@ -22,7 +22,6 @@ import '../../../theme-data.dart/colors.dart';
|
|||
import '../../../theme-data.dart/form-style.dart';
|
||||
import '../../../theme-data.dart/btn-style.dart';
|
||||
import './components/login-via-qr-label.dart';
|
||||
import './functions/press-again-to-exit.dart';
|
||||
|
||||
class UniT2Login extends StatefulWidget {
|
||||
const UniT2Login({super.key});
|
||||
|
@ -37,17 +36,30 @@ class _UniT2LoginState extends State<UniT2Login> {
|
|||
bool _showPassword = true;
|
||||
String? password;
|
||||
String? username;
|
||||
DateTime? ctime;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
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(
|
||||
body: ProgressHUD(
|
||||
backgroundColor: Colors.black87,
|
||||
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
|
||||
child: BlocConsumer<UserBloc, UserState>(listener: (context, state) {
|
||||
print(state);
|
||||
if (state is UserLoggedIn || state is UuidLoaded || state is LoginErrorState) {
|
||||
if (state is UserLoggedIn ||
|
||||
state is UuidLoaded ||
|
||||
state is LoginErrorState) {
|
||||
final progress = ProgressHUD.of(context);
|
||||
progress!.dismiss();
|
||||
}
|
||||
|
@ -94,10 +106,9 @@ class _UniT2LoginState extends State<UniT2Login> {
|
|||
}));
|
||||
}
|
||||
}, builder: (context, state) {
|
||||
print(state);
|
||||
if (state is VersionLoaded) {
|
||||
return Builder(builder: (context) {
|
||||
if (state.versionInfo!.version != state.apkVersion) {
|
||||
if (state.versionInfo?.version != state.apkVersion) {
|
||||
return SizedBox(
|
||||
child: SingleChildScrollView(
|
||||
child: Stack(
|
||||
|
@ -355,7 +366,7 @@ class _UniT2LoginState extends State<UniT2Login> {
|
|||
onpressed: () {
|
||||
BlocProvider.of<UserBloc>(
|
||||
NavigationService.navigatorKey.currentContext!)
|
||||
.add(GetApkVersion());
|
||||
.add(LoadVersion(username: username, password: password));
|
||||
return MaterialPageRoute(builder: (_) {
|
||||
return const UniT2Login();
|
||||
});
|
||||
|
@ -374,7 +385,7 @@ class _UniT2LoginState extends State<UniT2Login> {
|
|||
onpressed: () {
|
||||
BlocProvider.of<UserBloc>(
|
||||
NavigationService.navigatorKey.currentContext!)
|
||||
.add(GetApkVersion());
|
||||
.add(LoadVersion(username: username, password: password));
|
||||
return MaterialPageRoute(builder: (_) {
|
||||
return const UniT2Login();
|
||||
});
|
||||
|
|
|
@ -158,11 +158,11 @@ class EstPointPersonRoleAssignmentScreen extends StatelessWidget {
|
|||
if (!assignedRoles.keys.contains(fullName)) {
|
||||
assignedRoles.addAll({fullName: []});
|
||||
assignedRoles[fullName]!.add(Content(
|
||||
id: assignedRole.id!, name: assignedRole.role!.name));
|
||||
id: assignedRole.id!, name: assignedRole.role!.name!));
|
||||
} else {
|
||||
assignedRoles[fullName]!.add(Content(
|
||||
id: assignedRole.id!,
|
||||
name: assignedRole.role!.name));
|
||||
name: assignedRole.role!.name!));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,9 +116,9 @@ class PassCheckServices {
|
|||
}
|
||||
////PUROK
|
||||
if (assignRoleAreaType.areaTypeName.toLowerCase() == 'purok') {
|
||||
List<Purok> assignedArea = [];
|
||||
List<PassCheckPurok> assignedArea = [];
|
||||
data['data'][0]['assigned_area'].forEach((var element) {
|
||||
Purok purok = Purok.fromJson(element['area']);
|
||||
PassCheckPurok purok = PassCheckPurok.fromJson(element['area']);
|
||||
assignedArea.add(purok);
|
||||
});
|
||||
statusResponse = assignedArea;
|
||||
|
@ -172,7 +172,7 @@ class PassCheckServices {
|
|||
double? temp,
|
||||
int? stationId,
|
||||
String? cpId,
|
||||
required int roleid}) async {
|
||||
required RoleIdRoleName roleIdRoleName}) async {
|
||||
String path = Url.instance.postLogs();
|
||||
bool success;
|
||||
Map<String, String> headers = {
|
||||
|
@ -182,9 +182,8 @@ class PassCheckServices {
|
|||
};
|
||||
Map body;
|
||||
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") {
|
||||
print("1");
|
||||
body = {
|
||||
"station_id": stationId,
|
||||
"temperature": temp,
|
||||
|
@ -193,7 +192,6 @@ class PassCheckServices {
|
|||
"io": io
|
||||
};
|
||||
} else {
|
||||
print("2");
|
||||
body = {
|
||||
"station_id": stationId,
|
||||
"destination": destination,
|
||||
|
@ -203,7 +201,6 @@ class PassCheckServices {
|
|||
};
|
||||
}
|
||||
} else {
|
||||
print("3");
|
||||
if (io == "i") {
|
||||
body = {
|
||||
"cp_id": cpId,
|
||||
|
@ -213,7 +210,6 @@ class PassCheckServices {
|
|||
"io": io
|
||||
};
|
||||
} else {
|
||||
print("4");
|
||||
body = {
|
||||
"cp_id": cpId,
|
||||
"destination": destination,
|
||||
|
@ -224,8 +220,7 @@ class PassCheckServices {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
print("5");
|
||||
if (roleid == 41 || roleid == 13 || roleid == 17 || roleid == 22) {
|
||||
if (roleIdRoleName.roleName.toLowerCase() == "security guard" || roleIdRoleName.roleName.toLowerCase() == "qr code scanner") {
|
||||
body = {
|
||||
"station_id": stationId,
|
||||
"passer": passerId,
|
||||
|
@ -233,7 +228,6 @@ class PassCheckServices {
|
|||
"io": io
|
||||
};
|
||||
} else {
|
||||
print("6");
|
||||
body = {
|
||||
"cp_id": cpId,
|
||||
"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 '/':
|
||||
BlocProvider.of<UserBloc>(
|
||||
NavigationService.navigatorKey.currentContext!)
|
||||
.add(GetApkVersion());
|
||||
.add(GetApkVersion(username: "", password: ""));
|
||||
return MaterialPageRoute(builder: (_) {
|
||||
return const UniT2Login();
|
||||
});
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import 'package:hive/hive.dart';
|
||||
|
||||
import '../model/profile/basic_information/primary-information.dart';
|
||||
|
||||
double screenWidth = 0;
|
||||
double screenHeight = 0;
|
||||
double blockSizeHorizontal = 0;
|
||||
|
@ -11,8 +13,12 @@ double safeBlockVertical = 0;
|
|||
|
||||
const xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
|
||||
const xClientSecret = "unitcYqAN7GGalyz";
|
||||
|
||||
|
||||
String? globalFistname;
|
||||
String? globalLastname;
|
||||
String? globalMiddleName;
|
||||
DateTime? globalBday;
|
||||
String? globalSex;
|
||||
Profile? globalCurrentProfile;
|
||||
|
||||
//// hive boxes
|
||||
Box? CREDENTIALS;
|
||||
|
|
|
@ -6,6 +6,7 @@ import 'package:unit2/model/location/city.dart';
|
|||
import 'package:unit2/model/location/country.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:unit2/model/location/provinces.dart';
|
||||
import 'package:unit2/model/location/purok.dart';
|
||||
import 'package:unit2/utils/request.dart';
|
||||
import 'package:unit2/utils/urls.dart';
|
||||
|
||||
|
@ -70,6 +71,7 @@ class LocationUtils {
|
|||
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 province) {
|
||||
|
@ -77,6 +79,7 @@ class LocationUtils {
|
|||
provinces.add(newProvince);
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
throw (e.toString());
|
||||
}
|
||||
|
@ -89,6 +92,7 @@ class LocationUtils {
|
|||
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 city) {
|
||||
|
@ -96,6 +100,7 @@ class LocationUtils {
|
|||
cities.add(cityMun);
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
throw (e.toString());
|
||||
}
|
||||
|
@ -108,6 +113,7 @@ class LocationUtils {
|
|||
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 city) {
|
||||
|
@ -115,16 +121,40 @@ class LocationUtils {
|
|||
barangays.add(barangay);
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
throw (e.toString());
|
||||
}
|
||||
return barangays;
|
||||
}
|
||||
|
||||
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 = [];
|
||||
String path = Url.instance.getAddressCategory();
|
||||
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);
|
||||
if (data['data'] != null) {
|
||||
data['data'].forEach((var cat) {
|
||||
|
@ -137,6 +167,4 @@ class LocationUtils {
|
|||
throw e.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,11 +5,11 @@ class Url {
|
|||
|
||||
String host() {
|
||||
// return '192.168.10.183:3000';
|
||||
// return 'agusandelnorte.gov.ph';
|
||||
return 'agusandelnorte.gov.ph';
|
||||
// return "192.168.10.219:3000";
|
||||
// return "192.168.10.241";
|
||||
// return "192.168.10.221:3004";
|
||||
return "playweb.agusandelnorte.gov.ph";
|
||||
// return "playweb.agusandelnorte.gov.ph";
|
||||
// return 'devapi.agusandelnorte.gov.ph:3004';
|
||||
// return "192.168.10.218:8000";
|
||||
}
|
||||
|
@ -320,6 +320,10 @@ class Url {
|
|||
return "/api/hrms_app/position_title/";
|
||||
}
|
||||
|
||||
String getAssignedAreas() {
|
||||
return "/api/account/auth/assigned_role_area";
|
||||
}
|
||||
|
||||
//// location utils path
|
||||
String getCounties() {
|
||||
return "/api/jobnet_app/countries/";
|
||||
|
@ -340,6 +344,9 @@ class Url {
|
|||
String getBarangays() {
|
||||
return "/api/web_app/location/barangay/";
|
||||
}
|
||||
String getPurok(){
|
||||
return "/api/web_app/location/purok/";
|
||||
}
|
||||
|
||||
String getAddressCategory() {
|
||||
return "/api/jobnet_app/address_categories/";
|
||||
|
|
44
pubspec.lock
44
pubspec.lock
|
@ -25,6 +25,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
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:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -369,14 +377,6 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
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:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -409,14 +409,6 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
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:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -685,14 +677,6 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
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:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -801,10 +785,10 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
name: intl
|
||||
sha256: "910f85bce16fb5c6f614e117efa303e85a1731bb0081edf3604a2ae6e9a3cc91"
|
||||
sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.17.0"
|
||||
version: "0.18.1"
|
||||
io:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -997,6 +981,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
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:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
10
pubspec.yaml
10
pubspec.yaml
|
@ -38,10 +38,9 @@ dependencies:
|
|||
flutter_custom_clippers: ^2.0.0
|
||||
flutter_svg: ^1.1.6
|
||||
flutter_form_builder: ^7.7.0
|
||||
form_builder_validators: ^8.4.0
|
||||
form_builder_validators: any
|
||||
fluttericon: ^2.0.0
|
||||
fluttertoast: ^8.1.1
|
||||
device_preview: ^1.1.0
|
||||
flutter_zoom_drawer: ^3.0.3
|
||||
cached_network_image: ^3.2.3
|
||||
auto_size_text: ^3.0.0
|
||||
|
@ -50,7 +49,7 @@ dependencies:
|
|||
toggle_switch: ^2.0.1
|
||||
convex_bottom_bar: ^3.1.0+1
|
||||
azlistview: ^2.0.0
|
||||
intl: ^0.17.0
|
||||
intl: ^0.18.1
|
||||
date_time_picker: ^2.1.0
|
||||
flutter_progress_hud: ^2.0.2
|
||||
barcode_scan2: ^4.2.1
|
||||
|
@ -85,7 +84,7 @@ dependencies:
|
|||
flutter_speed_dial: ^6.2.0
|
||||
im_stepper: ^1.0.1+1
|
||||
shared_preferences: ^2.0.20
|
||||
multiselect: ^0.1.0
|
||||
multiselect: any
|
||||
multi_select_flutter: ^4.1.3
|
||||
flutter_custom_selector: ^0.0.3
|
||||
flutter_staggered_animations: ^1.1.1
|
||||
|
@ -98,6 +97,9 @@ dependencies:
|
|||
url_launcher: ^6.1.11
|
||||
url_launcher_android: ^6.0.38
|
||||
share_plus: ^7.1.0
|
||||
animated_splash_screen: ^1.3.0
|
||||
dependency_overrides:
|
||||
intl: ^0.18.0
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue