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/53
feature/passo/PASSO-#1-Sync-data-from-device-to-postgre-and-vice-versa
rodolfobacuinjr 2023-09-22 16:24:44 +08:00
commit b560340ebc
38 changed files with 2766 additions and 659 deletions

View File

@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}

View File

@ -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) {
currentProfileInformation = event.primaryBasicInformation;
emit(BasicInformationProfileLoaded(
primaryBasicInformation: event.primaryBasicInformation));
if (globalCurrentProfile != null) {
emit(BasicInformationProfileLoaded(
primaryBasicInformation: globalCurrentProfile!));
} else {
currentProfileInformation = event.primaryBasicInformation;
emit(BasicInformationProfileLoaded(
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));

View File

@ -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));
});
}
}

View File

@ -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];
}

View File

@ -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];
}

View File

@ -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",

View File

@ -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});

View File

@ -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,27 +22,24 @@ 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) {
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();
}
if (roles.isEmpty) {
roles = await RbacRoleServices.instance.getRbacRoles();
}
emit(AssignedRoleLoaded(
assignedRoles: assignedRoles, fullname: fullname!, roles: roles));
} else {
emit(UserNotExistError());
}
} catch (e) {
emit(RoleAssignmentErrorState(message: e.toString()));
}

View File

@ -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);

View File

@ -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 {

View File

@ -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
};
}

View File

@ -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(),
};
}

View File

@ -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,
};
}

View File

@ -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,
};
}

View File

@ -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(),
};
}

View File

@ -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"]),

View File

@ -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
@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,8 +186,9 @@ class _EditBasicProfileInfoScreenState
errorText: "This field is required"),
timeHintText: "Birthdate",
decoration:
normalTextFieldStyle("Birthdate *", "*").copyWith(
prefixIcon: const Icon(
normalTextFieldStyle("Birthdate *", "*")
.copyWith(
prefixIcon: const Icon(
Icons.date_range,
color: Colors.black87,
)),
@ -206,7 +200,7 @@ class _EditBasicProfileInfoScreenState
const SizedBox(
width: 10,
),
////sex
Flexible(
flex: 1,
@ -221,7 +215,7 @@ class _EditBasicProfileInfoScreenState
value: element, child: Text(element)))
.toList(),
onChanged: (e) {
selectedSex= e;
selectedSex = e;
},
),
)
@ -238,9 +232,10 @@ class _EditBasicProfileInfoScreenState
flex: 1,
child: FormBuilderDropdown<String>(
initialValue: selectedBloodType,
validator: FormBuilderValidators.required(
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,8 +254,9 @@ class _EditBasicProfileInfoScreenState
flex: 1,
child: FormBuilderDropdown<String>(
initialValue: selectedStatus,
decoration: normalTextFieldStyle("Civil status *", ""),
validator: FormBuilderValidators.required(
decoration:
normalTextFieldStyle("Civil status *", ""),
validator: FormBuilderValidators.required(
errorText: "This field is required"),
name: "extension",
items: state.civilStatus
@ -305,11 +301,12 @@ class _EditBasicProfileInfoScreenState
flex: 1,
child: FormBuilderTextField(
name: "height",
validator: numericRequired,
validator: numericRequired,
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,
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"),
),
@ -368,10 +367,11 @@ class _EditBasicProfileInfoScreenState
////Indigency
Flexible(
flex: 1,
child: DropdownButtonFormField<ProfileOtherInfo>(
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,33 +465,36 @@ 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,
webuserId: null,
id: state.primaryInformation.id,
lastName: lastName,
firstName: firstName,
@ -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));
}
@ -540,7 +552,7 @@ class _EditBasicProfileInfoScreenState
),
);
}
return Container();
return Container();
},
);
}

View File

@ -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,300 +64,420 @@ class _PrimaryInfoState extends State<PrimaryInfo> {
padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocConsumer<ProfileBloc, ProfileState>(
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());
});
}
}
},
child: BlocBuilder<UserBloc, UserState>(
builder: (context, state) {
if (state is BasicInformationProfileLoaded) {
return Container(
padding:
const EdgeInsets.symmetric(vertical: 24, horizontal: 24),
child: Column(
children: [
const SizedBox(
height: 28,
),
FormBuilderTextField(
enabled: enabled,
name: lastname,
initialValue: state.primaryBasicInformation.lastName!,
decoration: normalTextFieldStyle("Last name", ""),
),
const SizedBox(
height: 15,
),
FormBuilderTextField(
enabled: enabled,
name: firstname,
initialValue: state.primaryBasicInformation.firstName!,
decoration: normalTextFieldStyle("First name", ""),
),
const SizedBox(
height: 15,
),
SizedBox(
width: screenWidth,
child: Row(children: [
Flexible(
flex: 2,
child: FormBuilderTextField(
enabled: enabled,
name: middlename,
initialValue: state.primaryBasicInformation.middleName??''
,
decoration:
normalTextFieldStyle("Middle name", ""),
if (state is UserLoggedIn) {
return BlocConsumer<ProfileBloc, ProfileState>(
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) {
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());
});
} else {
errorAlert(context, "Update Failed",
"Something went wrong. Please try again.", () {
Navigator.of(context).pop();
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),
child: Column(
children: [
const SizedBox(
height: 28,
),
),
const SizedBox(
width: 10,
),
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",
FormBuilderTextField(
enabled: false,
name: lastname,
initialValue:
state.primaryBasicInformation.bloodType!,
decoration:
normalTextFieldStyle("Blood type", ""),
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(
width: 10,
),
Flexible(
flex: 1,
child: FormBuilderTextField(
const SizedBox(
height: 15,
),
FormBuilderTextField(
enabled: enabled,
name: "civilStatus",
name: firstname,
initialValue:
state.primaryBasicInformation.civilStatus!,
decoration:
normalTextFieldStyle("Civil Status", ""),
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(
width: 10,
),
Flexible(
flex: 1,
child: FormBuilderTextField(
enabled: enabled,
name: "gender",
initialValue: state
.primaryBasicInformation.gender ??= "N/A",
decoration: normalTextFieldStyle("Gender", ""),
const SizedBox(
height: 15,
),
),
]),
),
const SizedBox(
height: 15,
),
SizedBox(
width: screenWidth,
child: Row(children: [
Flexible(
flex: 1,
child: FormBuilderTextField(
maxLines: 2,
enabled: enabled,
name: height,
initialValue: state
.primaryBasicInformation.heightM!
.toString(),
decoration: normalTextFieldStyle("Height", ""),
SizedBox(
width: screenWidth,
child: Row(children: [
Flexible(
flex: 2,
child: FormBuilderTextField(
enabled: enabled,
name: middlename,
initialValue: state.primaryBasicInformation
.middleName ??
'',
style: const TextStyle(color: Colors.black),
decoration:
normalTextFieldStyle("Middle name", "")
.copyWith(
disabledBorder:
const OutlineInputBorder(),
labelStyle: const TextStyle(
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(
width: 10,
),
Flexible(
flex: 1,
child: FormBuilderTextField(
enabled: enabled,
name: width,
initialValue: state
.primaryBasicInformation.weightKg!
.toString(),
decoration: normalTextFieldStyle("Weight", ""),
const SizedBox(
height: 15,
),
),
const SizedBox(
width: 10,
),
Flexible(
flex: 1,
child: FormBuilderTextField(
enabled: enabled,
name: prefixSuffix,
initialValue:
"${state.primaryBasicInformation.titlePrefix ??= "NA"} | ${state.primaryBasicInformation.titleSuffix ??= "N/A"}",
decoration: normalTextFieldStyle(
"Title Prefix and Suffix", ""),
SizedBox(
width: screenWidth,
child: Row(children: [
Flexible(
flex: 1,
child: FormBuilderTextField(
enabled: enabled,
name: extensionName,
initialValue: dteFormat2.format(state
.primaryBasicInformation.birthdate!),
style: const TextStyle(color: Colors.black),
decoration:
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: 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(
height: 15,
),
),
const SizedBox(
width: 10,
),
Flexible(
flex: 1,
child: FormBuilderTextField(
enabled: enabled,
name: width,
initialValue: state
.primaryBasicInformation.ethnicity ??= "N/A",
decoration: normalTextFieldStyle("Ethnicity", ""),
SizedBox(
width: screenWidth,
child: Row(children: [
Flexible(
flex: 1,
child: FormBuilderTextField(
enabled: enabled,
name: "bloodType",
initialValue: state
.primaryBasicInformation.bloodType!,
style: const TextStyle(color: Colors.black),
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: 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", ""),
const SizedBox(
height: 15,
),
),
const SizedBox(
width: 10,
),
Flexible(
flex: 1,
child: FormBuilderTextField(
maxLines: 2,
enabled: enabled,
name: width,
initialValue: state
.primaryBasicInformation.disability ??= "N/A",
decoration:
normalTextFieldStyle("Disability", ""),
SizedBox(
width: screenWidth,
child: Row(children: [
Flexible(
flex: 1,
child: FormBuilderTextField(
maxLines: 2,
enabled: enabled,
name: height,
initialValue: state
.primaryBasicInformation.heightM!
.toString(),
style: const TextStyle(color: Colors.black),
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();
},
),

View File

@ -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!;
profile = state.userData!.employeeInfo!.profile!;
if (globalCurrentProfile == null) {
profile = state.userData!.employeeInfo!.profile!;
} else {
profile = globalCurrentProfile!;
}
print(profile.lastName);
return BlocConsumer<ProfileBloc, ProfileState>(
listener: (
context,

View File

@ -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,26 +234,25 @@ class RbacAgencyScreen extends StatelessWidget {
decoration: box1(),
padding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 8),
child: Expanded(
child: Row(
child: Row(
children: [
CircleAvatar(
child: Text('${index + 1}'),
),
const SizedBox(
width: 12,
),
Flexible(
child: Text(state.agencies[index].name!,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
fontWeight: FontWeight.w500,
color: primary)),
),
CircleAvatar(
child: Text('${index + 1}'),
),
const SizedBox(
width: 12,
),
Flexible(
child: Text(state.agencies[index].name!,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
fontWeight: FontWeight.w500,
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

View File

@ -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) {

View File

@ -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
? ''
: userData.employeeInfo!.profile?.middleName?.toUpperCase();
final String sex = userData.employeeInfo!.profile!.sex!.toUpperCase();
final DateTime? bday = userData.employeeInfo!.profile!.birthdate;
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())
: '';
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),
),

View File

@ -76,9 +76,6 @@ class _DashBoardState extends State<DashBoard> {
tempUnit2Cards = unit2Cards.sublist(0, 4);
}
superadminCards.forEach((el) {
print(el.object.name);
});
return Container(
padding:

View File

@ -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;

View File

@ -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(),
);
}));
}
@ -198,31 +196,126 @@ class SuperAdminMenu extends StatelessWidget {
);
}));
}
if (object.object.name == 'Station') {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) => StationBloc()
..add(const GetStations(agencyId: 1)),
child: const RbacStationScreen(
child: const RbacStationScreen(
agencyId: 1,
),
);
}));
}
if (object.object.name == 'Role Member') {
Navigator.of(context).pop();
////////////////////////////////
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))
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(
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(
@ -262,7 +355,6 @@ class SuperAdminMenu extends StatelessWidget {
if (roleAssignmentKey
.currentState!
.saveAndValidate()) {
String fname =
roleAssignmentKey
.currentState!
@ -271,19 +363,27 @@ class SuperAdminMenu extends StatelessWidget {
roleAssignmentKey
.currentState!
.value['lastname'];
Navigator.of(context).pop();
Navigator.of(context).pop();
Navigator.push(context,
MaterialPageRoute(builder:
(BuildContext
context) {
return BlocProvider(
create: (context) =>
RoleAssignmentBloc()
..add(GetAssignedRoles(
create: (context) =>
RoleAssignmentBloc()
..add(
GetAssignedRoles(
firstname:
fname,
lastname:
lname),),child:RbacRoleAssignment(id:id,name: fname,lname: lname,) ,);
lname),
),
child: RbacRoleAssignment(
id: id,
name: fname,
lname: lname,
),
);
}));
}
},

View File

@ -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(

View File

@ -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,34 +54,49 @@ class _MainScreenState extends State<MainScreen> {
}
}
return Scaffold(
appBar: AppBar(
backgroundColor: primary,
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,
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(
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();

View File

@ -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,14 +385,14 @@ 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();
});
},
);
}
return Container();
return Container();
}),
),
),

View File

@ -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!));
}
}
}

View File

@ -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,

View File

@ -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;
}
}

View File

@ -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();
});

View File

@ -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;

View File

@ -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';
@ -23,20 +24,20 @@ class LocationUtils {
List<Country> countries = [];
String path = Url.instance.getCounties();
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 country) {
Country newCOuntry = Country.fromJson(country);
countries.add(newCOuntry);
});
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 country) {
Country newCOuntry = Country.fromJson(country);
countries.add(newCOuntry);
});
}
}
}
}catch(e){
throw(e.toString());
} catch (e) {
throw (e.toString());
}
return countries;
}
@ -45,20 +46,20 @@ class LocationUtils {
List<Region> regions = [];
String path = Url.instance.getRegions();
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 region) {
Region newRegion = Region.fromJson(region);
regions.add(newRegion);
});
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 region) {
Region newRegion = Region.fromJson(region);
regions.add(newRegion);
});
}
}
}
}catch(e){
throw(e.toString());
} catch (e) {
throw (e.toString());
}
return regions;
}
@ -70,12 +71,14 @@ class LocationUtils {
try {
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 province) {
Province newProvince = Province.fromJson(province);
provinces.add(newProvince);
});
if (response.statusCode == 200) {
Map data = jsonDecode(response.body);
if (data['data'] != null) {
data['data'].forEach((var province) {
Province newProvince = Province.fromJson(province);
provinces.add(newProvince);
});
}
}
} catch (e) {
throw (e.toString());
@ -89,12 +92,14 @@ class LocationUtils {
try {
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 city) {
CityMunicipality cityMun = CityMunicipality.fromJson(city);
cities.add(cityMun);
});
if (response.statusCode == 200) {
Map data = jsonDecode(response.body);
if (data['data'] != null) {
data['data'].forEach((var city) {
CityMunicipality cityMun = CityMunicipality.fromJson(city);
cities.add(cityMun);
});
}
}
} catch (e) {
throw (e.toString());
@ -102,41 +107,64 @@ class LocationUtils {
return cities;
}
Future<List<Barangay>> getBarangay({required String code}) async {
Future<List<Barangay>> getBarangay({required String code}) async {
List<Barangay> barangays = [];
String path = Url.instance.getBarangays() + code;
try {
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 city) {
Barangay barangay = Barangay.fromJson(city);
barangays.add(barangay);
});
if (response.statusCode == 200) {
Map data = jsonDecode(response.body);
if (data['data'] != null) {
data['data'].forEach((var city) {
Barangay barangay = Barangay.fromJson(city);
barangays.add(barangay);
});
}
}
} catch (e) {
throw (e.toString());
}
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 = [];
String path = Url.instance.getAddressCategory();
try{
http.Response response = await Request.instance.getRequest(path: path,param: {},headers:headers );
try {
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){
if (data['data'] != null) {
data['data'].forEach((var cat) {
categories.add(AddressCategory.fromJson(cat));
});
}
categories;
return categories;
}catch(e){
} catch (e) {
throw e.toString();
}
}
}

View File

@ -5,17 +5,17 @@ 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";
}
String prefixHost() {
return "https";
return "https";
// return "http";
}
@ -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/";

View File

@ -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:

View File

@ -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,7 +97,10 @@ 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
dev_dependencies: