erge into develop

feature/passo/PASSO-#1-Sync-data-from-device-to-postgre-and-vice-versa
PGAN-MIS 2023-04-11 09:27:53 +08:00
parent 3789d998a8
commit 5dcfd32a51
38 changed files with 2409 additions and 2549 deletions

View File

@ -16,33 +16,57 @@ class EligibilityBloc extends Bloc<EligibilityEvent, EligibilityState> {
EligibilityBloc() : super(EligibilityInitial()) {
List<Country>? globalCountries;
List<Region>? globalRegions;
List<Eligibility>? globalEligibilities;
List<EligibityCert>? eligibilities;
////=====================================================================
List<Eligibility> globalEligibilities = [];
List<EligibityCert> eligibilities = [];
//// LOAD ELIGIBILTY
on<LoadEligibility>((event, emit) {
emit(EligibilityLoadingState());
eligibilities = event.eligibilities;
emit(EligibilityLoaded(eligibilities: event.eligibilities));
});
////====================================================================
on<GetEligibilities>((event, emit) async {
try {
if (eligibilities != null) {
emit(EligibilityLoaded(eligibilities: eligibilities!));
if (eligibilities.isEmpty) {
GetEligibilities(profileId: event.profileId!, token: event.token!);
} else {
emit(EligibilityLoadingState());
eligibilities = await EligibilityService.instance
.getEligibilities(event.profileId, event.token);
emit(EligibilityLoaded(eligibilities: eligibilities!));
emit(EligibilityLoaded(eligibilities: eligibilities));
}
});
//// DELETE
on<DeleteEligibility>((event, emit) async {
try {
final bool success = await EligibilityService.instance.delete(
eligibilityId: event.eligibilityId,
profileId: int.parse(event.profileId),
token: event.token);
if (success) {
eligibilities.removeWhere(
((EligibityCert element) => element.id == event.eligibilityId));
emit(DeletedState(
success: success,
));
} else {
emit(DeletedState(success: success));
}
} catch (e) {
emit(EligibilityErrorState(message: e.toString()));
}
});
////====================================================================
//// GET ELIGIBILITY
on<GetEligibilities>((event, emit) async {
try {
if (eligibilities.isNotEmpty) {
emit(EligibilityLoaded(eligibilities: eligibilities));
} else {
emit(EligibilityLoadingState());
eligibilities = await EligibilityService.instance
.getEligibilities(event.profileId, event.token);
emit(EligibilityLoaded(eligibilities: eligibilities));
}
} catch (e) {
emit(EligibilityErrorState(message: e.toString()));
}
});
//// SHOW EDIT FORM
on<ShowEditEligibilityForm>((event, emit) async {
try {
emit(EligibilityLoadingState());
if (globalCountries == null) {
List<Country> countries = await LocationUtils.instance.getCountries();
globalCountries = countries;
@ -51,12 +75,12 @@ class EligibilityBloc extends Bloc<EligibilityEvent, EligibilityState> {
List<Region> regions = await LocationUtils.instance.getRegions();
globalRegions = regions;
}
if (globalEligibilities == null) {
if (globalEligibilities.isEmpty) {
List<Eligibility> eligibilities =
await ProfileUtilities.instance.getEligibilities();
globalEligibilities = eligibilities;
}
Eligibility currentEligibility = globalEligibilities!.firstWhere(
Eligibility currentEligibility = globalEligibilities.firstWhere(
(Eligibility eligibility) =>
event.eligibityCert.eligibility!.id == eligibility.id);
bool? isOverseas = event.eligibityCert.overseas;
@ -95,7 +119,7 @@ class EligibilityBloc extends Bloc<EligibilityEvent, EligibilityState> {
eligibityCert: event.eligibityCert,
countries: globalCountries!,
regions: globalRegions!,
eligibilities: globalEligibilities!));
eligibilities: globalEligibilities));
} else {
emit(EditEligibilityState(
selectedCountry: currentCountry,
@ -109,17 +133,16 @@ class EligibilityBloc extends Bloc<EligibilityEvent, EligibilityState> {
eligibityCert: event.eligibityCert,
countries: globalCountries!,
regions: globalRegions!,
eligibilities: globalEligibilities!));
eligibilities: globalEligibilities));
}
} catch (e) {
emit(EligibilityErrorState(message: e.toString()));
}
});
////====================================================================
//// UPDATE
on<UpdateEligibility>((event, emit) async {
try {
emit(EligibilityLoadingState());
Map<dynamic, dynamic> status = await EligibilityService.instance.update(
eligibityCert: event.eligibityCert,
token: event.token,
@ -127,26 +150,25 @@ class EligibilityBloc extends Bloc<EligibilityEvent, EligibilityState> {
oldEligibility: event.oldEligibility);
if (status['success']) {
EligibityCert newEligibility = EligibityCert.fromJson(status['data']);
eligibilities!.removeWhere(
eligibilities.removeWhere(
(EligibityCert element) => element.id == event.eligibityCert.id);
eligibilities!.add(newEligibility);
emit(EligibilityEditedState(
eligibilities: eligibilities!, response: status));
eligibilities.add(newEligibility);
emit(EligibilityEditedState(response: status));
} else {
emit(EligibilityEditedState(
eligibilities: eligibilities!, response: status));
emit(EligibilityEditedState(response: status));
}
} catch (e) {
emit(EligibilityErrorState(message: e.toString()));
}
});
//// SHOW ADD FORM
on<ShowAddEligibilityForm>((event, emit) async {
emit(EligibilityLoadingState());
if (globalRegions == null) {
List<Region> regions = await LocationUtils.instance.getRegions();
globalRegions = regions;
}
if (globalEligibilities == null) {
if (globalEligibilities.isEmpty) {
List<Eligibility> eligibilities =
await ProfileUtilities.instance.getEligibilities();
globalEligibilities = eligibilities;
@ -157,37 +179,15 @@ class EligibilityBloc extends Bloc<EligibilityEvent, EligibilityState> {
}
emit(AddEligibilityState(
eligibilities: globalEligibilities!,
eligibilities: globalEligibilities,
regions: globalRegions!,
countries: globalCountries!));
});
////====================================================================
on<DeleteEligibility>((event, emit) async {
emit(EligibilityLoadingState());
try {
final bool success = await EligibilityService.instance.delete(
eligibilityId: event.eligibilityId,
profileId: int.parse(event.profileId),
token: event.token);
if (success) {
event.eligibilities.removeWhere(
((EligibityCert element) => element.id == event.eligibilityId));
List<EligibityCert> eligibilities = event.eligibilities;
emit(DeletedState(success: success, eligibilities: eligibilities));
} else {
emit(DeletedState(
success: success, eligibilities: event.eligibilities));
}
} catch (e) {
emit(EligibilityErrorState(message: e.toString()));
}
});
////====================================================================
//// ADD
on<AddEligibility>(
(event, emit) async {
try {
emit(EligibilityLoadingState());
Map<dynamic, dynamic> status = await EligibilityService.instance.add(
eligibityCert: event.eligibityCert,
token: event.token,
@ -195,12 +195,10 @@ class EligibilityBloc extends Bloc<EligibilityEvent, EligibilityState> {
if (status['success']) {
EligibityCert? eligibityCert =
EligibityCert.fromJson(status['data']);
eligibilities!.add(eligibityCert);
emit(EligibilityAddedState(
eligibilities: eligibilities!, response: status));
eligibilities.add(eligibityCert);
emit(EligibilityAddedState(response: status));
} else {
emit(EligibilityAddedState(
eligibilities: eligibilities!, response: status));
emit(EligibilityAddedState(response: status));
}
} catch (e) {
emit(EligibilityErrorState(message: e.toString()));

View File

@ -38,8 +38,9 @@ class UpdateEligibility extends EligibilityEvent{
List<Object> get props =>[eligibityCert,profileId,token,oldEligibility];
}
class LoadEligibility extends EligibilityEvent {
final List<EligibityCert> eligibilities;
const LoadEligibility({required this.eligibilities});
final int? profileId;
final String? token;
const LoadEligibility({ this.profileId, this.token});
@override
List<Object> get props => [];
}
@ -52,17 +53,16 @@ class ShowEditEligibilityForm extends EligibilityEvent {
}
class DeleteEligibility extends EligibilityEvent {
final List<EligibityCert> eligibilities;
final String profileId;
final int eligibilityId;
final String token;
const DeleteEligibility(
{required this.eligibilities,
{
required this.eligibilityId,
required this.profileId,
required this.token});
@override
List<Object> get props => [eligibilities, profileId, eligibilityId, token];
List<Object> get props => [ profileId, eligibilityId, token];
}
class CallErrorState extends EligibilityEvent{

View File

@ -43,11 +43,10 @@ class EditEligibilityState extends EligibilityState {
}
class DeletedState extends EligibilityState {
final List<EligibityCert> eligibilities;
final bool success;
const DeletedState({required this.eligibilities, required this.success});
const DeletedState({required this.success});
@override
List<Object> get props => [success, eligibilities];
List<Object> get props => [success];
}
class AddEligibilityState extends EligibilityState {
@ -63,20 +62,18 @@ class AddEligibilityState extends EligibilityState {
List<Object> get props => [eligibilities,countries,regions];
}
class EligibilityEditedState extends EligibilityState{
final List<EligibityCert> eligibilities;
final Map<dynamic,dynamic> response;
const EligibilityEditedState({required this.eligibilities, required this.response});
const EligibilityEditedState({required this.response});
@override
List<Object> get props =>[eligibilities, response];
List<Object> get props =>[ response];
}
class EligibilityAddedState extends EligibilityState{
final List<EligibityCert> eligibilities;
final Map<dynamic,dynamic> response;
const EligibilityAddedState({required this.eligibilities, required this.response});
const EligibilityAddedState({ required this.response});
@override
List<Object> get props =>[eligibilities,response];
List<Object> get props =>[response];
}
class EligibilityLoadingState extends EligibilityState{

View File

@ -1,6 +1,5 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/profile/work_history.dart';
import 'package:unit2/model/utils/agency.dart';
import 'package:unit2/model/utils/category.dart';
import 'package:unit2/sevices/profile/orgmembership_services.dart';
@ -30,7 +29,7 @@ class OrganizationMembershipBloc extends Bloc<OrganizationMembershipEvent, Organ
}
});
on<LoadOrganizationMemberships>((event,emit){
emit(OrganizationMembershipLoaded(orgMemberships: event.organizationMemberships));
emit(OrganizationMembershipLoaded(orgMemberships: organizationMemberships));
});
////SHOW ADD ORG MEMBERSHIP FORM
@ -52,15 +51,14 @@ class OrganizationMembershipBloc extends Bloc<OrganizationMembershipEvent, Organ
});
//// ADD ORGMEMBERSHIP
on<AddOrgMembership>((event,emit)async{
emit(OrgmembershipLoadingState());
try{
Map<dynamic,dynamic> status= await OrganizationMembershipServices.instance.add(agency: event.agency, token: event.token, profileId: event.profileId.toString());
if(status["success"]){
OrganizationMembership organizationMembership = OrganizationMembership.fromJson(status["data"]);
organizationMemberships.add(organizationMembership);
emit(OrgMembershipAddedState(orgMemberships: organizationMemberships, response: status));
emit(OrgMembershipAddedState( response: status));
}else{
emit(OrgMembershipAddedState(orgMemberships: organizationMemberships, response: status));
emit(OrgMembershipAddedState( response: status));
}
}catch(e){
emit(OrganizationMembershipErrorState(message: e.toString()));
@ -72,11 +70,10 @@ class OrganizationMembershipBloc extends Bloc<OrganizationMembershipEvent, Organ
try{
final bool success = await OrganizationMembershipServices.instance.delete(agency: event.org.agency!, profileId: event.profileId, token: event.token);
if(success){
event.organizationMemberships.removeWhere((element) => element.agency!.id == event.org.agency!.id );
List<OrganizationMembership> orgmemberships = event.organizationMemberships;
emit(OrgMembershipDeletedState(organizationMemberships: orgmemberships, success: success));
organizationMemberships.removeWhere((element) => element.agency!.id == event.org.agency!.id );
emit(OrgMembershipDeletedState(success: success));
}else{
emit(OrgMembershipDeletedState(organizationMemberships: organizationMemberships, success: success));
emit(OrgMembershipDeletedState(success: success));
}
}catch(e){
emit(OrganizationMembershipErrorState(message: e.toString()));

View File

@ -8,11 +8,9 @@ abstract class OrganizationMembershipEvent extends Equatable {
}
class LoadOrganizationMemberships extends OrganizationMembershipEvent{
final List<OrganizationMembership> organizationMemberships;
const LoadOrganizationMemberships({required this.organizationMemberships});
@override
List<Object> get props => [organizationMemberships];
List<Object> get props => [];
}
class GetOrganizationMembership extends OrganizationMembershipEvent{
@ -37,9 +35,9 @@ class DeleteOrgMemberShip extends OrganizationMembershipEvent{
final int profileId;
final String token;
final OrganizationMembership org;
final List<OrganizationMembership> organizationMemberships;
const DeleteOrgMemberShip({required this.profileId, required this.token, required this.org, required this.organizationMemberships});
const DeleteOrgMemberShip({required this.profileId, required this.token, required this.org,});
@override
List<Object> get props => [profileId,token,org,organizationMemberships];
List<Object> get props => [profileId,token,org];
}

View File

@ -27,18 +27,16 @@ class OrgmembershipLoadingState extends OrganizationMembershipState{
}
class OrgMembershipDeletedState extends OrganizationMembershipState{
final List<OrganizationMembership> organizationMemberships;
final bool success;
const OrgMembershipDeletedState({required this.organizationMemberships, required this.success});
const OrgMembershipDeletedState({ required this.success});
@override
List<Object> get props => [organizationMemberships,success];
List<Object> get props => [success];
}
class OrgMembershipAddedState extends OrganizationMembershipState{
final List<OrganizationMembership> orgMemberships;
final Map<dynamic,dynamic> response;
const OrgMembershipAddedState({required this.orgMemberships, required this.response});
const OrgMembershipAddedState({required this.response});
@override
List<Object> get props => [orgMemberships,response];
List<Object> get props => [response];
}
class AddOrgMembershipState extends OrganizationMembershipState{

View File

@ -27,7 +27,7 @@ class ContactBloc extends Bloc<ContactEvent, ContactState> {
});
//// Load Contacts
on<LoadContacts>((event, emit) {
emit(ContactLoadedState(contactInformation: event.contactInformation));
emit(ContactLoadedState(contactInformation: contactInformations));
});
//// show add form
on<ShowAddForm>((event, emit) async {
@ -44,50 +44,96 @@ class ContactBloc extends Bloc<ContactEvent, ContactState> {
///// Show edit form
on<ShowEditForm>((event, emit) async {
ServiceType serviceType;
List<ServiceProvider> serviceProvivers;
ServiceProvider serviceProvider;
List<CommService> commServiceProvivers;
CommService serviceProvider;
try{
if (serviceTypes.isEmpty) {
serviceTypes = await ProfileUtilities.instance.getServiceType();
}
serviceType = serviceTypes.firstWhere((var element){
return event.contactInfo.commService!.serviceType!.id == element.id;
serviceType = serviceTypes.firstWhere((ServiceType element) {
return element.id == event.contactInfo.commService!.serviceType!.id;
});
serviceProvivers = await ContactService.instance.getServiceProvider(serviceTypeId: serviceType.id!);
serviceProvider = serviceProvivers.firstWhere((element) => element.id == event.contactInfo.commService!.serviceProvider!.id);
emit(ContactEditingState(serviceTypes: serviceTypes,selectedServiceType: serviceType,serviceProviders: serviceProvivers,selectedProvider: serviceProvider, contactInfo: event.contactInfo));
commServiceProvivers = await ContactService.instance
.getServiceProvider(serviceTypeId: serviceType.id!);
serviceProvider = commServiceProvivers.firstWhere((CommService element) =>
element.id == event.contactInfo.commService!.id);
emit(ContactEditingState(
serviceTypes: serviceTypes,
selectedServiceType: serviceType,
commServiceProviders: commServiceProvivers,
selectedProvider: serviceProvider,
contactInfo: event.contactInfo));
}catch(e){
emit(ContactErrorState(message: e.toString()));
}
});
////edit contact
on<EditContactInformation>((event, emit) async {
Map<dynamic,dynamic> responseStatus = await ContactService.instance.update(profileId: event.profileId, token: event.token, contactInfo: event.contactInfo);
try {
Map<dynamic, dynamic> responseStatus = await ContactService.instance
.update(
profileId: event.profileId,
token: event.token,
contactInfo: event.contactInfo);
if (responseStatus['success']) {
ContactInfo contactInfo = ContactInfo.fromJson(responseStatus['data']['contact_info']);
contactInformations.removeWhere((ContactInfo element) => element.id == event.contactInfo.id);
ContactInfo contactInfo =
ContactInfo.fromJson(responseStatus['data']['contact_info']);
contactInformations.removeWhere(
(ContactInfo element) => element.id == event.contactInfo.id);
contactInformations.add(contactInfo);
emit(ContactEditedState(contactInformation: contactInformations, response: responseStatus));
emit(ContactEditedState(
response: responseStatus));
} else {
emit(ContactEditedState(contactInformation: contactInformations, response: responseStatus));
emit(ContactEditedState(
response: responseStatus));
}
} catch (e) {
emit(ContactErrorState(message: e.toString()));
}
});
//// add contact
try{
on<AddContactInformation>((event, emit) async {
try {
Map<dynamic, dynamic> responseStatus = await ContactService.instance
.add(
profileId: event.profileId,
token: event.token,
contactInfo: event.contactInfo);
if (responseStatus['success']) {
ContactInfo contactInfo =
ContactInfo.fromJson(responseStatus['data']['contact_info']);
contactInformations.add(contactInfo);
emit(ContactEditedState(
response: responseStatus));
} else {
emit(ContactEditedState(
response: responseStatus));
}
} catch (e) {
emit(ContactErrorState(message: e.toString()));
}
});
//// delete contact
on<DeleteContactInformation>((event, emit) async {
try {
final bool success = await ContactService.instance.deleteContact(profileId: event.profileId, token: event.token, contactInfo: event.contactInfo);
final bool success = await ContactService.instance.deleteContact(
profileId: event.profileId,
token: event.token,
contactInfo: event.contactInfo);
if (success) {
contactInformations.removeWhere((element) => element.id == event.contactInfo.id);
emit(ContactDeletedState(contactInformation: contactInformations, succcess: success));
contactInformations
.removeWhere((element) => element.id == event.contactInfo.id);
emit(ContactDeletedState(
succcess: success));
} else {
emit(ContactDeletedState(contactInformation: contactInformations, succcess: success));
emit(ContactDeletedState(
succcess: success));
}
} catch (e) {
emit(ContactErrorState(message: e.toString()));

View File

@ -17,10 +17,9 @@ class GetContacts extends ContactEvent{
//// load contacts
class LoadContacts extends ContactEvent{
final List<ContactInfo> contactInformation;
const LoadContacts({required this.contactInformation});
@override
List<Object> get props => [contactInformation];
List<Object> get props => [];
}
//// show add form

View File

@ -30,11 +30,11 @@ class ContactAddingState extends ContactState{
//// Editing state
class ContactEditingState extends ContactState{
final List<ServiceType> serviceTypes;
final List<ServiceProvider> serviceProviders;
final ServiceProvider selectedProvider;
final List<CommService> commServiceProviders;
final CommService selectedProvider;
final ServiceType selectedServiceType;
final ContactInfo contactInfo;
const ContactEditingState({ required this.serviceTypes, required this.selectedServiceType, required this.selectedProvider, required this.serviceProviders, required this.contactInfo});
const ContactEditingState({ required this.serviceTypes, required this.selectedServiceType, required this.selectedProvider, required this.commServiceProviders, required this.contactInfo});
@override
List<Object> get props => [serviceTypes];
}
@ -42,11 +42,11 @@ class ContactEditingState extends ContactState{
//// added state
class ContactAddedState extends ContactState{
final List<ContactInfo> contactInformation;
final Map<dynamic,dynamic> response;
const ContactAddedState({required this.contactInformation, required this.response});
const ContactAddedState({ required this.response});
@override
List<Object> get props => [contactInformation,response];
List<Object> get props => [response];
}
@ -54,19 +54,19 @@ class ContactAddedState extends ContactState{
//// edited state
class ContactEditedState extends ContactState{
final List<ContactInfo> contactInformation;
final Map<dynamic,dynamic> response;
const ContactEditedState({required this.contactInformation, required this.response});
const ContactEditedState({ required this.response});
@override
List<Object> get props => [contactInformation,response];
List<Object> get props => [response];
}
////deleted state
class ContactDeletedState extends ContactState{
final List<ContactInfo> contactInformation;
final bool succcess;
const ContactDeletedState({required this.contactInformation, required this.succcess});
const ContactDeletedState({required this.succcess});
@override
List<Object> get props => [contactInformation,succcess];
List<Object> get props => [succcess];
}
////error state

View File

@ -104,7 +104,11 @@ class ReferencesBloc extends Bloc<ReferencesEvent, ReferencesState> {
event.personalReference.address!.cityMunicipality!.code ==
city.code);
List<Barangay> barangays = await LocationUtils.instance.getBarangay(code: selectedCity.code.toString());
selectedBarangay = barangays.firstWhere((Barangay barangay)=>event.personalReference.address!.barangay!.code == barangay.code);
if(event.personalReference.address?.barangay!=null){
selectedBarangay = barangays.firstWhere((Barangay barangay)=>event.personalReference.address?.barangay?.code == barangay.code);
}else{
selectedBarangay = null;
}
emit(EditReferenceState(
selectedRegion: selectedRegion,
ref: event.personalReference,
@ -144,17 +148,16 @@ class ReferencesBloc extends Bloc<ReferencesEvent, ReferencesState> {
message: "Something went wrong. Please try again"));
//// EDIT REFERENCES EVENT
});on<EditReference>((event,emit)async{
emit(ReferencesLoadingState());
Map<dynamic,dynamic> status =await ReferencesServices.instace.update(ref: event.reference, token: event.token, profileId: event.profileId);
if (status['success']) {
PersonalReference ref = PersonalReference.fromJson(status['data']);
references.removeWhere((PersonalReference element)=>element.id == event.reference.id);
references.add(ref);
emit(
ReferenceEditedState(personalRefs: references, response: status));
ReferenceEditedState( response: status));
} else {
emit(
ReferenceEditedState(personalRefs: references, response: status));
ReferenceEditedState( response: status));
}
});
@ -171,10 +174,10 @@ class ReferencesBloc extends Bloc<ReferencesEvent, ReferencesState> {
PersonalReference ref = PersonalReference.fromJson(status['data']);
references.add(ref);
emit(
ReferencesAddedState(personalRefs: references, response: status));
ReferencesAddedState( response: status));
} else {
emit(
ReferencesAddedState(personalRefs: references, response: status));
ReferencesAddedState( response: status));
}
} catch (e) {
emit(ReferencesErrorState(message: e.toString()));
@ -183,7 +186,6 @@ class ReferencesBloc extends Bloc<ReferencesEvent, ReferencesState> {
////LOAD REFERENCE
on<LoadReferences>((event, emit) {
emit(ReferencesLoadingState());
references = event.references;
emit(ReferencesLoadedState(references: references));
});
@ -196,9 +198,9 @@ class ReferencesBloc extends Bloc<ReferencesEvent, ReferencesState> {
event.references.removeWhere(
(PersonalReference element) => element.id == event.refId);
references = event.references;
emit(DeleteReferenceState(references: references, success: success));
emit(DeleteReferenceState( success: success));
} else {
emit(DeleteReferenceState(references: references, success: success));
emit(DeleteReferenceState(success: success));
}
} catch (e) {
emit(ReferencesErrorState(message: e.toString()));

View File

@ -15,35 +15,33 @@ class GetReferences extends ReferencesEvent{
List<Object> get props => [profileId, token];
}
class ShowAddReferenceForm extends ReferencesEvent{
}
class ShowAddReferenceForm extends ReferencesEvent {}
class ShowEditReferenceForm extends ReferencesEvent {
final PersonalReference personalReference;
const ShowEditReferenceForm({required this.personalReference});
@override
List<Object> get props => [personalReference];
}
class CallErrorState extends ReferencesEvent{
}
class CallErrorState extends ReferencesEvent {}
class AddReference extends ReferencesEvent {
final PersonalReference reference;
final String token;
final int profileId;
const AddReference({required this.profileId, required this.reference,required this.token});
const AddReference(
{required this.profileId, required this.reference, required this.token});
@override
List<Object> get props => [profileId, token, reference];
}
class EditReference extends ReferencesEvent {
final PersonalReference reference;
final String token;
final int profileId;
const EditReference({required this.profileId, required this.reference,required this.token});
const EditReference(
{required this.profileId, required this.reference, required this.token});
@override
List<Object> get props => [profileId, token, reference];
}
@ -53,17 +51,16 @@ class DeleteReference extends ReferencesEvent{
final int profileId;
final String token;
final int refId;
const DeleteReference({required this.profileId, required this.refId, required this.references, required this.token});
const DeleteReference(
{required this.profileId,
required this.refId,
required this.references,
required this.token});
@override
List<Object> get props => [profileId, token, refId, references];
}
class LoadReferences extends ReferencesEvent {
final List<PersonalReference> references;
const LoadReferences({required this.references});
@override
List<Object> get props => [references];
List<Object> get props => [];
}

View File

@ -28,20 +28,19 @@ class ReferencesErrorState extends ReferencesState {
class ReferencesLoadingState extends ReferencesState {}
class ReferencesAddedState extends ReferencesState {
final List<PersonalReference> personalRefs;
final Map<dynamic, dynamic> response;
const ReferencesAddedState(
{required this.personalRefs, required this.response});
{ required this.response});
@override
List<Object> get props => [personalRefs, response];
List<Object> get props => [ response];
}
class ReferenceEditedState extends ReferencesState {
final List<PersonalReference> personalRefs;
final Map<dynamic, dynamic> response;
const ReferenceEditedState(
{required this.personalRefs, required this.response});
{ required this.response});
@override
List<Object> get props => [personalRefs, response];
List<Object> get props => [ response];
}
class EditReferenceState extends ReferencesState {
@ -89,7 +88,6 @@ class AddReferenceState extends ReferencesState {
}
class DeleteReferenceState extends ReferencesState {
final List<PersonalReference> references;
final bool success;
const DeleteReferenceState({required this.references, required this.success});
const DeleteReferenceState({ required this.success});
}

View File

@ -24,9 +24,12 @@ class WorkHistoryBloc extends Bloc<WorkHistorytEvent, WorkHistoryState> {
on<GetWorkHistories>((event, emit) async {
emit(WorkHistoryLoadingState());
try {
if (workExperiences.isEmpty) {
List<WorkHistory> works = await WorkHistoryService.instance
.getWorkExperiences(event.profileId, event.token);
.getWorkExperiences(event.profileId!, event.token!);
workExperiences = works;
}
emit(WorkHistoryLoaded(workExperiences: workExperiences));
} catch (e) {
emit(WorkHistoryErrorState(message: e.toString()));
@ -35,25 +38,21 @@ class WorkHistoryBloc extends Bloc<WorkHistorytEvent, WorkHistoryState> {
///// LOAD WORK HISTORIES
on<LoadWorkHistories>((event, emit) {
emit(WorkHistoryLoadingState());
workExperiences = event.workHistories;
emit(WorkHistoryLoaded(workExperiences: workExperiences));
});
////DELETE
on<DeleteWorkHistory>((event, emit) async {
emit(WorkHistoryLoadingState());
try {
final bool success = await WorkHistoryService.instance.delete(
profileId: event.profileId,
token: event.token,
work: event.workHistory);
if (success) {
event.workHistories.removeWhere(
workExperiences.removeWhere(
(WorkHistory element) => element.id == event.workHistory.id);
List<WorkHistory> newWorkHistories = event.workHistories;
emit(DeletedState(success: success, workHistories: newWorkHistories));
emit(DeletedState(success: success));
} else {
emit(DeletedState(
success: success, workHistories: event.workHistories));
emit(DeletedState(success: success));
}
} catch (e) {
emit(WorkHistoryErrorState(message: e.toString()));
@ -62,7 +61,6 @@ class WorkHistoryBloc extends Bloc<WorkHistorytEvent, WorkHistoryState> {
//// ADD WORK HISTORIES
on<AddWorkHostory>((event, emit) async {
try {
emit(WorkHistoryLoadingState());
Map<dynamic, dynamic> status = await WorkHistoryService.instance.add(
isPrivate: event.isPrivate,
workHistory: event.workHistory,
@ -71,40 +69,40 @@ class WorkHistoryBloc extends Bloc<WorkHistorytEvent, WorkHistoryState> {
if (status['success']) {
WorkHistory workHistory = WorkHistory.fromJson(status['data']);
workExperiences.add(workHistory);
emit(WorkHistoryAddedState(
response: status, workExperiences: workExperiences));
emit(WorkHistoryAddedState(response: status));
} else {
emit(WorkHistoryAddedState(
response: status, workExperiences: workExperiences));
emit(WorkHistoryAddedState(response: status));
}
} catch (e) {
emit(WorkHistoryErrorState(message: e.toString()));
}
});
////UPDATE WORK HISTORY
on<UpdateWorkHistory>((event, emit) async {
emit(WorkHistoryLoadingState());
// try{
Map<dynamic,dynamic> status = await WorkHistoryService.instance.update(oldWorkHistory: event.oldWorkHistory, newWorkHistory: event.workHistory, token: event.token, profileId: event.profileId);
try {
Map<dynamic, dynamic> status = await WorkHistoryService.instance.update(
oldWorkHistory: event.oldWorkHistory,
newWorkHistory: event.workHistory,
token: event.token,
profileId: event.profileId);
if (status['success']) {
WorkHistory workHistory = WorkHistory.fromJson(status['data']);
workExperiences.removeWhere((WorkHistory work) {
return work.id == event.oldWorkHistory.id;
});
workExperiences.add(workHistory);
emit(WorkHistoryEditedState(workExperiences: workExperiences,response: status));
emit(WorkHistoryEditedState(response: status));
} else {
emit(WorkHistoryEditedState(response: status, workExperiences: workExperiences));
emit(WorkHistoryEditedState(
response: status,
));
}
} catch (e) {
emit(WorkHistoryErrorState(message: e.toString()));
}
// }catch(e){
// emit(WorkHistoryErrorState(message: e.toString()));
// }
});
////SHOW EDIT WORK HISTORIES
on<ShowEditWorkHistoryForm>((event, emit) async {
try {
@ -150,23 +148,31 @@ on<UpdateWorkHistory>((event, emit)async{
emit(WorkHistoryLoadingState());
try {
/////POSITIONS------------------------------------------
if (agencyPositions.isEmpty) {
List<Position> positions =
await WorkHistoryService.instance.getAgencyPosition();
agencyPositions = positions;
}
/////AGENCIES------------------------------------------
if (agencies.isEmpty) {
List<Agency> newAgencies =
await ProfileUtilities.instance.getAgecies();
agencies = newAgencies;
}
/////Category Agency------------------------------------------
if (agencyCategory.isEmpty) {
List<Category> categoryAgencies =
await ProfileUtilities.instance.agencyCategory();
agencyCategory = categoryAgencies;
}
/////////-------------------------------------
if (appointmentStatus.isEmpty) {
List<AppoinemtStatus> status =
WorkHistoryService.instance.getAppointmentStatusList();
appointmentStatus = status;
}
emit(AddWorkHistoryState(
agencyPositions: agencyPositions,

View File

@ -18,10 +18,8 @@ class GetWorkHistories extends WorkHistorytEvent{
}
class LoadWorkHistories extends WorkHistorytEvent{
final List<WorkHistory> workHistories;
const LoadWorkHistories({required this.workHistories});
@override
List<Object> get props => [workHistories];
List<Object> get props => [];
}
class ShowAddWorkHistoryForm extends WorkHistorytEvent{
@ -35,13 +33,12 @@ class ShowEditWorkHistoryForm extends WorkHistorytEvent{
}
class DeleteWorkHistory extends WorkHistorytEvent{
final List<WorkHistory> workHistories;
final String token;
final int profileId;
final WorkHistory workHistory;
const DeleteWorkHistory({required this.profileId, required this.token, required this.workHistory, required this.workHistories});
const DeleteWorkHistory({required this.profileId, required this.token, required this.workHistory});
@override
List<Object> get props => [token, profileId,workHistory, workHistories];
List<Object> get props => [token, profileId,workHistory];
}
class UpdateWorkHistory extends WorkHistorytEvent{

View File

@ -53,25 +53,22 @@ class EditWorkHistoryState extends WorkHistoryState{
}
class DeletedState extends WorkHistoryState{
final List<WorkHistory> workHistories;
final bool success;
const DeletedState({required this.success, required this.workHistories});
const DeletedState({required this.success});
@override
List<Object> get props => [workHistories,success];
List<Object> get props => [success];
}
class WorkHistoryEditedState extends WorkHistoryState{
final List<WorkHistory> workExperiences;
final Map<dynamic,dynamic> response;
const WorkHistoryEditedState({required this.response, required this.workExperiences});
const WorkHistoryEditedState({required this.response});
@override
List<Object> get props => [workExperiences,response];
List<Object> get props => [response];
}
class WorkHistoryAddedState extends WorkHistoryState{
final List<WorkHistory> workExperiences;
final Map<dynamic,dynamic> response;
const WorkHistoryAddedState({required this.response, required this.workExperiences});
const WorkHistoryAddedState({required this.response});
@override
List<Object> get props => [workExperiences,response];
List<Object> get props => [response];
}

View File

@ -34,6 +34,8 @@ class UserBloc extends Bloc<UserEvent, UserState> {
final String? saved = CREDENTIALS?.get('saved');
final String? username = CREDENTIALS?.get('username');
final String? password = CREDENTIALS?.get('password');
debugPrint(username);
debugPrint(password);
if (saved != null) {
save = true;
add(UserLogin(username: username, password: password));

View File

@ -31,14 +31,14 @@ class _AddContactInformationScreenState
extends State<AddContactInformationScreen> {
final formKey = GlobalKey<FormBuilderState>();
ServiceType? selectedServiceType;
ServiceProvider? selectedProvider;
List<ServiceProvider> serviceProviders = [];
CommService? selectedCommServiceProvider;
List<CommService> commServiceProviders = [];
bool callServiceType = false;
bool primaryaContact = false;
bool active = false;
String? numberMail;
var mobileFormatter = MaskTextInputFormatter(
mask: "+63 (##) ###-###",
mask: "+63 (###) ###-####",
filter: {"#": RegExp(r"^[1-9][0-9]*$")},
type: MaskAutoCompletionType.lazy,
initialText: "0");
@ -82,7 +82,7 @@ class _AddContactInformationScreenState
setState(() {
callServiceType = true;
});
serviceProviders = await ContactService.instance
commServiceProviders = await ContactService.instance
.getServiceProvider(
serviceTypeId: selectedServiceType!.id!);
setState(() {
@ -101,22 +101,22 @@ class _AddContactInformationScreenState
child: ModalProgressHUD(
color: Colors.transparent,
inAsyncCall: callServiceType,
child: FormBuilderDropdown<ServiceProvider>(
child: FormBuilderDropdown<CommService>(
validator: FormBuilderValidators.required(
errorText: "This field is required"),
name: "Service Provider",
items: serviceProviders.isEmpty
items: commServiceProviders.isEmpty
? []
: serviceProviders
.map<DropdownMenuItem<ServiceProvider>>(
(ServiceProvider e) {
return DropdownMenuItem<ServiceProvider>(
value: e, child: Text(e.agency!.name!));
: commServiceProviders
.map<DropdownMenuItem<CommService>>(
(CommService e) {
return DropdownMenuItem<CommService>(
value: e, child: Text(e.serviceProvider!.agency!.name!));
}).toList(),
decoration: normalTextFieldStyle(
"Communication Service *", ""),
onChanged: (var serviceProvider) {
selectedProvider = serviceProvider;
selectedCommServiceProvider = serviceProvider;
}),
),
),
@ -215,10 +215,7 @@ class _AddContactInformationScreenState
numberMail =
formKey.currentState!.value['number-mail'];
CommService commService = CommService(
id: null,
serviceType: selectedServiceType,
serviceProvider: selectedProvider);
CommService commService = selectedCommServiceProvider!;
ContactInfo contactInfo = ContactInfo(
id: null,
active: active,

View File

@ -31,15 +31,15 @@ class _EditContactInformationScreenState
extends State<EditContactInformationScreen> {
final formKey = GlobalKey<FormBuilderState>();
ServiceType? selectedServiceType;
ServiceProvider? selectedProvider;
List<ServiceProvider> serviceProviders = [];
CommService? selectedCommProvider;
List<CommService> commServiceProviders = [];
String? numberMail;
bool callServiceType = false;
bool? primaryaContact;
bool? active;
var mobileFormatter = MaskTextInputFormatter(
mask: "+63 (##) ###-###",
mask: "+63 (###) ###-####",
filter: {"#": RegExp(r"^[1-9][0-9]*$")},
type: MaskAutoCompletionType.lazy,
initialText: "0");
@ -56,8 +56,8 @@ class _EditContactInformationScreenState
builder: (context, state) {
if (state is ContactEditingState) {
selectedServiceType = state.selectedServiceType;
selectedProvider = state.selectedProvider;
serviceProviders = state.serviceProviders;
selectedCommProvider = state.selectedProvider;
commServiceProviders = state.commServiceProviders;
primaryaContact = state.contactInfo.primary!;
active = state.contactInfo.active!;
return FormBuilder(
@ -91,11 +91,11 @@ class _EditContactInformationScreenState
setState(() {
callServiceType = true;
});
serviceProviders = await ContactService.instance
commServiceProviders = await ContactService.instance
.getServiceProvider(
serviceTypeId:
selectedServiceType!.id!);
selectedProvider = null;
selectedCommProvider = null;
setState(() {
setState(() {
callServiceType = false;
@ -112,24 +112,24 @@ class _EditContactInformationScreenState
child: ModalProgressHUD(
color: Colors.transparent,
inAsyncCall: callServiceType,
child: DropdownButtonFormField<ServiceProvider>(
value: selectedProvider,
child: DropdownButtonFormField<CommService>(
value: selectedCommProvider,
validator: FormBuilderValidators.required(
errorText: "This field is required"),
items: serviceProviders.isEmpty
items: commServiceProviders.isEmpty
? []
: serviceProviders
.map<DropdownMenuItem<ServiceProvider>>(
(ServiceProvider e) {
: commServiceProviders
.map<DropdownMenuItem<CommService>>(
(CommService e) {
return DropdownMenuItem<
ServiceProvider>(
CommService>(
value: e,
child: Text(e.agency!.name!));
child: Text(e.serviceProvider!.agency!.name!));
}).toList(),
decoration: normalTextFieldStyle(
"Communication Service *", ""),
onChanged: (var serviceProvider) {
selectedProvider = serviceProvider;
onChanged: (var commServiceProvider) {
selectedCommProvider = commServiceProvider;
}),
),
),
@ -243,10 +243,7 @@ class _EditContactInformationScreenState
if (formKey.currentState!.saveAndValidate()) {
numberMail =
formKey.currentState!.value['number-mail'];
CommService commService = CommService(
id: state.contactInfo.commService!.id,
serviceType: selectedServiceType,
serviceProvider: selectedProvider);
CommService commService = selectedCommProvider!;
ContactInfo contactInfo = ContactInfo(
id: state.contactInfo.id,
active: active,

View File

@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:fluttericon/font_awesome_icons.dart';
import 'package:unit2/bloc/profile/primary_information/contact/contact_bloc.dart';
import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/user/user_bloc.dart';
@ -14,9 +13,9 @@ import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/utils/alerts.dart';
import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/Leadings/add_leading.dart';
import 'package:unit2/widgets/Leadings/close_leading.dart';
import 'package:unit2/widgets/empty_data.dart';
import '../../../../bloc/profile/eligibility/eligibility_bloc.dart';
import 'package:unit2/widgets/error_state.dart';
class ContactInformationScreen extends StatelessWidget {
const ContactInformationScreen({
@ -33,11 +32,15 @@ class ContactInformationScreen extends StatelessWidget {
title: const Text(contactScreenTitle),
centerTitle: true,
backgroundColor: primary,
actions: [
actions: context.watch<ContactBloc>().state is ContactLoadedState? [
AddLeading(onPressed: () {
context.read<ContactBloc>().add(ShowAddForm());
})
],
]:( context.watch<ContactBloc>().state is ContactAddingState || context.watch<ContactBloc>().state is ContactEditingState)?[
CloseLeading(onPressed: (){
context.read<ContactBloc>().add(LoadContacts());
})
]:[]
),
body: ProgressHUD(
padding: const EdgeInsets.all(24),
@ -67,15 +70,14 @@ class ContactInformationScreen extends StatelessWidget {
final progress = ProgressHUD.of(context);
progress!.dismiss();
}
////EDIT CONTACT STATE
if (state is ContactEditedState) {
////ADDED CONTACT STATE
if (state is ContactAddedState) {
if (state.response['success']) {
successAlert(context, "Update Successfull!",
state.response['message'], () {
Navigator.of(context).pop();
context.read<ContactBloc>().add(LoadContacts(
contactInformation:
state.contactInformation));
));
});
} else {
errorAlert(context, "Update Failed",
@ -83,8 +85,27 @@ class ContactInformationScreen extends StatelessWidget {
() {
Navigator.of(context).pop();
context.read<ContactBloc>().add(LoadContacts(
contactInformation:
state.contactInformation));
));
});
}
}
////EDIT CONTACT STATE
if (state is ContactEditedState) {
if (state.response['success']) {
successAlert(context, "Update Successfull!",
state.response['message'], () {
Navigator.of(context).pop();
context.read<ContactBloc>().add(LoadContacts(
));
});
} else {
errorAlert(context, "Update Failed",
"Something went wrong. Please try again.",
() {
Navigator.of(context).pop();
context.read<ContactBloc>().add(LoadContacts(
));
});
}
}
@ -97,16 +118,14 @@ class ContactInformationScreen extends StatelessWidget {
() {
Navigator.of(context).pop();
context.read<ContactBloc>().add(LoadContacts(
contactInformation:
state.contactInformation));
));
});
} else {
errorAlert(context, "Deletion Failed",
"Error deleting Contact Info", () {
Navigator.of(context).pop();
context.read<ContactBloc>().add(LoadContacts(
contactInformation:
state.contactInformation));
));
});
}
}
@ -136,8 +155,7 @@ class ContactInformationScreen extends StatelessWidget {
children: [
Container(
decoration: box1(),
padding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 8),
padding: const EdgeInsets.fromLTRB(12, 12, 0, 12),
child: Row(
children: [
Expanded(
@ -149,30 +167,18 @@ class ContactInformationScreen extends StatelessWidget {
CrossAxisAlignment
.start,
children: [
Text(numberMail,
Row(
children: [
Expanded(
child: Text(
numberMail,
style: Theme.of(
context)
.textTheme
.titleMedium!
.copyWith(
fontWeight:
FontWeight
.w500)),
const Divider(),
const SizedBox(
height: 5,
),
Row(
children: [
Expanded(
child: Text(
commService
.toString(),
style: Theme.of(
context)
.textTheme
.titleSmall,
),
FontWeight.w500)),
),
state.contactInformation[index]
.active ==
@ -201,10 +207,30 @@ class ContactInformationScreen extends StatelessWidget {
: const SizedBox()
],
),
const Divider(),
const SizedBox(
height: 5,
),
Text(state
Row(
children: [
Flexible(
flex: 2,
child: Text(
commService
.toString().toUpperCase(),
style: Theme.of(
context)
.textTheme
.titleSmall,
),
),
const SizedBox(
child: Text(" - "),
),
Flexible(
flex: 1,
child: Text(state
.contactInformation[
index]
.commService!
@ -212,6 +238,9 @@ class ContactInformationScreen extends StatelessWidget {
.agency!
.name
.toString()),
),
],
),
]),
),
AppPopupMenu<int>(
@ -298,6 +327,12 @@ class ContactInformationScreen extends StatelessWidget {
return EditContactInformationScreen(
profileId: profileId, token: token);
}
if (state is ContactErrorState) {
return SomethingWentWrong(
message: state.message, onpressed: () {
context.read<ContactBloc>().add(LoadContacts());
});
}
return Container();
},
);

View File

@ -24,7 +24,10 @@ import '../../../../utils/location_utilities.dart';
import '../../../../utils/text_container.dart';
class AddEligibilityScreen extends StatefulWidget {
const AddEligibilityScreen({super.key});
const AddEligibilityScreen(
{super.key, required this.profileId, required this.token});
final int profileId;
final String token;
@override
State<AddEligibilityScreen> createState() => _AddEligibilityScreenState();
@ -32,7 +35,7 @@ class AddEligibilityScreen extends StatefulWidget {
class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
final formKey = GlobalKey<FormBuilderState>();
bool? overseas;
bool? overseas = false;
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
Region? selectedRegion;
Province? selectedProvince;
@ -51,30 +54,21 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
String? license;
@override
Widget build(BuildContext context) {
////USERBLOC
return BlocBuilder<UserBloc, UserState>(
builder: (context, state) {
////LOGGED IN USER STATE
if (state is UserLoggedIn) {
////PROFIILE BLOC
token = state.userData!.user!.login!.token;
profileId = state.userData!.user!.login!.user!.profileId.toString();
return BlocBuilder<ProfileBloc, ProfileState>(
builder: (context, state) {
if (state is ProfileLoaded) {
return BlocBuilder<EligibilityBloc, EligibilityState>(
buildWhen: (previous, current) {
if (state is EditEligibilityState) {}
return false;
},
builder: (context, state) {
////ADD ELIGIBILITY STATE
if (state is AddEligibilityState) {
return ProgressHUD(
return SingleChildScrollView(
child: SizedBox(
height: screenHeight * .95,
child: ProgressHUD(
child: Center(
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 25, horizontal: 18),
padding:
const EdgeInsets.symmetric(vertical: 25, horizontal: 18),
child: FormBuilder(
key: formKey,
child: Column(
@ -101,7 +95,7 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
decoration: normalTextFieldStyle(
"Eligibility", "Eligibility")),
const SizedBox(
height: 20,
height: 8,
),
SizedBox(
@ -117,19 +111,18 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
},
name: 'license_number',
decoration: normalTextFieldStyle(
"license number",
"license number"),
"license number", "license number"),
),
),
const SizedBox(
width: 12,
width: 8,
),
////RATING
Flexible(
flex: 1,
child: FormBuilderTextField(
keyboardType: const TextInputType
.numberWithOptions(),
keyboardType:
const TextInputType.numberWithOptions(),
onChanged: (value) {
rating = value;
},
@ -142,7 +135,7 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
),
),
const SizedBox(
height: 20,
height: 8,
),
SizedBox(
width: screenWidth,
@ -152,41 +145,38 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
Flexible(
flex: 1,
child: DateTimePicker(
validator: FormBuilderValidators.required(errorText: "This field is required"),
validator: FormBuilderValidators.required(
errorText: "This field is required"),
use24HourFormat: false,
icon: const Icon(
Icons.date_range),
icon: const Icon(Icons.date_range),
controller: examDateController,
firstDate: DateTime(1970),
lastDate: DateTime(2100),
timeHintText:
"Date of Examination/Conferment",
decoration:
normalTextFieldStyle(
"Exam date", "")
normalTextFieldStyle("Exam date", "")
.copyWith(
prefixIcon:
const Icon(
prefixIcon: const Icon(
Icons.date_range,
color: Colors.black87,
)),
initialValue: null,
)),
const SizedBox(
width: 12,
width: 8,
),
////VALIDITY DATE
Flexible(
flex: 1,
child: DateTimePicker(
validator: FormBuilderValidators.required(errorText: "This field is required"),
controller:
validityDateController,
validator: FormBuilderValidators.required(
errorText: "This field is required"),
controller: validityDateController,
firstDate: DateTime(1970),
lastDate: DateTime(2100),
decoration: normalTextFieldStyle(
"Validity date",
"Validity date")
"Validity date", "Validity date")
.copyWith(
prefixIcon: const Icon(
Icons.date_range,
@ -199,24 +189,24 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
),
),
const SizedBox(
height: 20,
height: 8,
),
Text(
"Placement of Examination/Conferment",
style: Theme.of(context)
.textTheme
.displaySmall!
.copyWith(
fontSize: blockSizeVertical * 2),
.copyWith(fontSize: blockSizeVertical * 2),
),
const SizedBox(
height: 12,
height: 8,
),
////OVERSEAS ADDRESS SWITCH
Column(
children: [
FormBuilderSwitch(
validator: FormBuilderValidators.required(errorText: 'This field is required'),
validator: FormBuilderValidators.required(
errorText: 'This field is required'),
initialValue: overseas,
activeColor: second,
onChanged: (value) {
@ -224,91 +214,80 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
overseas = value;
});
},
decoration:
normalTextFieldStyle("", ''),
decoration: normalTextFieldStyle("", ''),
name: 'overseas',
title:
const Text("Overseas Address?"),
title: const Text("Overseas Address?"),
),
const SizedBox(
height: 20,
height: 8,
),
////COUNTRY DROPDOWN
SizedBox(
child: overseas == true
? FormBuilderDropdown<Country>(
initialValue: null,
validator: FormBuilderValidators.required(errorText: "This field is required"),
items: state.countries.map<
DropdownMenuItem<
Country>>(
validator:
FormBuilderValidators.required(
errorText:
"This field is required"),
items: state.countries
.map<DropdownMenuItem<Country>>(
(Country country) {
return DropdownMenuItem<
Country>(
return DropdownMenuItem<Country>(
value: country,
child: FittedBox(
child: Text(
country
.name!)));
child: Text(country.name!)));
}).toList(),
name: 'country',
decoration:
normalTextFieldStyle(
"Country*",
"Country"),
onChanged:
(Country? value) {
decoration: normalTextFieldStyle(
"Country*", "Country"),
onChanged: (Country? value) {
selectedCountry = value;
},
)
: Column(
children: [
////REGION DROPDOWN
FormBuilderDropdown<
Region?>(
autovalidateMode:
AutovalidateMode
FormBuilderDropdown<Region?>(
autovalidateMode: AutovalidateMode
.onUserInteraction,
validator: FormBuilderValidators.required(errorText: "This field is required"),
validator:
FormBuilderValidators.required(
errorText:
"This field is required"),
//// region onchange
onChanged: (Region?
region) async {
onChanged: (Region? region) async {
if(selectedRegion != region){
setState(() {
provinceCall = true;
});
selectedRegion =
region;
selectedRegion = region;
getProvinces();
}
},
initialValue:
selectedRegion,
decoration:
normalTextFieldStyle(
"Region*",
"Region"),
initialValue: selectedRegion,
decoration: normalTextFieldStyle(
"Region*", "Region"),
name: 'region',
items: state.regions.map<
DropdownMenuItem<
Region>>((Region
region) {
return DropdownMenuItem<
Region>(
items: state.regions
.map<DropdownMenuItem<Region>>(
(Region region) {
return DropdownMenuItem<Region>(
value: region,
child: Text(region
.description!));
child: Text(
region.description!));
}).toList(),
),
const SizedBox(
height: 20,
height: 8,
),
////PROVINCE DROPDOWN
SizedBox(
height: 70,
child: ModalProgressHUD(
color: Colors
.transparent,
inAsyncCall:
provinceCall,
color: Colors.transparent,
inAsyncCall: provinceCall,
child: DropdownButtonFormField<
Province?>(
autovalidateMode:
@ -319,33 +298,29 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
? 'required'
: null,
isExpanded: true,
value:
selectedProvince,
value: selectedProvince,
onChanged:
(Province?
province) {
(Province? province) {
if(selectedProvince != province){
setState(() {
cityCall =
true;
cityCall = true;
});
selectedProvince =
province;
selectedProvince = province;
getCities();
}
},
items: provinces ==
null
items: provinces == null
? []
: provinces!.map<
DropdownMenuItem<
Province>>((Province
province) {
Province>>(
(Province province) {
return DropdownMenuItem(
value:
province,
child:
FittedBox(
child:
Text(province.description!),
value: province,
child: FittedBox(
child: Text(province
.description!),
));
}).toList(),
decoration:
@ -357,7 +332,7 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
//// CityMunicipalities dropdown
SizedBox(
height: 70,
height: 60,
child: ModalProgressHUD(
color: Colors.white,
inAsyncCall: cityCall,
@ -369,36 +344,29 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
: null,
isExpanded: true,
onChanged:
(CityMunicipality?
city) {
selectedMunicipality =
city;
(CityMunicipality? city) {
selectedMunicipality = city;
},
decoration: normalTextFieldStyle(
decoration:
normalTextFieldStyle(
"Municipality*",
"Municipality"),
value:
selectedMunicipality,
items: citymuns ==
null
value: selectedMunicipality,
items: citymuns == null
? []
: citymuns!.map<
DropdownMenuItem<
CityMunicipality>>(
(CityMunicipality
c) {
(CityMunicipality c) {
return DropdownMenuItem(
value:
c,
child: Text(
c.description!));
value: c,
child: Text(c
.description!));
}).toList(),
),
),
),
const SizedBox(
height: 20,
),
],
)),
],
@ -412,8 +380,8 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
width: screenWidth,
height: 60,
child: ElevatedButton(
style: mainBtnStyle(primary,
Colors.transparent, second),
style: mainBtnStyle(
primary, Colors.transparent, second),
onPressed: () {
//rating
double? rate = rating == null
@ -423,22 +391,17 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
String? licenseNumber = license;
CityMunicipality? cityMunicipality =
selectedMunicipality;
DateTime? examDate =
examDateController.text.isEmpty
? null
: DateTime.parse(
examDateController
.text);
DateTime? validityDate =
validityDateController
DateTime? examDate = examDateController
.text.isEmpty
? null
: DateTime.parse(examDateController.text);
DateTime? validityDate =
validityDateController.text.isEmpty
? null
: DateTime.parse(
validityDateController
.text);
validityDateController.text);
ExamAddress examAddress =
ExamAddress(
ExamAddress examAddress = ExamAddress(
barangay: null,
id: null,
addressCategory: null,
@ -448,30 +411,26 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
id: 175,
name: 'Philippines',
code: 'PH'),
cityMunicipality:
cityMunicipality);
EligibityCert eligibityCert =
EligibityCert(
cityMunicipality: cityMunicipality);
EligibityCert eligibityCert = EligibityCert(
id: null,
rating: rate,
examDate: examDate,
attachments: null,
eligibility:
selectedEligibility,
eligibility: selectedEligibility,
examAddress: examAddress,
validityDate: validityDate,
licenseNumber:
licenseNumber,
licenseNumber: licenseNumber,
overseas: overseas);
if (formKey.currentState!
.saveAndValidate()) {
context
.read<EligibilityBloc>()
.add(AddEligibility(
eligibityCert:
eligibityCert,
profileId: profileId!,
token: token!));
if (formKey.currentState!.saveAndValidate()) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Loading...");
context.read<EligibilityBloc>().add(
AddEligibility(
eligibityCert: eligibityCert,
profileId:
widget.profileId.toString(),
token: widget.token));
}
// context.read<ProfileBloc>().add(AddEligibility(eligibityCert: eligibityCert, profileId: profileId, token: token))
},
@ -484,16 +443,11 @@ class _AddEligibilityScreenState extends State<AddEligibilityScreen> {
),
),
),
),
),
);
}
return Container();
},
);
}
return Container();
},
);
}
return Container();
},
);

View File

@ -2,11 +2,10 @@ import 'package:date_time_picker/date_time_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:intl/intl.dart';
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/user/user_bloc.dart';
import 'package:unit2/model/location/city.dart';
import 'package:unit2/model/profile/eligibility.dart';
import 'package:unit2/model/utils/eligibility.dart';
@ -23,7 +22,9 @@ import '../../../../utils/text_container.dart';
class EditEligibilityScreen extends StatefulWidget {
final EligibityCert eligibityCert;
const EditEligibilityScreen({super.key, required this.eligibityCert});
final int profileId;
final String token;
const EditEligibilityScreen({super.key, required this.eligibityCert, required this.profileId, required this.token});
@override
State<EditEligibilityScreen> createState() => _EditEligibilityScreenState();
@ -52,20 +53,10 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
final validityDateController = TextEditingController();
@override
Widget build(BuildContext context) {
//USERBLOC
return BlocBuilder<UserBloc, UserState>(
builder: (context, state) {
//LOGGED IN USER STATE
if (state is UserLoggedIn) {
//PROFIILE BLOC
token = state.userData!.user!.login!.token;
profileId = state.userData!.user!.login!.user!.profileId.toString();
return BlocBuilder<ProfileBloc, ProfileState>(
builder: (context, state) {
if(state is ProfileLoaded){
return BlocBuilder<EligibilityBloc, EligibilityState>(
buildWhen: (previous, current) {
if (state is EditEligibilityState) {}
return false;
},
builder: (context, state) {
@ -194,6 +185,8 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
Flexible(
flex: 1,
child: DateTimePicker(
validator: FormBuilderValidators.required(errorText: "This field is required"),
use24HourFormat: false,
controller: validityDateController,
firstDate: DateTime(1970),
@ -514,6 +507,11 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
overseas: overseas);
if (formKey.currentState!
.saveAndValidate()) {
final progress =
ProgressHUD.of(
context);
progress!.showWithText(
"Loading...");
context.read<EligibilityBloc>().add(
UpdateEligibility(
eligibityCert: eligibityCert,
@ -521,8 +519,8 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
.eligibityCert
.eligibility!
.id,
profileId: profileId!,
token: token!));
profileId:widget.profileId.toString(),
token: widget.token));
}
},
child: const Text(submit)),
@ -534,15 +532,8 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
),
),
);
}
return Container();
},
);
}
return Container();
},
);
}
return Container();
},

View File

@ -16,6 +16,7 @@ import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/Leadings/add_leading.dart';
import 'package:unit2/widgets/Leadings/close_leading.dart';
import 'package:unit2/widgets/empty_data.dart';
import 'package:unit2/widgets/error_state.dart';
import '../../../bloc/profile/eligibility/eligibility_bloc.dart';
import '../../../utils/alerts.dart';
@ -25,13 +26,14 @@ class EligibiltyScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
String? token;
String? profileId;
int? profileId;
return WillPopScope(
onWillPop: () async {
return true;
},
child: Scaffold(
resizeToAvoidBottomInset: true,
appBar: AppBar(
title: context.watch<EligibilityBloc>().state is AddEligibilityState
? const Text("Add Eligiblity")
@ -40,8 +42,8 @@ class EligibiltyScreen extends StatelessWidget {
: const Text(elibilityScreenTitle),
centerTitle: true,
backgroundColor: primary,
actions: (context.watch<EligibilityBloc>().state is EligibilityLoaded ||
context.watch<EligibilityBloc>().state is ProfileLoading)
actions: (context.watch<EligibilityBloc>().state is EligibilityLoaded)
? [
AddLeading(onPressed: () {
context
@ -49,19 +51,18 @@ class EligibiltyScreen extends StatelessWidget {
.add(ShowAddEligibilityForm());
})
]
: [
:(context.watch<EligibilityBloc>().state is AddEligibilityState || context.watch<EligibilityBloc>().state is EditEligibilityState)? [
CloseLeading(onPressed: () {
context.read<EligibilityBloc>().add(GetEligibilities(
profileId: int.parse(profileId!), token: token!));
context.read<EligibilityBloc>().add(const LoadEligibility());
})
],
]:[],
),
body: BlocBuilder<UserBloc, UserState>(
builder: (context, state) {
if (state is UserLoggedIn) {
token = state.userData!.user!.login!.token;
profileId =
state.userData!.user!.login!.user!.profileId.toString();
state.userData!.user!.login!.user!.profileId;
return BlocBuilder<ProfileBloc, ProfileState>(
builder: (context, state) {
if(state is ProfileLoaded){
@ -82,7 +83,9 @@ class EligibiltyScreen extends StatelessWidget {
state is EditEligibilityState ||
state is DeletedState ||
state is EligibilityAddedState ||
state is EligibilityEditedState) {
state is EligibilityEditedState ||
state is EligibilityErrorState
) {
final progress = ProgressHUD.of(context);
progress!.dismiss();
}
@ -93,15 +96,15 @@ class EligibiltyScreen extends StatelessWidget {
"Eligibility has been deleted successfully",
() {
Navigator.of(context).pop();
context.read<EligibilityBloc>().add(LoadEligibility(
eligibilities: state.eligibilities));
context.read<EligibilityBloc>().add(const LoadEligibility(
));
});
} else {
errorAlert(context, "Deletion Failed",
"Error deleting eligibility", () {
Navigator.of(context).pop();
context.read<EligibilityBloc>().add(LoadEligibility(
eligibilities: state.eligibilities));
context.read<EligibilityBloc>().add(const LoadEligibility(
));
});
}
}
@ -111,16 +114,16 @@ class EligibiltyScreen extends StatelessWidget {
successAlert(context, "Adding Successfull!",
state.response['message'], () {
Navigator.of(context).pop();
context.read<EligibilityBloc>().add(LoadEligibility(
eligibilities: state.eligibilities));
context.read<EligibilityBloc>().add(const LoadEligibility(
));
});
} else {
errorAlert(context, "Adding Failed",
"Something went wrong. Please try again.",
() {
Navigator.of(context).pop();
context.read<EligibilityBloc>().add(LoadEligibility(
eligibilities: state.eligibilities));
context.read<EligibilityBloc>().add(const LoadEligibility(
));
});
}
}
@ -130,16 +133,16 @@ class EligibiltyScreen extends StatelessWidget {
successAlert(context, "Update Successfull!",
state.response['message'], () {
Navigator.of(context).pop();
context.read<EligibilityBloc>().add(LoadEligibility(
eligibilities: state.eligibilities));
context.read<EligibilityBloc>().add(const LoadEligibility(
));
});
} else {
errorAlert(context, "Update Failed",
"Something went wrong. Please try again.",
() {
Navigator.of(context).pop();
context.read<EligibilityBloc>().add(LoadEligibility(
eligibilities: state.eligibilities));
context.read<EligibilityBloc>().add(const LoadEligibility(
));
});
}
}
@ -221,27 +224,29 @@ class EligibiltyScreen extends StatelessWidget {
const Offset(-10, -10),
elevation: 3,
onSelected: (value) {
////delete eligibilty-= = = = = = = = =>>
if (value == 2) {
confirmAlert(context,
() {
final progress =
ProgressHUD.of(
context);
progress!.showWithText(
"Loading...");
////delete eligibilty-= = = = = = = = =>>
if (value == 2) {
confirmAlert(context,
() {
BlocProvider.of<
EligibilityBloc>(
context)
.add(DeleteEligibility(
eligibilities: state
.eligibilities,
eligibilityId: state
.eligibilities[
index]
.id!,
profileId:
profileId!,
profileId.toString(),
token:
token!));
}, "Delete?",
@ -249,6 +254,11 @@ class EligibiltyScreen extends StatelessWidget {
}
if (value == 1) {
////edit eligibilty-= = = = = = = = =>>
final progress =
ProgressHUD.of(
context);
progress!.showWithText(
"Loading...");
EligibityCert
eligibityCert =
state.eligibilities[
@ -312,15 +322,17 @@ class EligibiltyScreen extends StatelessWidget {
}
if (state is EditEligibilityState) {
return EditEligibilityScreen(
profileId: profileId!,
token: token!,
eligibityCert: state.eligibityCert);
}
if (state is AddEligibilityState) {
return const AddEligibilityScreen();
return AddEligibilityScreen(token: token!,profileId: profileId!,);
}
if (state is EligibilityErrorState) {
return Center(
child: Text(state.message),
);
return SomethingWentWrong(message: state.message, onpressed: (){
context.read<EligibilityBloc>().add(LoadEligibility(token: token,profileId: profileId));
});
}
return Container(
color: Colors.grey.shade200,

View File

@ -135,21 +135,20 @@ class LoadingScreen extends StatelessWidget {
),
Center(
child: Container(
height: 120,
width: 120,
height: 80,
width: 80,
decoration:const BoxDecoration(
color: Colors.black87,
borderRadius: BorderRadius.all(Radius.circular(25))
borderRadius: BorderRadius.all(Radius.circular(8))
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: const[
SpinKitFadingCircle(
size: 42,
color: Colors.white),
SizedBox(height: 10,),
Text("Loading Profile",textAlign: TextAlign.center, style: TextStyle(color: Colors.white,fontSize: 10),)
],
),
),

View File

@ -5,11 +5,8 @@ import 'package:fluttericon/font_awesome_icons.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:searchfield/searchfield.dart';
import 'package:unit2/bloc/profile/other_information/org_membership/organization_membership_bloc.dart';
import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/user/user_bloc.dart';
import 'package:unit2/model/utils/agency.dart';
import 'package:unit2/utils/text_container.dart';
import '../../../../../model/utils/category.dart';
import '../../../../../theme-data.dart/box_shadow.dart';
import '../../../../../theme-data.dart/btn-style.dart';
@ -17,7 +14,10 @@ import '../../../../../theme-data.dart/colors.dart';
import '../../../../../theme-data.dart/form-style.dart';
class AddOrgMemberShipScreen extends StatefulWidget {
const AddOrgMemberShipScreen({super.key});
final int profileId;
final String token;
const AddOrgMemberShipScreen(
{super.key, required this.profileId, required this.token});
@override
State<AddOrgMemberShipScreen> createState() => _AddOrgMemberShipScreenState();
@ -34,39 +34,26 @@ Agency? newAgency;
bool showIsPrivateRadio = false;
bool? isPrivate = false;
final _formKey = GlobalKey<FormBuilderState>();
int? profileId;
String? token;
class _AddOrgMemberShipScreenState extends State<AddOrgMemberShipScreen> {
@override
Widget build(BuildContext context) {
return BlocBuilder<UserBloc, UserState>(
builder: (context, state) {
if (state is UserLoggedIn) {
token = state.userData!.user!.login!.token;
profileId = state.userData!.user!.login!.user!.profileId;
return BlocBuilder<ProfileBloc, ProfileState>(
builder: (context, state) {
if (state is ProfileLoaded) {
return BlocBuilder<OrganizationMembershipBloc,
OrganizationMembershipState>(
return BlocBuilder<OrganizationMembershipBloc, OrganizationMembershipState>(
builder: (context, state) {
if (state is AddOrgMembershipState) {
return SingleChildScrollView(
child: FormBuilder(
key: _formKey,
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 25, horizontal: 18),
padding:
const EdgeInsets.symmetric(vertical: 25, horizontal: 18),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(
height: 100,
),
StatefulBuilder(
builder: (context, setState) {
StatefulBuilder(builder: (context, setState) {
//// AGENCY SEARCHFIELD
return Column(
children: [
@ -74,20 +61,15 @@ class _AddOrgMemberShipScreenState extends State<AddOrgMemberShipScreen> {
itemHeight: 70,
suggestions: state.agencies
.map((Agency agency) =>
SearchFieldListItem(
agency.name!,
SearchFieldListItem(agency.name!,
item: agency,
child: ListTile(
title: Text(
agency.name!
.toUpperCase(),
overflow:
TextOverflow
.ellipsis,
agency.name!.toUpperCase(),
overflow: TextOverflow.ellipsis,
),
subtitle: Text(agency
.privateEntity ==
true
subtitle: Text(
agency.privateEntity == true
? "Private"
: agency.privateEntity ==
false
@ -95,26 +77,20 @@ class _AddOrgMemberShipScreenState extends State<AddOrgMemberShipScreen> {
: ""),
)))
.toList(),
validator: FormBuilderValidators
.required(
errorText:
"This field is required"),
validator: FormBuilderValidators.required(
errorText: "This field is required"),
focusNode: agencyFocusNode,
searchInputDecoration:
normalTextFieldStyle(
searchInputDecoration: normalTextFieldStyle(
"Agency *", "")
.copyWith(
suffixIcon:
const Icon(Icons
.arrow_drop_down)),
const Icon(Icons.arrow_drop_down)),
////agency suggestion tap
onSuggestionTap: (agency) {
setState(() {
selectedAgency = agency.item;
agencyFocusNode.unfocus();
if (selectedAgency
?.category ==
null) {
if (selectedAgency?.category == null) {
showAgencyCategory = true;
showIsPrivateRadio = true;
} else {
@ -128,17 +104,14 @@ class _AddOrgMemberShipScreenState extends State<AddOrgMemberShipScreen> {
height: 100,
child: Column(
mainAxisAlignment:
MainAxisAlignment
.center,
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment
.center,
CrossAxisAlignment.center,
children: [
const SizedBox(
height: 20,
),
const Text(
"No result found..."),
const Text("No result found..."),
const SizedBox(
height: 10,
),
@ -146,54 +119,62 @@ class _AddOrgMemberShipScreenState extends State<AddOrgMemberShipScreen> {
//// Add agency onpressed
onPressed: () {
showDialog(
context:
context,
context: context,
builder:
(BuildContext
context) {
(BuildContext context) {
return AlertDialog(
title: const Text(
"Add Agency?"),
content:
SizedBox(
height:
130,
child:
Column(
content: SizedBox(
height: 130,
child: Column(
children: [
TextFormField(
controller:
addAgencyController,
decoration:
normalTextFieldStyle("", ""),
normalTextFieldStyle(
"", ""),
),
const SizedBox(
height:
12,
height: 12,
),
SizedBox(
width: double.infinity,
width: double
.infinity,
height: 50,
child: ElevatedButton(
style: mainBtnStyle(primary, Colors.transparent, second),
child:
ElevatedButton(
style: mainBtnStyle(
primary,
Colors
.transparent,
second),
//// onpressed
onPressed: () {
setState(() {
newAgency = Agency(id: null, name: addAgencyController.text.toUpperCase(), category: null, privateEntity: null);
state.agencies.insert(0, newAgency!);
onPressed:
() {
setState(
() {
newAgency = Agency(
id: null,
name: addAgencyController.text.toUpperCase(),
category: null,
privateEntity: null);
state.agencies.insert(0,
newAgency!);
addAgencyController.clear();
Navigator.pop(context);
});
},
child: const Text("Add"))),
child: const Text(
"Add"))),
],
),
),
);
});
},
child: const Text(
"Add position"))
child: const Text("Add position"))
]),
),
),
@ -203,23 +184,16 @@ class _AddOrgMemberShipScreenState extends State<AddOrgMemberShipScreen> {
SizedBox(
child: showAgencyCategory
? SearchField(
focusNode:
agencyCategoryFocusNode,
focusNode: agencyCategoryFocusNode,
itemHeight: 70,
suggestions: state
.agencyCategories
.map((Category
category) =>
suggestions: state.agencyCategories
.map((Category category) =>
SearchFieldListItem(
category
.name!,
item:
category,
child:
ListTile(
title: Text(
category
.name!),
category.name!,
item: category,
child: ListTile(
title:
Text(category.name!),
subtitle: Text(category
.industryClass!
.name!),
@ -229,33 +203,26 @@ class _AddOrgMemberShipScreenState extends State<AddOrgMemberShipScreen> {
height: 100,
decoration: box1(),
child: const Center(
child: Text(
"No result found ...")),
child:
Text("No result found ...")),
),
////agency controller suggestion tap
onSuggestionTap:
(agencyCategory) {
onSuggestionTap: (agencyCategory) {
setState(() {
selectedCategory =
agencyCategory
.item;
agencyCategory.item;
agencyCategoryFocusNode
.unfocus();
agencyCategoryFocusNode.unfocus();
});
},
searchInputDecoration:
normalTextFieldStyle(
"Category *",
"")
"Category *", "")
.copyWith(
suffixIcon:
const Icon(
Icons
.arrow_drop_down)),
suffixIcon: const Icon(
Icons.arrow_drop_down)),
validator:
FormBuilderValidators
.required(
FormBuilderValidators.required(
errorText:
"This field is required"),
)
@ -266,24 +233,19 @@ class _AddOrgMemberShipScreenState extends State<AddOrgMemberShipScreen> {
SizedBox(
child: showIsPrivateRadio
? FormBuilderRadioGroup(
decoration:
InputDecoration(
border:
InputBorder.none,
decoration: InputDecoration(
border: InputBorder.none,
label: Row(
children: [
Text(
"Is this private sector? ",
style: Theme.of(
context)
style: Theme.of(context)
.textTheme
.headlineSmall!
.copyWith(
fontSize:
24),
.copyWith(fontSize: 24),
),
const Icon(FontAwesome
.help_circled)
const Icon(
FontAwesome.help_circled)
],
),
),
@ -291,9 +253,7 @@ class _AddOrgMemberShipScreenState extends State<AddOrgMemberShipScreen> {
////onvhange private sector
onChanged: (value) {
setState(() {
if (value
.toString() ==
"YES") {
if (value.toString() == "YES") {
isPrivate = true;
} else {
isPrivate = false;
@ -303,18 +263,14 @@ class _AddOrgMemberShipScreenState extends State<AddOrgMemberShipScreen> {
name: 'isPrivate',
validator:
FormBuilderValidators
.required(
FormBuilderValidators.required(
errorText:
"This field is required"),
options: ["YES", "NO"]
.map((lang) =>
FormBuilderFieldOption(
value:
lang))
.toList(
growable:
false),
value: lang))
.toList(growable: false),
)
: const SizedBox()),
],
@ -329,23 +285,26 @@ class _AddOrgMemberShipScreenState extends State<AddOrgMemberShipScreen> {
height: 60,
width: double.infinity,
child: ElevatedButton(
style: mainBtnStyle(primary,
Colors.transparent, second),
style: mainBtnStyle(
primary, Colors.transparent, second),
onPressed: () {
if (_formKey.currentState!
.saveAndValidate()) {
if (_formKey.currentState!.saveAndValidate()) {
if (selectedAgency?.privateEntity != null) {
newAgency = selectedAgency;
} else {
newAgency = Agency(
id: selectedAgency?.id,
name: selectedAgency!.name,
category:
selectedCategory,
category: selectedCategory,
privateEntity: isPrivate);
}
context.read<OrganizationMembershipBloc>().add(AddOrgMembership(agency: newAgency!, profileId: profileId!, token: token!));
context
.read<OrganizationMembershipBloc>()
.add(AddOrgMembership(
agency: newAgency!,
profileId: widget.profileId,
token: widget.token));
setState(() {
showAgencyCategory = false;
showIsPrivateRadio = false;
@ -362,12 +321,4 @@ class _AddOrgMemberShipScreenState extends State<AddOrgMemberShipScreen> {
},
);
}
return Container();
},
);
}
return const Placeholder();
},
);
}
}

View File

@ -14,6 +14,7 @@ import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/Leadings/add_leading.dart';
import 'package:unit2/widgets/Leadings/close_leading.dart';
import 'package:unit2/widgets/empty_data.dart';
import 'package:unit2/widgets/error_state.dart';
import '../../../../bloc/profile/other_information/org_membership/organization_membership_bloc.dart';
import '../../../../utils/alerts.dart';
import '../../../../utils/global.dart';
@ -65,6 +66,7 @@ class OrgMembershipsScreen extends StatelessWidget {
final progress = ProgressHUD.of(context);
progress!.dismiss();
}
////ADDED STATE
if (state is OrgMembershipAddedState) {
if (state.response['success']) {
@ -73,8 +75,7 @@ class OrgMembershipsScreen extends StatelessWidget {
Navigator.of(context).pop();
context.read<OrganizationMembershipBloc>().add(
LoadOrganizationMemberships(
organizationMemberships:
state.orgMemberships));
));
});
} else {
errorAlert(context, "Adding Failed",
@ -83,8 +84,7 @@ class OrgMembershipsScreen extends StatelessWidget {
Navigator.of(context).pop();
context.read<OrganizationMembershipBloc>().add(
LoadOrganizationMemberships(
organizationMemberships:
state.orgMemberships));
));
});
}
}
@ -96,7 +96,7 @@ class OrgMembershipsScreen extends StatelessWidget {
Navigator.of(context).pop();
context.read<OrganizationMembershipBloc>().add(
LoadOrganizationMemberships(
organizationMemberships: state.organizationMemberships));
));
});
} else {
errorAlert(context, "Deletion Failed",
@ -104,7 +104,7 @@ class OrgMembershipsScreen extends StatelessWidget {
Navigator.of(context).pop();
context.read<OrganizationMembershipBloc>().add(
LoadOrganizationMemberships(
organizationMemberships: state.organizationMemberships));
));
});
}
}
@ -161,14 +161,15 @@ class OrgMembershipsScreen extends StatelessWidget {
offset: const Offset(-10, -10),
elevation: 3,
onSelected: (value) {
////delete orgmembership-= = = = = = = = =>>
if (value == 1) {
confirmAlert(context, () {
final progress =
ProgressHUD.of(context);
progress!
.showWithText("Loading...");
////delete orgmembership-= = = = = = = = =>>
if (value == 1) {
confirmAlert(context, () {
context.read<OrganizationMembershipBloc>().add(DeleteOrgMemberShip(profileId: profileId, token: token!, org: state.orgMemberships[index], organizationMemberships: state.orgMemberships));
context.read<OrganizationMembershipBloc>().add(DeleteOrgMemberShip(profileId: profileId, token: token!, org: state.orgMemberships[index]));
}, "Delete?",
"Confirm Delete?");
}
@ -198,9 +199,13 @@ class OrgMembershipsScreen extends StatelessWidget {
});
}
if (state is AddOrgMembershipState) {
return const AddOrgMemberShipScreen();
return AlertDialog(
content: AddOrgMemberShipScreen(profileId: profileId,token: token!,)
);
}if(state is OrganizationMembershipErrorState){
return Container(child: Text(state.message),);
return SomethingWentWrong(message: state.message, onpressed: (){
context.read<OrganizationMembershipBloc>().add(GetOrganizationMembership(token: token,profileId: profileId));
});
}
return Container();
},

View File

@ -1,6 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/placeholder.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
@ -9,9 +7,7 @@ import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/user/user_bloc.dart';
import 'package:unit2/model/profile/other_information/skills_and_hobbies.dart';
import 'package:unit2/screens/profile/components/other_information/skills_hobbies/add_modal.dart';
import 'package:unit2/theme-data.dart/box_shadow.dart';
import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/utils/global.dart';
import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/Leadings/add_leading.dart';
import 'package:unit2/widgets/empty_data.dart';

View File

@ -4,14 +4,13 @@ import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/profile/references/references_bloc.dart';
import 'package:unit2/bloc/user/user_bloc.dart';
import 'package:unit2/model/location/address_category.dart';
import 'package:unit2/model/location/barangay.dart';
import 'package:unit2/model/profile/references.dart';
import 'package:unit2/theme-data.dart/btn-style.dart';
import 'package:unit2/theme-data.dart/form-style.dart';
import 'package:unit2/utils/global.dart';
import '../../../../model/location/city.dart';
import '../../../../model/location/country.dart';
import '../../../../model/location/provinces.dart';
@ -21,7 +20,10 @@ import '../../../../utils/location_utilities.dart';
import '../../../../utils/text_container.dart';
class AddReferenceScreen extends StatefulWidget {
const AddReferenceScreen({super.key});
final int profileId;
final String token;
const AddReferenceScreen(
{super.key, required this.profileId, required this.token});
@override
State<AddReferenceScreen> createState() => _AddReferenceScreenState();
@ -29,8 +31,6 @@ class AddReferenceScreen extends StatefulWidget {
class _AddReferenceScreenState extends State<AddReferenceScreen> {
final formKey = GlobalKey<FormBuilderState>();
String? token;
String? profileId;
bool provinceCall = false;
bool cityCall = false;
bool barangayCall = false;
@ -48,21 +48,15 @@ class _AddReferenceScreenState extends State<AddReferenceScreen> {
AddressCategory? selectedCategory;
@override
Widget build(BuildContext context) {
return BlocBuilder<UserBloc, UserState>(
builder: (context, state) {
if (state is UserLoggedIn) {
token = state.userData!.user!.login!.token;
profileId = state.userData!.user!.login!.user!.profileId.toString();
return BlocBuilder<ProfileBloc, ProfileState>(
builder: (context, state) {
if (state is ProfileLoaded) {
return BlocBuilder<ReferencesBloc, ReferencesState>(
builder: (context, state) {
if (state is AddReferenceState) {
return ProgressHUD(
return SingleChildScrollView(
child: SizedBox(
height: screenHeight * .95,
child: ProgressHUD(
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 25, horizontal: 18),
padding: const EdgeInsets.symmetric(vertical: 25, horizontal: 18),
child: FormBuilder(
key: formKey,
child: Column(
@ -77,10 +71,8 @@ class _AddReferenceScreenState extends State<AddReferenceScreen> {
decoration: normalTextFieldStyle(
"Last name *", "Last name *"),
name: "lastname",
validator:
FormBuilderValidators.required(
errorText:
"This field is required"),
validator: FormBuilderValidators.required(
errorText: "This field is required"),
),
),
const SizedBox(
@ -93,10 +85,8 @@ class _AddReferenceScreenState extends State<AddReferenceScreen> {
decoration: normalTextFieldStyle(
"First name *", "First name *"),
name: "firstname",
validator:
FormBuilderValidators.required(
errorText:
"This field is required"),
validator: FormBuilderValidators.required(
errorText: "This field is required"),
),
),
],
@ -112,10 +102,8 @@ class _AddReferenceScreenState extends State<AddReferenceScreen> {
decoration: normalTextFieldStyle(
"Middle name *", "Midlle name *"),
name: "middlename",
validator:
FormBuilderValidators.required(
errorText:
"This field is required"),
validator: FormBuilderValidators.required(
errorText: "This field is required"),
),
),
const SizedBox(
@ -124,20 +112,16 @@ class _AddReferenceScreenState extends State<AddReferenceScreen> {
////CATEGORY
Flexible(
flex: 1,
child: FormBuilderDropdown<
AddressCategory>(
child: FormBuilderDropdown<AddressCategory>(
name: 'category',
validator:
FormBuilderValidators.required(
errorText: ""),
decoration: normalTextFieldStyle(
"Category", "Category"),
items: state.categories.map<
DropdownMenuItem<
AddressCategory>>(
FormBuilderValidators.required(errorText: ""),
decoration:
normalTextFieldStyle("Category", "Category"),
items: state.categories
.map<DropdownMenuItem<AddressCategory>>(
(AddressCategory cat) {
return DropdownMenuItem<
AddressCategory>(
return DropdownMenuItem<AddressCategory>(
value: cat,
child: Text(cat.name!),
);
@ -181,34 +165,28 @@ class _AddReferenceScreenState extends State<AddReferenceScreen> {
////REGION DROPDOWN
FormBuilderDropdown<Region?>(
autovalidateMode:
AutovalidateMode
.onUserInteraction,
validator: FormBuilderValidators
.required(
errorText:
"This field is required"),
onChanged:
(Region? region) async {
AutovalidateMode.onUserInteraction,
validator: FormBuilderValidators.required(
errorText: "This field is required"),
onChanged: (Region? region) async {
if(selectedRegion != region){
setState(() {
provinceCall = true;
});
selectedRegion = region;
getProvinces();
}
},
initialValue: null,
decoration:
normalTextFieldStyle(
decoration: normalTextFieldStyle(
"Region*", "Region"),
name: 'region',
items: state.regions.map<
DropdownMenuItem<
Region>>(
items: state.regions
.map<DropdownMenuItem<Region>>(
(Region region) {
return DropdownMenuItem<
Region>(
return DropdownMenuItem<Region>(
value: region,
child: Text(
region.description!));
child: Text(region.description!));
}).toList(),
),
const SizedBox(
@ -220,47 +198,37 @@ class _AddReferenceScreenState extends State<AddReferenceScreen> {
child: ModalProgressHUD(
color: Colors.transparent,
inAsyncCall: provinceCall,
child: DropdownButtonFormField<
Province?>(
autovalidateMode:
AutovalidateMode
child: DropdownButtonFormField<Province?>(
autovalidateMode: AutovalidateMode
.onUserInteraction,
validator: (value) =>
value == null
? 'required'
: null,
value == null ? 'required' : null,
isExpanded: true,
value: selectedProvince,
onChanged:
(Province? province) {
onChanged: (Province? province) {
if(selectedProvince != province){
setState(() {
cityCall = true;
});
selectedProvince =
province;
selectedProvince = province;
getCities();
}
},
items: provinces == null
? []
: provinces!.map<
DropdownMenuItem<
Province>>(
(Province
province) {
(Province province) {
return DropdownMenuItem(
value:
province,
child:
FittedBox(
child: Text(
province
value: province,
child: FittedBox(
child: Text(province
.description!),
));
}).toList(),
decoration:
normalTextFieldStyle(
"Province*",
"Province")),
decoration: normalTextFieldStyle(
"Province*", "Province")),
),
),
////CITY MUNICIPALITY
@ -269,40 +237,35 @@ class _AddReferenceScreenState extends State<AddReferenceScreen> {
child: ModalProgressHUD(
color: Colors.white,
inAsyncCall: cityCall,
child:
DropdownButtonFormField<
child: DropdownButtonFormField<
CityMunicipality>(
validator: FormBuilderValidators
.required(
validator:
FormBuilderValidators.required(
errorText:
"This field is required"),
isExpanded: true,
onChanged:
(CityMunicipality?
city) {
onChanged: (CityMunicipality? city) {
if(selectedMunicipality != city){
setState(() {
barangayCall = true;
});
selectedMunicipality =
city;
selectedMunicipality = city;
getBarangays();
}
},
decoration:
normalTextFieldStyle(
"Municipality*",
"Municipality"),
decoration: normalTextFieldStyle(
"Municipality*", "Municipality"),
value: selectedMunicipality,
items: citymuns == null
? []
: citymuns!.map<
DropdownMenuItem<
CityMunicipality>>(
(CityMunicipality
c) {
(CityMunicipality c) {
return DropdownMenuItem(
value: c,
child: Text(c
.description!));
child:
Text(c.description!));
}).toList(),
),
),
@ -313,35 +276,24 @@ class _AddReferenceScreenState extends State<AddReferenceScreen> {
child: ModalProgressHUD(
color: Colors.white,
inAsyncCall: barangayCall,
child:
DropdownButtonFormField<
Barangay>(
validator: FormBuilderValidators
.required(
errorText:
"This field is required"),
child: DropdownButtonFormField<Barangay>(
isExpanded: true,
onChanged:
(Barangay? baragay) {
selectedBarangay =
baragay;
onChanged: (Barangay? baragay) {
selectedBarangay = baragay;
},
decoration:
normalTextFieldStyle(
"Barangay*",
"Barangay"),
decoration: normalTextFieldStyle(
"Barangay*", "Barangay"),
value: selectedBarangay,
items: barangays == null
? []
: barangays!.map<
DropdownMenuItem<
Barangay>>(
(Barangay
barangay) {
DropdownMenuItem<Barangay>>(
(Barangay barangay) {
return DropdownMenuItem(
value: barangay,
child: Text(barangay
.description!));
child: Text(
barangay.description!));
}).toList(),
),
),
@ -353,20 +305,15 @@ class _AddReferenceScreenState extends State<AddReferenceScreen> {
height: 60,
child: FormBuilderDropdown<Country>(
initialValue: null,
validator: FormBuilderValidators
.required(
errorText:
"This field is required"),
items: state.countries.map<
DropdownMenuItem<
Country>>(
validator: FormBuilderValidators.required(
errorText: "This field is required"),
items: state.countries
.map<DropdownMenuItem<Country>>(
(Country country) {
return DropdownMenuItem<
Country>(
return DropdownMenuItem<Country>(
value: country,
child: FittedBox(
child: Text(
country.name!)));
child: Text(country.name!)));
}).toList(),
name: 'country',
decoration: normalTextFieldStyle(
@ -392,47 +339,35 @@ class _AddReferenceScreenState extends State<AddReferenceScreen> {
width: double.infinity,
height: 60,
child: ElevatedButton(
style: mainBtnStyle(
primary, Colors.transparent, second),
style:
mainBtnStyle(primary, Colors.transparent, second),
child: const Text(submit),
onPressed: () {
PersonalReference? personalReference;
if (formKey.currentState!
.saveAndValidate()) {
String lastname = formKey
.currentState!.value['lastname'];
String firstname = formKey
.currentState!.value['firstname'];
String middlename = formKey
.currentState!
.value['middlename'];
String mobile = formKey
.currentState!.value['mobile'];
if (formKey.currentState!.saveAndValidate()) {
String lastname =
formKey.currentState!.value['lastname'];
String firstname =
formKey.currentState!.value['firstname'];
String middlename =
formKey.currentState!.value['middlename'];
String mobile =
formKey.currentState!.value['mobile'];
Region? region = selectedRegion;
Province? province = Province(
code: selectedProvince?.code,
description:
selectedProvince?.description,
description: selectedProvince?.description,
region: region,
psgcCode:
selectedProvince?.psgcCode,
shortname:
selectedProvince?.shortname);
CityMunicipality? city =
CityMunicipality(
code: selectedMunicipality
?.code,
psgcCode: selectedProvince?.psgcCode,
shortname: selectedProvince?.shortname);
CityMunicipality? city = CityMunicipality(
code: selectedMunicipality?.code,
description:
selectedMunicipality
?.description,
selectedMunicipality?.description,
province: province,
psgcCode: selectedMunicipality
?.psgcCode,
zipcode: selectedMunicipality
?.zipcode);
psgcCode: selectedMunicipality?.psgcCode,
zipcode: selectedMunicipality?.zipcode);
Address address = Address(
id: null,
@ -443,13 +378,11 @@ class _AddReferenceScreenState extends State<AddReferenceScreen> {
cityMunicipality: city);
if (selectedCountry != null) {
personalReference =
PersonalReference(
personalReference = PersonalReference(
id: null,
address: Address(
id: null,
addressCategory:
selectedCategory,
addressCategory: selectedCategory,
country: selectedCountry,
barangay: null,
cityMunicipality: null,
@ -459,8 +392,7 @@ class _AddReferenceScreenState extends State<AddReferenceScreen> {
firstName: firstname,
middleName: middlename);
} else {
personalReference =
PersonalReference(
personalReference = PersonalReference(
id: null,
address: address,
lastName: lastname,
@ -470,12 +402,10 @@ class _AddReferenceScreenState extends State<AddReferenceScreen> {
}
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
context.read<ReferencesBloc>().add(
AddReference(
profileId:
int.parse(profileId!),
context.read<ReferencesBloc>().add(AddReference(
profileId: widget.profileId,
reference: personalReference,
token: token!));
token: widget.token));
}
},
),
@ -486,14 +416,8 @@ progress!.showWithText("Please wait...");
],
)),
),
);
}
return Container();
},
);
}
return Container();
},
),
),
);
}
return Container();

View File

@ -4,9 +4,7 @@ import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
import '../../../../bloc/profile/profile_bloc.dart';
import '../../../../bloc/profile/references/references_bloc.dart';
import '../../../../bloc/user/user_bloc.dart';
import '../../../../model/location/address_category.dart';
import '../../../../model/location/barangay.dart';
import '../../../../model/location/city.dart';
@ -21,7 +19,9 @@ import '../../../../utils/location_utilities.dart';
import '../../../../utils/text_container.dart';
class EditReferenceScreen extends StatefulWidget {
const EditReferenceScreen({super.key});
final String token;
final int profileId;
const EditReferenceScreen({super.key,required this.profileId, required this.token});
@override
State<EditReferenceScreen> createState() => _EditReferenceScreenState();
@ -29,8 +29,6 @@ class EditReferenceScreen extends StatefulWidget {
class _EditReferenceScreenState extends State<EditReferenceScreen> {
final formKey = GlobalKey<FormBuilderState>();
String? token;
String? profileId;
bool provinceCall = false;
bool cityCall = false;
bool barangayCall = false;
@ -48,14 +46,7 @@ class _EditReferenceScreenState extends State<EditReferenceScreen> {
@override
Widget build(BuildContext context) {
return BlocBuilder<UserBloc, UserState>(
builder: (context, state) {
if (state is UserLoggedIn) {
token = state.userData!.user!.login!.token;
profileId = state.userData!.user!.login!.user!.profileId.toString();
return BlocBuilder<ProfileBloc, ProfileState>(
builder: (context, state) {
if (state is ProfileLoaded) {
return BlocBuilder<ReferencesBloc, ReferencesState>(
buildWhen: (previous, current) => false,
builder: (context, state) {
@ -525,6 +516,10 @@ class _EditReferenceScreenState extends State<EditReferenceScreen> {
PersonalReference? personalReference;
if (formKey.currentState!
.saveAndValidate()) {
final progress =
ProgressHUD.of(context);
progress!.showWithText(
"Please wait...");
String lastname = formKey
.currentState!.value['lastname'];
String firstname = formKey
@ -607,9 +602,9 @@ class _EditReferenceScreenState extends State<EditReferenceScreen> {
context.read<ReferencesBloc>().add(
EditReference(
profileId:
int.parse(profileId!),
widget.profileId,
reference: personalReference,
token: token!));
token: widget.token));
}
},
),
@ -624,14 +619,7 @@ class _EditReferenceScreenState extends State<EditReferenceScreen> {
}
return Container();
},
);
}
return Container();
},
);
}
return Container();
},
);
}
}

View File

@ -26,25 +26,37 @@ class ReferencesScreen extends StatelessWidget {
int? profileId;
String? token;
return Scaffold(
resizeToAvoidBottomInset: true,
appBar: AppBar(
title: context.watch<ReferencesBloc>().state is AddReferenceState?const Text("Add Personal Reference"):context.watch<ReferencesBloc>().state is EditReferenceState?const Text("Edit Personal Reference"):const Text("Personal References"),
title: context.watch<ReferencesBloc>().state is AddReferenceState
? const Text("Add Personal Reference")
: context.watch<ReferencesBloc>().state is EditReferenceState
? const Text("Edit Personal Reference")
: const Text("Personal References"),
centerTitle: true,
backgroundColor: primary,
////if state is adding or editing state show close button
actions: (context.watch<ReferencesBloc>().state is AddReferenceState || context.watch<ReferencesBloc>().state is EditReferenceState)?
[
actions: (context.watch<ReferencesBloc>().state
is AddReferenceState ||
context.watch<ReferencesBloc>().state is EditReferenceState)
? [
//// close button
CloseLeading(onPressed: () {
context.read<ReferencesBloc>().add(GetReferences(profileId: profileId!, token: token!));
context.read<ReferencesBloc>().add(
GetReferences(profileId: profileId!, token: token!));
}),
]:
]
:
//// if state is loaded state show add button
context.watch<ReferencesBloc>().state is ReferencesLoadedState?[
context.watch<ReferencesBloc>().state is ReferencesLoadedState
? [
AddLeading(onPressed: () {
context.read<ReferencesBloc>().add(ShowAddReferenceForm());
context
.read<ReferencesBloc>()
.add(ShowAddReferenceForm());
}),
]:[]
),
]
: []),
body: ProgressHUD(
padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87,
@ -83,7 +95,7 @@ class ReferencesScreen extends StatelessWidget {
Navigator.of(context).pop();
context.read<ReferencesBloc>().add(
LoadReferences(
references: state.personalRefs));
));
});
} else {
errorAlert(context, "Adding Failed",
@ -92,7 +104,7 @@ class ReferencesScreen extends StatelessWidget {
Navigator.of(context).pop();
context.read<ReferencesBloc>().add(
LoadReferences(
references: state.personalRefs));
));
});
}
}
@ -104,7 +116,7 @@ class ReferencesScreen extends StatelessWidget {
Navigator.of(context).pop();
context.read<ReferencesBloc>().add(
LoadReferences(
references: state.personalRefs));
));
});
} else {
errorAlert(context, "Update Failed",
@ -113,7 +125,7 @@ class ReferencesScreen extends StatelessWidget {
Navigator.of(context).pop();
context.read<ReferencesBloc>().add(
LoadReferences(
references: state.personalRefs));
));
});
}
}
@ -127,7 +139,7 @@ class ReferencesScreen extends StatelessWidget {
Navigator.of(context).pop();
context.read<ReferencesBloc>().add(
LoadReferences(
references: state.references));
));
});
} else {
errorAlert(context, "Deletion Failed",
@ -135,7 +147,7 @@ class ReferencesScreen extends StatelessWidget {
Navigator.of(context).pop();
context.read<ReferencesBloc>().add(
LoadReferences(
references: state.references));
));
});
}
}
@ -212,12 +224,14 @@ class ReferencesScreen extends StatelessWidget {
offset: const Offset(-10, -10),
elevation: 3,
onSelected: (value) {
////delete eligibilty-= = = = = = = = =>>
if (value == 2) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
confirmAlert(context, () {
final progress =
ProgressHUD.of(context);
progress!.showWithText(
"Please wait...");
context
.read<
ReferencesBloc>()
@ -236,6 +250,10 @@ progress!.showWithText("Please wait...");
}
if (value == 1) {
////edit reference-= = = = = = = = =>>
final progress =
ProgressHUD.of(context);
progress!.showWithText(
"Please wait...");
context
.read<ReferencesBloc>()
.add(ShowEditReferenceForm(
@ -276,14 +294,16 @@ progress!.showWithText("Please wait...");
}
}
if (state is AddReferenceState) {
return const AddReferenceScreen();
return AddReferenceScreen(profileId: profileId!, token: token!,);
}
if (state is EditReferenceState) {
return const EditReferenceScreen();
return EditReferenceScreen(profileId: profileId!,token: token!,);
}
if (state is ReferencesErrorState) {
return SomethingWentWrong(
message: state.message, onpressed: () {});
message: state.message, onpressed: () {
context.read<ReferencesBloc>().add(GetReferences(profileId: profileId!, token: token!));
});
}
return Container();
},

View File

@ -24,7 +24,9 @@ import 'package:unit2/utils/validators.dart';
import '../../../../model/utils/position.dart';
class AddWorkHistoryScreen extends StatefulWidget {
const AddWorkHistoryScreen({super.key});
final int profileId;
final String token;
const AddWorkHistoryScreen({super.key, required this.profileId, required this.token});
@override
State<AddWorkHistoryScreen> createState() => _AddWorkHistoryScreenState();
@ -65,14 +67,7 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
@override
Widget build(BuildContext context) {
return BlocBuilder<UserBloc, UserState>(
builder: (context, state) {
if (state is UserLoggedIn) {
profileId = state.userData!.user!.login!.user!.profileId;
token = state.userData!.user!.login!.token;
return BlocBuilder<ProfileBloc, ProfileState>(
builder: (context, state) {
if (state is ProfileLoaded) {
return BlocConsumer<WorkHistoryBloc, WorkHistoryState>(
listener: (context, state) {
if (state is AddWorkHistoryState) {
@ -121,6 +116,7 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
positionFocusNode.unfocus();
});
},
////EMPTY WIDGET
emptyWidget: Container(
decoration: box1(),
height: 100,
@ -139,6 +135,7 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
),
TextButton(
onPressed: () {
////ADD POSITION DIALOG
showDialog(
context: context,
builder: (BuildContext
@ -638,12 +635,7 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
Flexible(
flex: 1,
child: DateTimePicker(
validator: (value) {
if (value == null) {
return "This field is required";
}
return null;
},
validator: FormBuilderValidators.required(errorText: "This field is required"),
use24HourFormat: false,
icon: const Icon(
Icons.date_range),
@ -684,9 +676,7 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
.copyWith(),
)
: DateTimePicker(
validator: (val) {
return null;
},
validator: FormBuilderValidators.required(errorText: "This field is required"),
controller:
toDateController,
firstDate: DateTime(1970),
@ -723,17 +713,12 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
style: mainBtnStyle(
primary, Colors.transparent, second),
onPressed: () {
print(selectedPosition?.title);
print(selectedStatus?.label);
print(selectedAgency?.name);
print(salary);
print(fromDateController.text);
print(toDateController.text);
print(salaryGrade);
print(salaryGradeStep);
print(isPrivate);
if (_formKey.currentState!.validate()) {
final progress =
ProgressHUD.of(context);
progress!.showWithText(
"Loading...");
WorkHistory workHistory = WorkHistory(
position: selectedPosition,
id: null,
@ -783,14 +768,4 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
return Container();
});
}
return Container();
},
);
}
return const Center(
child: Text("Add Work History"),
);
},
);
}
}

View File

@ -23,7 +23,10 @@ import '../../../../utils/text_container.dart';
import '../../../../utils/validators.dart';
class EditWorkHistoryScreen extends StatefulWidget {
const EditWorkHistoryScreen({super.key});
final int profileId;
final String token;
const EditWorkHistoryScreen(
{super.key, required this.profileId, required this.token});
@override
State<EditWorkHistoryScreen> createState() => _EditWorkHistoryScreenState();
@ -73,36 +76,20 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
@override
Widget build(BuildContext context) {
return BlocBuilder<UserBloc, UserState>(
return BlocBuilder<UserBloc, UserState>(builder: (context, state) {
return BlocBuilder<WorkHistoryBloc, WorkHistoryState>(
builder: (context, state) {
if (state is UserLoggedIn) {
profileId = state.userData!.user!.login!.user!.profileId;
token = state.userData!.user!.login!.token;
return BlocBuilder<ProfileBloc, ProfileState>(
builder: (context, state) {
if (state is ProfileLoaded) {
return BlocConsumer<WorkHistoryBloc, WorkHistoryState>(
listener: (context, state) {
if (state is AddWorkHistoryState) {
final progress = ProgressHUD.of(context);
progress!.dismiss();
}
}, builder: (context, state) {
if (state is EditWorkHistoryState) {
oldPositionController.text =
state.workHistory.position!.title!;
oldPositionController.text = state.workHistory.position!.title!;
oldAppointmentStatusController.text =
state.workHistory.appointmentStatus!;
oldAgencyController.text = state.workHistory.agency!.name!;
currentlyEmployed =
state.workHistory.toDate == null ? true : false;
currentlyEmployed = state.workHistory.toDate == null ? true : false;
showSalaryGradeAndSalaryStep =
!state.workHistory.agency!.privateEntity!;
fromDateController.text =
state.workHistory.fromDate.toString();
fromDateController.text = state.workHistory.fromDate.toString();
toDateController.text = state.workHistory.toDate.toString();
currentlyEmployed =
state.workHistory.toDate == null ? true : false;
currentlyEmployed = state.workHistory.toDate == null ? true : false;
return SingleChildScrollView(
child: SizedBox(
@ -121,24 +108,21 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
itemHeight: 50,
suggestionsDecoration: box1(),
suggestions: state.agencyPositions
.map((Position position) =>
SearchFieldListItem(position.title!,
.map((Position position) => SearchFieldListItem(
position.title!,
item: position,
child: Padding(
padding: const EdgeInsets
.symmetric(
padding: const EdgeInsets.symmetric(
horizontal: 10),
child: ListTile(
title:
Text(position.title!),
title: Text(position.title!),
))))
.toList(),
focusNode: positionFocusNode,
searchInputDecoration:
normalTextFieldStyle("Position *", "")
.copyWith(
suffixIcon: const Icon(
Icons.arrow_drop_down)),
normalTextFieldStyle("Position *", "").copyWith(
suffixIcon:
const Icon(Icons.arrow_drop_down)),
onSuggestionTap: (position) {
setState(() {
selectedPosition = position.item;
@ -149,10 +133,8 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
decoration: box1(),
height: 100,
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(
height: 20,
@ -165,8 +147,7 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
onPressed: () {
showDialog(
context: context,
builder: (BuildContext
context) {
builder: (BuildContext context) {
return AlertDialog(
title: const Text(
"Add Position?"),
@ -179,42 +160,51 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
addPositionController,
decoration:
normalTextFieldStyle(
"",
""),
"", ""),
),
const SizedBox(
height: 12,
),
SizedBox(
width: double
.infinity,
width:
double.infinity,
height: 50,
child: ElevatedButton(
style: mainBtnStyle(primary, Colors.transparent, second),
onPressed: () {
child:
ElevatedButton(
style: mainBtnStyle(
primary,
Colors
.transparent,
second),
onPressed:
() {
setState(
() {
Position
newAgencyPosition =
Position(id: null, title: addPositionController.text.toUpperCase());
state.agencyPositions.insert(0,
Position(
id: null,
title: addPositionController.text.toUpperCase());
state.agencyPositions.insert(
0,
newAgencyPosition);
selectedPosition =
newAgencyPosition;
addPositionController.text =
"";
Navigator.pop(context);
Navigator.pop(
context);
});
},
child: const Text("Add"))),
child: const Text(
"Add"))),
],
),
),
);
});
},
child:
const Text("Add position"))
child: const Text("Add position"))
]),
),
validator: (position) {
@ -247,11 +237,11 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
selectedStatus = status.item;
appointmentStatusNode.unfocus();
},
searchInputDecoration: normalTextFieldStyle(
"Appointment Status", "")
searchInputDecoration:
normalTextFieldStyle("Appointment Status", "")
.copyWith(
suffixIcon: const Icon(
Icons.arrow_drop_down)),
suffixIcon:
const Icon(Icons.arrow_drop_down)),
),
const SizedBox(
@ -268,45 +258,38 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
focusNode: agencyFocusNode,
suggestions: state.agencies
.map((Agency agency) =>
SearchFieldListItem(
agency.name!,
SearchFieldListItem(agency.name!,
item: agency,
child: ListTile(
title: Text(
agency.name!,
overflow: TextOverflow
.ellipsis,
overflow: TextOverflow.ellipsis,
),
subtitle: Text(
agency.privateEntity ==
true
agency.privateEntity == true
? "Private"
: "Government"),
)))
.toList(),
searchInputDecoration:
normalTextFieldStyle("Agency *", "")
searchInputDecoration: normalTextFieldStyle(
"Agency *", "")
.copyWith(
suffixIcon: const Icon(
Icons.arrow_drop_down)),
suffixIcon:
const Icon(Icons.arrow_drop_down)),
onSuggestionTap: (agency) {
setState(() {
selectedAgency = agency.item;
if (selectedAgency!.privateEntity ==
null) {
if (selectedAgency!.privateEntity == null) {
showIsPrivateRadio = true;
} else {
showIsPrivateRadio = false;
}
if (selectedAgency!.privateEntity ==
true) {
showSalaryGradeAndSalaryStep =
false;
if (selectedAgency!.privateEntity == true) {
showSalaryGradeAndSalaryStep = false;
}
if (selectedAgency!.privateEntity ==
false) {
showSalaryGradeAndSalaryStep =
true;
showSalaryGradeAndSalaryStep = true;
}
agencyFocusNode.unfocus();
});
@ -337,8 +320,8 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
onPressed: () {
showDialog(
context: context,
builder: (BuildContext
context) {
builder:
(BuildContext context) {
return AlertDialog(
title: const Text(
"Add Position"),
@ -351,42 +334,55 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
addAgencyController,
decoration:
normalTextFieldStyle(
"",
""),
"", ""),
),
const SizedBox(
height:
12,
height: 12,
),
SizedBox(
width: double
.infinity,
height:
50,
child: ElevatedButton(
style: mainBtnStyle(primary, Colors.transparent, second),
onPressed: () {
setState(() {
Agency newAgency = Agency(id: null, name: addAgencyController.text.toUpperCase(), category: null, privateEntity: null);
state.agencies.insert(0, newAgency);
selectedAgency = newAgency;
addAgencyController.text = "";
showAgencyCategory = true;
height: 50,
child:
ElevatedButton(
style: mainBtnStyle(
primary,
Colors
.transparent,
second),
onPressed:
() {
setState(
() {
Agency newAgency = Agency(
id: null,
name: addAgencyController.text.toUpperCase(),
category: null,
privateEntity: null);
state.agencies.insert(0,
newAgency);
selectedAgency =
newAgency;
addAgencyController.text =
"";
showAgencyCategory =
true;
showIsPrivateRadio = true;
showIsPrivateRadio =
true;
Navigator.pop(context);
});
},
child: const Text("Add"))),
child: const Text(
"Add"))),
],
),
),
);
});
},
child: const Text(
"Add Agency"))
child: const Text("Add Agency"))
]),
),
),
@ -398,21 +394,17 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
SizedBox(
child: showAgencyCategory
? SearchField(
focusNode:
agencyCategoryFocusNode,
focusNode: agencyCategoryFocusNode,
itemHeight: 70,
suggestions: state
.agencyCategory
suggestions: state.agencyCategory
.map((Category category) =>
SearchFieldListItem(
category.name!,
item: category,
child: ListTile(
title: Text(
category
.name!),
subtitle: Text(
category
title:
Text(category.name!),
subtitle: Text(category
.industryClass!
.name!),
)))
@ -421,20 +413,17 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
height: 100,
decoration: box1(),
child: const Center(
child: Text(
"No result found ...")),
child:
Text("No result found ...")),
),
onSuggestionTap:
(agencyCategory) {
onSuggestionTap: (agencyCategory) {
setState(() {
selectedAgencyCategory =
agencyCategory.item;
agencyCategoryFocusNode
.unfocus();
agencyCategoryFocusNode.unfocus();
selectedAgency = Agency(
id: null,
name: selectedAgency!
.name,
name: selectedAgency!.name,
category:
selectedAgencyCategory,
privateEntity: null);
@ -444,9 +433,8 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
normalTextFieldStyle(
"Category *", "")
.copyWith(
suffixIcon:
const Icon(Icons
.arrow_drop_down)),
suffixIcon: const Icon(
Icons.arrow_drop_down)),
validator: (value) {
if (value!.isEmpty) {
return "This field is required";
@ -467,15 +455,13 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
children: [
Text(
"Is this private sector? ",
style: Theme.of(
context)
style: Theme.of(context)
.textTheme
.headlineSmall!
.copyWith(
fontSize: 24),
.copyWith(fontSize: 24),
),
const Icon(FontAwesome
.help_circled)
const Icon(
FontAwesome.help_circled)
],
),
),
@ -483,8 +469,7 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
////onvhange private sector
onChanged: (value) {
setState(() {
if (value.toString() ==
"YES") {
if (value.toString() == "YES") {
isPrivate = true;
showSalaryGradeAndSalaryStep =
false;
@ -495,24 +480,20 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
}
selectedAgency = Agency(
id: null,
name: selectedAgency!
.name,
name: selectedAgency!.name,
category:
selectedAgencyCategory,
privateEntity:
value == "YES"
privateEntity: value == "YES"
? true
: false);
agencyFocusNode.unfocus();
agencyCategoryFocusNode
.unfocus();
agencyCategoryFocusNode.unfocus();
});
},
name: 'isPrivate',
validator:
FormBuilderValidators
.required(),
FormBuilderValidators.required(),
options: ["YES", "NO"]
.map((lang) =>
FormBuilderFieldOption(
@ -521,9 +502,7 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
)
: const SizedBox()),
SizedBox(
height: showSalaryGradeAndSalaryStep
? 12
: 0,
height: showSalaryGradeAndSalaryStep ? 12 : 0,
),
////SALARY GRADE AND SALARY GRADE STEP
SizedBox(
@ -535,17 +514,13 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
////SALARY GRADE
Flexible(
flex: 1,
child:
FormBuilderTextField(
child: FormBuilderTextField(
initialValue: state
.workHistory
.salaryGrade
.workHistory.salaryGrade
?.toString(),
name:
'salary_grade',
name: 'salary_grade',
keyboardType:
TextInputType
.number,
TextInputType.number,
decoration:
normalTextFieldStyle(
"Salary Grade (SG)",
@ -563,16 +538,13 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
//// SALARY STEP
Flexible(
flex: 1,
child:
FormBuilderTextField(
child: FormBuilderTextField(
initialValue: state
.workHistory
.sgStep
.workHistory.sgStep
?.toString(),
name: 'salary_step',
keyboardType:
TextInputType
.number,
TextInputType.number,
decoration:
normalTextFieldStyle(
"SG Step (SG)",
@ -597,8 +569,8 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
),
////MONTHLY SALARY
FormBuilderTextField(
initialValue: state.workHistory.monthlySalary
.toString(),
initialValue:
state.workHistory.monthlySalary.toString(),
onChanged: (value) {
setState(() {
salary = value;
@ -606,8 +578,8 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
},
validator: numericRequired,
name: "salary",
decoration: normalTextFieldStyle(
"Monthly Salary *", "")
decoration:
normalTextFieldStyle("Monthly Salary *", "")
.copyWith(prefix: const Text("")),
),
@ -632,11 +604,9 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
}
});
},
decoration:
normalTextFieldStyle("", ''),
decoration: normalTextFieldStyle("", ''),
name: 'overseas',
title:
const Text("Currently Employed?"),
title: const Text("Currently Employed?"),
),
const SizedBox(
height: 12,
@ -649,28 +619,21 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
Flexible(
flex: 1,
child: DateTimePicker(
validator: (value) {
if (value == null) {
return "This field is required";
}
return null;
},
validator:
FormBuilderValidators.required(
errorText:
"This field is required"),
use24HourFormat: false,
icon: const Icon(
Icons.date_range),
controller:
fromDateController,
icon: const Icon(Icons.date_range),
controller: fromDateController,
firstDate: DateTime(1970),
lastDate: DateTime(2100),
timeHintText:
"Date of Examination/Conferment",
decoration:
normalTextFieldStyle(
"From *",
"From *")
decoration: normalTextFieldStyle(
"From *", "From *")
.copyWith(
prefixIcon:
const Icon(
prefixIcon: const Icon(
Icons.date_range,
color: Colors.black87,
)),
@ -687,35 +650,29 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
enabled: false,
initialValue: "PRESENT",
style: const TextStyle(
color:
Colors.black45),
decoration:
normalTextFieldStyle(
color: Colors.black45),
decoration: normalTextFieldStyle(
"", "")
.copyWith(
prefixIcon:
const Icon(
prefixIcon: const Icon(
Icons.date_range,
color: Colors.black45,
)),
)
: DateTimePicker(
validator: (val) {
return null;
},
controller:
toDateController,
validator: FormBuilderValidators
.required(
errorText:
"This field is required"),
controller: toDateController,
firstDate: DateTime(1970),
lastDate: DateTime(2100),
decoration: normalTextFieldStyle(
"To *", "To *")
.copyWith(
prefixIcon:
const Icon(
Icons
.date_range,
color: Colors
.black87,
prefixIcon: const Icon(
Icons.date_range,
color: Colors.black87,
),
prefixText:
currentlyEmployed
@ -739,37 +696,33 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
style: mainBtnStyle(
primary, Colors.transparent, second),
onPressed: () {
if (_formKey.currentState!
.saveAndValidate()) {
salary = _formKey
.currentState!.value['salary'];
if (_formKey.currentState!.saveAndValidate()) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Loading...");
salary =
_formKey.currentState!.value['salary'];
selectedPosition ??=
state.workHistory.position;
salaryGrade = _formKey.currentState!
.value['salary_grade'];
salaryGrade = _formKey
.currentState!.value['salary_grade'];
salaryGradeStep = _formKey
.currentState!
.value['salary_step'];
selectedAgency ??=
state.workHistory.agency;
.currentState!.value['salary_step'];
selectedAgency ??= state.workHistory.agency;
selectedStatus ??= AppoinemtStatus(
value: state.workHistory
.appointmentStatus!,
label: state.workHistory
.appointmentStatus!);
WorkHistory newWorkHistory =
WorkHistory(
value:
state.workHistory.appointmentStatus!,
label:
state.workHistory.appointmentStatus!);
WorkHistory newWorkHistory = WorkHistory(
id: state.workHistory.id,
position: selectedPosition,
agency: selectedAgency,
fromDate: fromDateController
.text.isEmpty
fromDate: fromDateController.text.isEmpty
? null
: DateTime.parse(
fromDateController.text),
toDate: toDateController
.text.isEmpty ||
toDate: toDateController.text.isEmpty ||
toDateController.text
.toUpperCase() ==
"PRESENT" ||
@ -777,12 +730,9 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
.toLowerCase() ==
'null'
? null
: DateTime.parse(
toDateController.text),
monthlySalary:
double.parse(salary!),
appointmentStatus:
selectedStatus!.value,
: DateTime.parse(toDateController.text),
monthlySalary: double.parse(salary!),
appointmentStatus: selectedStatus!.value,
salaryGrade: salaryGrade == null
? null
: int.parse(salaryGrade!),
@ -792,10 +742,8 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
);
context.read<WorkHistoryBloc>().add(
UpdateWorkHistory(
oldWorkHistory:
state.workHistory,
profileId:
profileId.toString(),
oldWorkHistory: state.workHistory,
profileId: profileId.toString(),
token: token!,
workHistory: newWorkHistory));
}
@ -812,17 +760,11 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
),
);
}
return Container();
});
}
return Container();
},
);
}
return const Center(
child: Text("Add Work History"),
);
},
);
});
}
}

View File

@ -1,5 +1,4 @@
import 'dart:io';
import 'package:app_popup_menu/app_popup_menu.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@ -15,6 +14,7 @@ import 'package:unit2/theme-data.dart/box_shadow.dart';
import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/Leadings/add_leading.dart';
import 'package:unit2/widgets/Leadings/close_leading.dart';
import 'package:unit2/widgets/empty_data.dart';
import 'package:unit2/widgets/error_state.dart';
@ -36,11 +36,15 @@ class WorkHistoryScreen extends StatelessWidget {
title: const Text(workHistoryScreenTitle),
backgroundColor: primary,
centerTitle: true,
actions: [
actions: context.watch<WorkHistoryBloc>().state is WorkHistoryLoaded?[
AddLeading(onPressed: () {
context.read<WorkHistoryBloc>().add(ShowAddWorkHistoryForm());
})
],
]:(context.watch<WorkHistoryBloc>().state is AddWorkHistoryState || context.watch<WorkHistoryBloc>().state is EditWorkHistoryState)?[
CloseLeading(onPressed: (){
context.read<WorkHistoryBloc>().add(LoadWorkHistories());
})
]:[],
),
body:
//UserBloc
@ -68,7 +72,9 @@ class WorkHistoryScreen extends StatelessWidget {
}
if (state is WorkHistoryLoaded ||
state is WorkHistoryErrorState ||
state is AddWorkHistoryState ||state is WorkHistoryAddedState || state is EditWorkHistoryState) {
state is AddWorkHistoryState ||
state is WorkHistoryAddedState ||
state is EditWorkHistoryState) {
final progress = ProgressHUD.of(context);
progress!.dismiss();
}
@ -78,17 +84,17 @@ class WorkHistoryScreen extends StatelessWidget {
successAlert(context, "Deletion Successfull",
"Work has been deleted successfully", () {
Navigator.of(context).pop();
context.read<WorkHistoryBloc>().add(
LoadWorkHistories(
workHistories: state.workHistories));
context
.read<WorkHistoryBloc>()
.add(LoadWorkHistories());
});
} else {
errorAlert(context, "Deletion Failed",
"Error deleting Work History", () {
Navigator.of(context).pop();
context.read<WorkHistoryBloc>().add(
LoadWorkHistories(
workHistories: state.workHistories));
context
.read<WorkHistoryBloc>()
.add(LoadWorkHistories());
});
}
}
@ -98,16 +104,18 @@ class WorkHistoryScreen extends StatelessWidget {
successAlert(context, "Adding Successfull!",
state.response['message'], () {
Navigator.of(context).pop();
context.read<WorkHistoryBloc>().add(LoadWorkHistories(
workHistories: state.workExperiences));
context
.read<WorkHistoryBloc>()
.add(LoadWorkHistories());
});
} else {
errorAlert(context, "Adding Failed",
"Something went wrong. Please try again.",
() {
Navigator.of(context).pop();
context.read<WorkHistoryBloc>().add(LoadWorkHistories(
workHistories: state.workExperiences));
context
.read<WorkHistoryBloc>()
.add(LoadWorkHistories());
});
}
}
@ -117,16 +125,18 @@ class WorkHistoryScreen extends StatelessWidget {
successAlert(context, "Update Successfull!",
state.response['message'], () {
Navigator.of(context).pop();
context.read<WorkHistoryBloc>().add(LoadWorkHistories(
workHistories: state.workExperiences));
context
.read<WorkHistoryBloc>()
.add(LoadWorkHistories());
});
} else {
errorAlert(context, "Update Failed",
"Something went wrong. Please try again.",
() {
Navigator.of(context).pop();
context.read<WorkHistoryBloc>().add(LoadWorkHistories(
workHistories: state.workExperiences));
context
.read<WorkHistoryBloc>()
.add(LoadWorkHistories());
});
}
}
@ -207,31 +217,41 @@ class WorkHistoryScreen extends StatelessWidget {
offset: const Offset(-10, -10),
elevation: 3,
onSelected: (value) {
final progress =
ProgressHUD.of(context);
progress!
.showWithText("Loading...");
////delete workhistory-= = = = = = = = =>>
if (value == 2) {
confirmAlert(context, () {
BlocProvider.of<WorkHistoryBloc>(
final progress =
ProgressHUD.of(context);
progress!.showWithText(
"Loading...");
BlocProvider.of<
WorkHistoryBloc>(
context)
.add(DeleteWorkHistory(
profileId:
profileId,
profileId: profileId,
token: token!,
workHistory: state
.workExperiences[
workHistory:
state.workExperiences[
index],
workHistories: state
.workExperiences));
));
}, "Delete?",
"Confirm Delete?");
}
if (value == 1) {
////edit eligibilty-= = = = = = = = =>>
WorkHistory workHistory = state.workExperiences[index];
context.read<WorkHistoryBloc>().add(ShowEditWorkHistoryForm(workHistory: workHistory));
final progress =
ProgressHUD.of(context);
progress!.showWithText(
"Loading...");
WorkHistory workHistory =
state.workExperiences[
index];
context
.read<WorkHistoryBloc>()
.add(
ShowEditWorkHistoryForm(
workHistory:
workHistory));
}
},
menuItems: [
@ -269,14 +289,16 @@ class WorkHistoryScreen extends StatelessWidget {
}
}
if (state is AddWorkHistoryState) {
return const AddWorkHistoryScreen();
return AddWorkHistoryScreen(profileId: profileId, token: token!,);
}
if (state is EditWorkHistoryState) {
return const EditWorkHistoryScreen();
return EditWorkHistoryScreen(profileId: profileId,token: token!,);
}
if (state is WorkHistoryErrorState) {
return SomethingWentWrong(
message: state.message, onpressed: () {});
message: state.message, onpressed: () {
context.read<WorkHistoryBloc>().add(GetWorkHistories(profileId: profileId,token: token!));
});
}
return Container();
},

View File

@ -10,7 +10,8 @@ class CoverImage extends StatelessWidget {
color: Colors.grey,
child: CachedNetworkImage(
imageUrl:
'https://static.vecteezy.com/system/resources/thumbnails/008/074/253/small/tropical-forest-sunset-nature-background-with-coconut-trees-vector.jpg',
"https://live.staticflickr.com/7320/9052838885_af9b21c79b_b.jpg",
// 'https://static.vecteezy.com/system/resources/thumbnails/008/074/253/small/tropical-forest-sunset-nature-background-with-coconut-trees-vector.jpg',
width: double.infinity,
height: 220,
fit: BoxFit.cover,

View File

@ -21,12 +21,15 @@ Widget getTile(
if (title.toLowerCase() == "logout") {
confirmAlert(context, () async{
await CREDENTIALS!.clear();
await CREDENTIALS!.deleteAll(['username','password','saved']);
Navigator.pushReplacementNamed (context,"/");
},"Logout","Are You sure you want to logout?");
}if(title.toLowerCase() == 'profile'){
ProfileArguments profileArguments = ProfileArguments(token: userData.user!.login!.token!, userID:userData.user!.login!.user!.profileId!);
Navigator.pushNamed(context, route,arguments: profileArguments);
}if(title.toLowerCase() == 'basic info'){
Navigator.pushNamed(context, '/basic-info');
}
},

View File

@ -36,6 +36,7 @@ class _UniT2LoginState extends State<UniT2Login> {
bool showSuffixIcon = false;
bool _showPassword = true;
String? password;
String? username;
@override
Widget build(BuildContext context) {
return WillPopScope(
@ -236,7 +237,7 @@ class _UniT2LoginState extends State<UniT2Login> {
TextStyle(color: Colors.white),
),
onPressed: () {
password = "nav071394";
final progress =
ProgressHUD.of(context);
@ -244,20 +245,21 @@ class _UniT2LoginState extends State<UniT2Login> {
if (_formKey.currentState!
.saveAndValidate()) {
password = _formKey
.currentState!
.value['password'];
username = _formKey
.currentState!
.value['username'];
progress?.showWithText(
'Logging in...',
);
BlocProvider.of<UserBloc>(context)
.add(UserLogin(
username: "rjvincentlopeplopez",
password: "shesthequ33n",
// username: _formKey
// .currentState!
// .value['username'],
// password: _formKey
// .currentState!
// .value['password'])
username:username,
password: password
));
}
},

View File

@ -9,11 +9,11 @@ class ContactService {
static final ContactService _instance = ContactService();
static ContactService get instance => _instance;
Future<List<ServiceProvider>> getServiceProvider(
Future<List<CommService>> getServiceProvider(
{required int serviceTypeId}) async {
String path = Url.instance.getServiceType();
String path = Url.instance.getCommunicationProvider();
Map<String, String> params = {"service_type__id": serviceTypeId.toString()};
List<ServiceProvider> serviceProviders = [];
List<CommService> serviceProviders = [];
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
};
@ -25,7 +25,7 @@ class ContactService {
if (data['data'] != null) {
for (var element in data['data']) {
CommService commService = CommService.fromJson(element);
serviceProviders.add(commService.serviceProvider!);
serviceProviders.add(commService);
}
}
}
@ -52,7 +52,7 @@ class ContactService {
"_numbermail": contactInfo.numbermail,
"_active": contactInfo.active,
"_primary": contactInfo.primary,
"_commServiceId": contactInfo.commService!.serviceProvider!.id!
"_commServiceId": contactInfo.commService!.id
};
Map<dynamic, dynamic> responseStatus = {};
try {
@ -71,24 +71,38 @@ class ContactService {
}
//// add
// Future<Map<dynamic, dynamic>> update(
// {required int profileId,
// required String token,
// required ContactInfo contactInfo}) async {
// String path = "${Url.instance.contactPath()}$profileId/";
// String authToken = "Token $token";
// Map<String, String> headers = {
// 'Content-Type': 'application/json; charset=UTF-8',
// 'Authorization': authToken
// };
// Map body ={
// "personid": profileId,
// "_numbermail": contactInfo.numbermail,
// "_active": contactInfo.active,
// "_primary": contactInfo.primary,
// "_commServiceId": contactInfo
// }
// }
Future<Map<dynamic, dynamic>> add(
{required int profileId,
required String token,
required ContactInfo contactInfo}) async {
String path = "${Url.instance.contactPath()}$profileId/";
String authToken = "Token $token";
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': authToken
};
Map<dynamic, dynamic> responseStatus = {};
Map body = {
"personid": profileId,
"_numbermail": contactInfo.numbermail,
"_active": contactInfo.active,
"_primary": contactInfo.primary,
"_commServiceId": contactInfo.commService!.id
};
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});
}
return responseStatus;
} catch (e) {
throw e.toString();
}
}
////delete
Future<bool> deleteContact(
@ -116,7 +130,7 @@ class ContactService {
try {
http.Response response = await Request.instance.deleteRequest(
path: path, headers: headers, body: body, param: params);
if (response.statusCode == 20) {
if (response.statusCode == 200) {
Map data = jsonDecode(response.body);
success = data['success'];
}

View File

@ -4,10 +4,10 @@ class Url {
String host() {
// return '192.168.10.221:3003';
// return 'agusandelnorte.gov.ph';
return 'agusandelnorte.gov.ph';
// return "192.168.10.219:3000";
// return "devweb.agusandelnorte.gov.ph";
return 'devapi.agusandelnorte.gov.ph:3004';
// return 'devapi.agusandelnorte.gov.ph:3004';
}
String authentication() {
@ -111,7 +111,7 @@ String getServiceTypes(){
String contactPath(){
return "/api/jobnet_app/profile/pds/basic/contact/";
}
String getServiceType(){
String getCommunicationProvider(){
return "/api/jobnet_app/comm_services/";
}
String deleteContact (){

View File

@ -45,8 +45,8 @@ class UniTSplashScreen extends StatelessWidget {
height: 1,
color: Colors.black)),
),
const SizedBox(height: 5,),
SpinKitThreeBounce(color: Colors.black,size: 32,)
const SizedBox(height: 150,),
const SpinKitCircle(color: primary,size: 42,)
// Row(
// mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.center,