diff --git a/lib/bloc/profile/profile_bloc.dart b/lib/bloc/profile/profile_bloc.dart index 2439f6e..10a5515 100644 --- a/lib/bloc/profile/profile_bloc.dart +++ b/lib/bloc/profile/profile_bloc.dart @@ -4,15 +4,15 @@ import 'package:unit2/model/profile/basic_info.dart'; import 'package:unit2/model/profile/basic_information/primary-information.dart'; import 'package:unit2/model/profile/eligibility.dart'; import 'package:unit2/model/profile/profileInfomation.dart'; -import 'package:unit2/model/utils/eligibilities_choices.dart'; +import 'package:unit2/model/utils/eligibility.dart'; import 'package:unit2/sevices/profile/profile_service.dart'; import 'package:unit2/utils/location_utilities.dart'; import 'package:unit2/utils/profile_utilities.dart'; -import '../../model/location/country.dart' as country; -import '../../model/location/region.dart' as region; -import '../../model/location/provinces.dart' as province; -import '../../model/location/city.dart' as city; -import '../../model/location/barangay.dart' as barangay; +import '../../model/location/country.dart'; +import '../../model/location/region.dart'; +import '../../model/location/provinces.dart'; +import '../../model/location/city.dart'; +import '../../model/location/barangay.dart'; part 'profile_event.dart'; part 'profile_state.dart'; @@ -35,17 +35,53 @@ class ProfileBloc extends Bloc { emit(ProfileLoading()); emit(EligibilityLoaded(eligibilities: event.eligibilities)); }); - on((event, emit) async{ + + on((event, emit) async { // try{ - List countries = await LocationUtils.instance.getCountries(); - List regions = await LocationUtils.instance.getRegions(); - List eligibilities = await ProfileUtilities.instance.getEligibilities(); - List provinces = await LocationUtils.instance.getProvinces(regionCode: event.eligibityCert.examAddress!.cityMunicipality!.province!.region!.code!.toString()); - emit(EditEligibilityState(provinces: provinces, eligibityCert: event.eligibityCert,countries: countries,regions: regions,eligibilities: eligibilities)); + emit(ProfileLoading()); + List regions = await LocationUtils.instance.getRegions(); + List eligibilities = + await ProfileUtilities.instance.getEligibilities(); + bool? isOverseas = event.eligibityCert.overseas; + List provinces = + event.eligibityCert.examAddress?.cityMunicipality?.province?.region != null + ? await LocationUtils.instance.getProvinces( + regionCode: event.eligibityCert.examAddress!.cityMunicipality! + .province!.region!.code! + .toString()) + : []; + List citymuns = + event.eligibityCert.examAddress?.cityMunicipality != null + ? await LocationUtils.instance.getCities( + code: event.eligibityCert.examAddress!.cityMunicipality! + .province!.code!) + : []; + emit(EditNotOverseasEligibilityState( + currentEligibility: null, + currentRegion: null, + isOverseas: isOverseas!, + cityMuns: citymuns, + provinces: provinces, + eligibityCert: event.eligibityCert, + regions: regions, + eligibilities: eligibilities)); + // }catch(e){ // emit(ProfileErrorState(mesage: e.toString())); // } - + });on((event,emit)async{ + emit(ProfileLoading()); + List countries = await LocationUtils.instance.getCountries(); + List eligibilities = + await ProfileUtilities.instance.getEligibilities(); + bool? isOverseas = event.eligibityCert.overseas; + emit(EditOverseasEligibilityState( + countries: countries, + currentCOuntry: null, + currentEligibility: null, + isOverseas: isOverseas!, + eligibityCert: event.eligibityCert, + eligibilities: eligibilities)); }); } } diff --git a/lib/bloc/profile/profile_event.dart b/lib/bloc/profile/profile_event.dart index 0548743..df9d027 100644 --- a/lib/bloc/profile/profile_event.dart +++ b/lib/bloc/profile/profile_event.dart @@ -28,9 +28,16 @@ class LoadEligibility extends ProfileEvent{ List get props => []; } -class EditEligibility extends ProfileEvent{ +class EditEligibilityOverseas extends ProfileEvent{ final EligibityCert eligibityCert; - const EditEligibility({required this.eligibityCert}); + const EditEligibilityOverseas({required this.eligibityCert}); + @override + List get props => []; +} + +class EditEligibilityNotOverseas extends ProfileEvent{ + final EligibityCert eligibityCert; + const EditEligibilityNotOverseas({required this.eligibityCert}); @override List get props => []; } diff --git a/lib/bloc/profile/profile_state.dart b/lib/bloc/profile/profile_state.dart index 8695782..4b38a3e 100644 --- a/lib/bloc/profile/profile_state.dart +++ b/lib/bloc/profile/profile_state.dart @@ -2,45 +2,74 @@ part of 'profile_bloc.dart'; abstract class ProfileState extends Equatable { const ProfileState(); - + @override List get props => []; } class ProfileInitial extends ProfileState {} -class ProfileLoaded extends ProfileState{ +class ProfileLoaded extends ProfileState { final ProfileInformation profileInformation; - const ProfileLoaded({required this.profileInformation}); + const ProfileLoaded({required this.profileInformation}); @override List get props => [profileInformation]; } -class ProfileErrorState extends ProfileState{ +class ProfileErrorState extends ProfileState { final String mesage; const ProfileErrorState({required this.mesage}); - @override + @override List get props => [mesage]; } -class ProfileLoading extends ProfileState{ +class ProfileLoading extends ProfileState {} -} - -class EligibilityLoaded extends ProfileState{ +class EligibilityLoaded extends ProfileState { final List eligibilities; const EligibilityLoaded({required this.eligibilities}); - @override + @override List get props => [eligibilities]; } -class EditEligibilityState extends ProfileState{ +class EditNotOverseasEligibilityState extends ProfileState { final EligibityCert eligibityCert; - final List eligibilities; - final List countries; - final List regions; - List provinces; - EditEligibilityState({ required this.provinces,required this.eligibityCert, required this.eligibilities, required this.countries, required this.regions}); - @override - List get props => [eligibityCert]; + final List eligibilities; + + final List regions; + List provinces; + List cityMuns; + Eligibility? currentEligibility; + Region? currentRegion; + Province? currentProvince; + bool? isOverseas; + EditNotOverseasEligibilityState( + {required this.currentEligibility, + required this.currentRegion, + required this.isOverseas, + required this.cityMuns, + required this.provinces, + required this.eligibityCert, + required this.eligibilities, + required this.regions}); + + +} + +class EditOverseasEligibilityState extends ProfileState { + final List eligibilities; + final EligibityCert eligibityCert; + final Eligibility? currentEligibility; + final List countries; + final Country? currentCOuntry; + bool? isOverseas; + + EditOverseasEligibilityState( + {required this.currentEligibility, + required this.eligibilities, + required this.isOverseas, + required this.eligibityCert, + required this.countries, + required this.currentCOuntry}); + } diff --git a/lib/model/location/address_category.dart b/lib/model/location/address_category.dart new file mode 100644 index 0000000..0916912 --- /dev/null +++ b/lib/model/location/address_category.dart @@ -0,0 +1,23 @@ +class AddressCategory { + AddressCategory({ + required this.id, + required this.name, + required this.type, + }); + + final int? id; + final String? name; + final String? type; + + factory AddressCategory.fromJson(Map json) => AddressCategory( + id: json["id"], + name: json["name"], + type: json["type"], + ); + + Map toJson() => { + "id": id, + "name": name, + "type": type, + }; +} \ No newline at end of file diff --git a/lib/model/location/barangay.dart b/lib/model/location/barangay.dart index a56f2f2..f36032c 100644 --- a/lib/model/location/barangay.dart +++ b/lib/model/location/barangay.dart @@ -5,6 +5,9 @@ import 'package:meta/meta.dart'; import 'dart:convert'; +import 'city.dart'; +import 'provinces.dart'; + Barangay barangayFromJson(String str) => Barangay.fromJson(json.decode(str)); String barangayToJson(Barangay data) => json.encode(data.toJson()); @@ -33,90 +36,6 @@ class Barangay { }; } -class CityMunicipality { - CityMunicipality({ - required this.code, - required this.description, - required this.province, - required this.psgcCode, - required this.zipcode, - }); - final String? code; - final String? description; - final Province? province; - final String? psgcCode; - final String? zipcode; - factory CityMunicipality.fromJson(Map json) => CityMunicipality( - code: json["code"], - description: json["description"], - province: json['province'] == null? null:Province.fromJson(json["province"]), - psgcCode: json["psgc_code"], - zipcode: json["zipcode"], - ); - Map toJson() => { - "code": code, - "description": description, - "province": province!.toJson(), - "psgc_code": psgcCode, - "zipcode": zipcode, - }; -} - -class Province { - Province({ - required this.code, - required this.description, - required this.region, - required this.psgcCode, - required this.shortname, - }); - - final String? code; - final String? description; - final Region? region; - final String? psgcCode; - final String? shortname; - - factory Province.fromJson(Map json) => Province( - code: json["code"], - description: json["description"], - region: json['region'] == null? null: Region.fromJson(json["region"]), - psgcCode: json["psgc_code"], - shortname: json["shortname"], - ); - - Map toJson() => { - "code": code, - "description": description, - "region": region!.toJson(), - "psgc_code": psgcCode, - "shortname": shortname, - }; -} - -class Region { - Region({ - required this.code, - required this.description, - required this.psgcCode, - }); - - final int? code; - final String? description; - final String? psgcCode; - - factory Region.fromJson(Map json) => Region( - code: json["code"], - description: json["description"], - psgcCode: json["psgc_code"], - ); - - Map toJson() => { - "code": code, - "description": description, - "psgc_code": psgcCode, - }; -} diff --git a/lib/model/location/city.dart b/lib/model/location/city.dart index e946098..c9c449a 100644 --- a/lib/model/location/city.dart +++ b/lib/model/location/city.dart @@ -5,12 +5,15 @@ import 'package:meta/meta.dart'; import 'dart:convert'; -City cityFromJson(String str) => City.fromJson(json.decode(str)); +import 'provinces.dart'; +import 'region.dart'; -String cityToJson(City data) => json.encode(data.toJson()); +CityMunicipality cityFromJson(String str) => CityMunicipality.fromJson(json.decode(str)); -class City { - City({ +String cityToJson(CityMunicipality data) => json.encode(data.toJson()); + +class CityMunicipality { + CityMunicipality({ required this.code, required this.description, required this.province, @@ -24,7 +27,7 @@ class City { final String? psgcCode; final String? zipcode; - factory City.fromJson(Map json) => City( + factory CityMunicipality.fromJson(Map json) => CityMunicipality( code: json["code"], description: json["description"], province: json['province'] == null? null : Province.fromJson(json["province"]), @@ -41,58 +44,4 @@ class City { }; } -class Province { - Province({ - required this.code, - required this.description, - required this.region, - required this.psgcCode, - required this.shortname, - }); - final String? code; - final String? description; - final Region? region; - final String? psgcCode; - final String? shortname; - - factory Province.fromJson(Map json) => Province( - code: json["code"], - description: json["description"], - region: json['region'] == null ? null : Region.fromJson(json["region"]), - psgcCode: json["psgc_code"], - shortname: json["shortname"], - ); - - Map toJson() => { - "code": code, - "description": description, - "region": region!.toJson(), - "psgc_code": psgcCode, - "shortname": shortname, - }; -} - -class Region { - Region({ - required this.code, - required this.description, - required this.psgcCode, - }); - - final int? code; - final String? description; - final String? psgcCode; - - factory Region.fromJson(Map json) => Region( - code: json["code"], - description: json["description"], - psgcCode: json["psgc_code"], - ); - - Map toJson() => { - "code": code, - "description": description, - "psgc_code": psgcCode, - }; -} diff --git a/lib/model/location/subdivision.dart b/lib/model/location/subdivision.dart new file mode 100644 index 0000000..950d80e --- /dev/null +++ b/lib/model/location/subdivision.dart @@ -0,0 +1,23 @@ +class Subdivision { + Subdivision({ + this.id, + this.lotNo, + this.blockNo, + }); + + final int? id; + final int? lotNo; + final int? blockNo; + + factory Subdivision.fromJson(Map json) => Subdivision( + id: json["id"], + lotNo: json["lot_no"], + blockNo: json["block_no"], + ); + + Map toJson() => { + "id": id, + "lot_no": lotNo, + "block_no": blockNo, + }; +} \ No newline at end of file diff --git a/lib/model/profile/basic_information/adress.dart b/lib/model/profile/basic_information/adress.dart index 68e18d6..4e941ec 100644 --- a/lib/model/profile/basic_information/adress.dart +++ b/lib/model/profile/basic_information/adress.dart @@ -1,5 +1,11 @@ +import '../../location/barangay.dart'; +import '../../location/city.dart'; +import '../../location/country.dart'; +import '../../location/subdivision.dart'; +import '../../utils/category.dart'; + class MainAdress { MainAdress({ this.id, @@ -64,186 +70,7 @@ class AddressClass { }; } -class Barangay { - Barangay({ - this.code, - this.description, - this.cityMunicipality, - }); - final String? code; - final String? description; - final CityMunicipality? cityMunicipality; - factory Barangay.fromJson(Map json) => Barangay( - code: json["code"], - description: json["description"], - cityMunicipality: json["city_municipality"] == null ? null : CityMunicipality.fromJson(json["city_municipality"]), - ); - Map toJson() => { - "code": code, - "description": description, - "city_municipality": cityMunicipality?.toJson(), - }; -} -class CityMunicipality { - CityMunicipality({ - this.code, - this.zipcode, - this.province, - this.psgcCode, - this.description, - }); - - final String? code; - final String? zipcode; - final Province? province; - final String? psgcCode; - final String? description; - - factory CityMunicipality.fromJson(Map json) => CityMunicipality( - code: json["code"], - zipcode: json["zipcode"], - province: json["province"] == null ? null : Province.fromJson(json["province"]), - psgcCode: json["psgc_code"], - description: json["description"], - ); - - Map toJson() => { - "code": code, - "zipcode": zipcode, - "province": province?.toJson(), - "psgc_code": psgcCode, - "description": description, - }; -} - -class Province { - Province({ - this.code, - this.region, - this.psgcCode, - this.shortname, - this.description, - }); - - final String? code; - final Region? region; - final String? psgcCode; - final String? shortname; - final String? description; - - factory Province.fromJson(Map json) => Province( - code: json["code"], - region: json["region"] == null ? null : Region.fromJson(json["region"]), - psgcCode: json["psgc_code"], - shortname: json["shortname"], - description: json["description"], - ); - - Map toJson() => { - "code": code, - "region": region?.toJson(), - "psgc_code": psgcCode, - "shortname": shortname, - "description": description, - }; -} - -class Region { - Region({ - this.code, - this.psgcCode, - this.description, - }); - - final int? code; - final String? psgcCode; - final String? description; - - factory Region.fromJson(Map json) => Region( - code: json["code"], - psgcCode: json["psgc_code"], - description: json["description"], - ); - - Map toJson() => { - "code": code, - "psgc_code": psgcCode, - "description": description, - }; -} - -class Category { - Category({ - this.id, - this.name, - this.type, - }); - - final int? id; - final String? name; - final String? type; - - factory Category.fromJson(Map json) => Category( - id: json["id"], - name: json["name"], - type: json["type"], - ); - - Map toJson() => { - "id": id, - "name": name, - "type": type, - }; -} - -class Country { - Country({ - this.id, - this.code, - this.name, - }); - - final int? id; - final String? code; - final String? name; - - factory Country.fromJson(Map json) => Country( - id: json["id"], - code: json["code"], - name: json["name"], - ); - - Map toJson() => { - "id": id, - "code": code, - "name": name, - }; -} - -class Subdivision { - Subdivision({ - this.id, - this.lotNo, - this.blockNo, - }); - - final int? id; - final int? lotNo; - final int? blockNo; - - factory Subdivision.fromJson(Map json) => Subdivision( - id: json["id"], - lotNo: json["lot_no"], - blockNo: json["block_no"], - ); - - Map toJson() => { - "id": id, - "lot_no": lotNo, - "block_no": blockNo, - }; -} diff --git a/lib/model/profile/basic_information/citizenship.dart b/lib/model/profile/basic_information/citizenship.dart index 397e12d..1c694ed 100644 --- a/lib/model/profile/basic_information/citizenship.dart +++ b/lib/model/profile/basic_information/citizenship.dart @@ -1,4 +1,6 @@ +import '../../location/country.dart'; + class Citizenship { Citizenship({ required this.country, @@ -18,27 +20,3 @@ class Citizenship { "natural_born": naturalBorn, }; } - -class Country { - Country({ - required this.id, - required this.code, - required this.name, - }); - - final int? id; - final String? code; - final String? name; - - factory Country.fromJson(Map json) => Country( - id: json["id"], - code: json["code"], - name: json["name"], - ); - - Map toJson() => { - "id": id, - "code": code, - "name": name, - }; -} diff --git a/lib/model/profile/basic_information/contact_information.dart b/lib/model/profile/basic_information/contact_information.dart index 729e7f5..3c182e9 100644 --- a/lib/model/profile/basic_information/contact_information.dart +++ b/lib/model/profile/basic_information/contact_information.dart @@ -3,6 +3,8 @@ // final contactInformation = contactInformationFromJson(jsonString); +import '../../utils/agency.dart'; + class ContactInfo { ContactInfo({ required this.id, @@ -83,81 +85,6 @@ class ServiceProvider { }; } -class Agency { - Agency({ - required this.id, - required this.name, - required this.category, - required this.privateEntity, - }); - - int? id; - String? name; - Category? category; - bool? privateEntity; - - factory Agency.fromJson(Map json) => Agency( - id: json["id"], - name: json["name"], - category: json["category"] == null? null : Category.fromJson(json["category"]), - privateEntity: json["private_entity"], - ); - - Map toJson() => { - "id": id, - "name": name, - "category": category!.toJson(), - "private_entity": privateEntity, - }; -} - -class Category { - Category({ - required this.id, - required this.name, - required this.industryClass, - }); - - int? id; - String? name; - IndustryClass? industryClass; - - factory Category.fromJson(Map json) => Category( - id: json["id"], - name: json["name"], - industryClass: json["industry_class"] == null? null: IndustryClass.fromJson(json["industry_class"]), - ); - - Map toJson() => { - "id": id, - "name": name, - "industry_class": industryClass!.toJson(), - }; -} - -class IndustryClass { - IndustryClass({ - required this.id, - required this.name, - this.description, - }); - - int? id; - String? name; - String? description; - - factory IndustryClass.fromJson(Map json) => IndustryClass( - id: json["id"], - name: json["name"], - description: json["description"], - ); - - Map toJson() => { - "id": id, - "name": name, - "description": description, - }; -} class ServiceType { ServiceType({ diff --git a/lib/model/profile/basic_information/identification_information.dart b/lib/model/profile/basic_information/identification_information.dart index f0ee066..61411c1 100644 --- a/lib/model/profile/basic_information/identification_information.dart +++ b/lib/model/profile/basic_information/identification_information.dart @@ -1,5 +1,9 @@ import 'dart:convert'; +import '../../location/city.dart'; +import '../../location/country.dart'; +import '../../utils/agency.dart'; + Identification identificationFromJson(String str) => Identification.fromJson(json.decode(str)); String identificationToJson(Identification data) => json.encode(data.toJson()); @@ -44,81 +48,6 @@ class Identification { }; } -class Agency { - Agency({ - required this.id, - required this.name, - required this.category, - required this.privateEntity, - }); - - int? id; - String? name; - Category? category; - bool? privateEntity; - - factory Agency.fromJson(Map json) => Agency( - id: json["id"], - name: json["name"], - category: json["category"] == null? null: Category.fromJson(json["category"]), - privateEntity: json["private_entity"], - ); - - Map toJson() => { - "id": id, - "name": name, - "category": category!.toJson(), - "private_entity": privateEntity, - }; -} - -class Category { - Category({ - required this.id, - required this.name, - required this.industryClass, - }); - - int? id; - String? name; - IndustryClass? industryClass; - - factory Category.fromJson(Map json) => Category( - id: json["id"], - name: json["name"], - industryClass:json['industry_class'] == null? null: IndustryClass.fromJson(json["industry_class"]), - ); - - Map toJson() => { - "id": id, - "name": name, - "industry_class": industryClass!.toJson(), - }; -} - -class IndustryClass { - IndustryClass({ - required this.id, - required this.name, - this.description, - }); - - int? id; - String? name; - String? description; - - factory IndustryClass.fromJson(Map json) => IndustryClass( - id: json["id"], - name: json["name"], - description: json["description"], - ); - - Map toJson() => { - "id": id, - "name": name, - "description": description, - }; -} class IssuedAt { IssuedAt({ @@ -179,115 +108,3 @@ class AddressCategory { "type": type, }; } - -class CityMunicipality { - CityMunicipality({ - required this.code, - required this.zipcode, - required this.province, - required this.psgcCode, - required this.description, - }); - - String? code; - String? zipcode; - Province? province; - String? psgcCode; - String? description; - - factory CityMunicipality.fromJson(Map json) => CityMunicipality( - code: json["code"], - zipcode: json["zipcode"], - province:json["province"] == null? null : Province.fromJson(json["province"]), - psgcCode: json["psgc_code"], - description: json["description"], - ); - - Map toJson() => { - "code": code, - "zipcode": zipcode, - "province": province!.toJson(), - "psgc_code": psgcCode, - "description": description, - }; -} - -class Province { - Province({ - required this.code, - required this.region, - required this.psgcCode, - required this.shortname, - required this.description, - }); - - String? code; - Region? region; - String? psgcCode; - String? shortname; - String? description; - - factory Province.fromJson(Map json) => Province( - code: json["code"], - region: json["region"] == null? null:Region.fromJson(json["region"]), - psgcCode: json["psgc_code"], - shortname: json["shortname"], - description: json["description"], - ); - - Map toJson() => { - "code": code, - "region": region!.toJson(), - "psgc_code": psgcCode, - "shortname": shortname, - "description": description, - }; -} - -class Region { - Region({ - required this.code, - required this.psgcCode, - required this.description, - }); - - int? code; - String? psgcCode; - String? description; - - factory Region.fromJson(Map json) => Region( - code: json["code"], - psgcCode: json["psgc_code"], - description: json["description"], - ); - - Map toJson() => { - "code": code, - "psgc_code": psgcCode, - "description": description, - }; -} - -class Country { - Country({ - required this.id, - required this.code, - required this.name, - }); - - int? id; - String? code; - String? name; - - factory Country.fromJson(Map json) => Country( - id: json["id"], - code: json["code"], - name: json["name"], - ); - - Map toJson() => { - "id": id, - "code": code, - "name": name, - }; -} diff --git a/lib/model/profile/eligibility.dart b/lib/model/profile/eligibility.dart index 674b65e..5f7e7fd 100644 --- a/lib/model/profile/eligibility.dart +++ b/lib/model/profile/eligibility.dart @@ -5,6 +5,13 @@ import 'package:meta/meta.dart'; import 'dart:convert'; +import 'package:unit2/model/location/region.dart'; + +import '../location/address_category.dart'; +import '../location/city.dart'; +import '../location/country.dart'; +import '../utils/eligibility.dart'; + EligibityCert eligibityFromJson(String str) => EligibityCert.fromJson(json.decode(str)); String eligibityToJson(EligibityCert data) => json.encode(data.toJson()); @@ -19,8 +26,9 @@ class EligibityCert { required this.examAddress, required this.validityDate, required this.licenseNumber, - }); - + required this.overseas, + }); + bool? overseas; final int? id; final double? rating; final DateTime? examDate; @@ -39,6 +47,7 @@ class EligibityCert { examAddress: json['exam_address'] == null? null: ExamAddress.fromJson(json["exam_address"]), validityDate: json["validity_date"], licenseNumber: json["license_number"], + overseas: null, ); Map toJson() => { @@ -53,29 +62,6 @@ class EligibityCert { }; } -class Eligibility { - Eligibility({ - required this.id, - required this.type, - required this.title, - }); - - final int? id; - final String? type; - final String? title; - - factory Eligibility.fromJson(Map json) => Eligibility( - id: json["id"], - type: json["type"], - title: json["title"], - ); - - Map toJson() => { - "id": id, - "type": type, - "title": title, - }; -} class ExamAddress { ExamAddress({ @@ -113,138 +99,3 @@ class ExamAddress { }; } -class AddressCategory { - AddressCategory({ - required this.id, - required this.name, - required this.type, - }); - - final int? id; - final String? name; - final String? type; - - factory AddressCategory.fromJson(Map json) => AddressCategory( - id: json["id"], - name: json["name"], - type: json["type"], - ); - - Map toJson() => { - "id": id, - "name": name, - "type": type, - }; -} - -class CityMunicipality { - CityMunicipality({ - required this.code, - required this.zipcode, - required this.province, - required this.psgcCode, - required this.description, - }); - - final String? code; - final String? zipcode; - final Province? province; - final String? psgcCode; - final String? description; - - factory CityMunicipality.fromJson(Map json) => CityMunicipality( - code: json["code"], - zipcode: json["zipcode"], - province: json["province"]== null? null: Province.fromJson(json["province"]), - psgcCode: json["psgc_code"], - description: json["description"], - ); - - Map toJson() => { - "code": code, - "zipcode": zipcode, - "province": province!.toJson(), - "psgc_code": psgcCode, - "description": description, - }; -} - -class Province { - Province({ - required this.code, - required this.region, - required this.psgcCode, - required this.shortname, - required this.description, - }); - - final String? code; - final Region? region; - final String? psgcCode; - final String? shortname; - final String? description; - - factory Province.fromJson(Map json) => Province( - code: json["code"], - region:json["region"] == null? null: Region.fromJson(json["region"]), - psgcCode: json["psgc_code"], - shortname: json["shortname"], - description: json["description"], - ); - - Map toJson() => { - "code": code, - "region": region!.toJson(), - "psgc_code": psgcCode, - "shortname": shortname, - "description": description, - }; -} - -class Region { - Region({ - required this.code, - required this.psgcCode, - required this.description, - }); - - final int? code; - final String? psgcCode; - final String? description; - - factory Region.fromJson(Map json) => Region( - code: json["code"], - psgcCode: json["psgc_code"], - description: json["description"], - ); - - Map toJson() => { - "code": code, - "psgc_code": psgcCode, - "description": description, - }; -} - -class Country { - Country({ - required this.id, - required this.code, - required this.name, - }); - - final int? id; - final String? code; - final String? name; - - factory Country.fromJson(Map json) => Country( - id: json["id"], - code: json["code"], - name: json["name"], - ); - - Map toJson() => { - "id": id, - "code": code, - "name": name, - }; -} diff --git a/lib/model/profile/family_backround.dart b/lib/model/profile/family_backround.dart index 9083cb7..68275a1 100644 --- a/lib/model/profile/family_backround.dart +++ b/lib/model/profile/family_backround.dart @@ -5,6 +5,9 @@ import 'dart:convert'; import 'dart:ffi'; +import '../utils/category.dart'; +import '../utils/position.dart'; + FamilyBackground familyBackgroundFromJson(String str) => FamilyBackground.fromJson(json.decode(str)); String familyBackgroundToJson(FamilyBackground data) => json.encode(data.toJson()); @@ -81,53 +84,6 @@ class Company { }; } -class Category { - Category({ - this.id, - this.name, - this.industryClass, - }); - - final int? id; - final String? name; - final IndustryClass? industryClass; - - factory Category.fromJson(Map json) => Category( - id: json["id"], - name: json["name"], - industryClass: json["industry_class"] == null ? null : IndustryClass.fromJson(json["industry_class"]), - ); - - Map toJson() => { - "id": id, - "name": name, - "industry_class": industryClass?.toJson(), - }; -} - -class IndustryClass { - IndustryClass({ - this.id, - this.name, - this.description, - }); - - final int? id; - final String? name; - final String? description; - - factory IndustryClass.fromJson(Map json) => IndustryClass( - id: json["id"], - name: json["name"], - description: json["description"], - ); - - Map toJson() => { - "id": id, - "name": name, - "description": description, - }; -} class EmergencyContact { EmergencyContact({ @@ -173,25 +129,6 @@ class EmergencyContact { }; } -class Position { - Position({ - this.id, - this.title, - }); - - final int? id; - final String? title; - - factory Position.fromJson(Map json) => Position( - id: json["id"], - title: json["title"], - ); - - Map toJson() => { - "id": id, - "title": title, - }; -} class RelatedPerson { RelatedPerson({ diff --git a/lib/model/profile/learning_development.dart b/lib/model/profile/learning_development.dart index 4131a02..11bb21b 100644 --- a/lib/model/profile/learning_development.dart +++ b/lib/model/profile/learning_development.dart @@ -4,6 +4,10 @@ import 'dart:convert'; +import '../location/city.dart'; +import '../location/country.dart'; +import '../utils/industry_class.dart'; + LearningDevelopement learningDevelopementFromJson(String str) => LearningDevelopement.fromJson(json.decode(str)); String learningDevelopementToJson(LearningDevelopement data) => json.encode(data.toJson()); @@ -144,29 +148,6 @@ class SponsoredByCategory { }; } -class IndustryClass { - IndustryClass({ - this.id, - this.name, - this.description, - }); - - final int? id; - final String? name; - final dynamic description; - - factory IndustryClass.fromJson(Map json) => IndustryClass( - id: json["id"], - name: json["name"], - description: json["description"], - ); - - Map toJson() => { - "id": id, - "name": name, - "description": description, - }; -} class LearningDevelopmentType { LearningDevelopmentType({ @@ -248,114 +229,3 @@ class VenueCategory { }; } -class CityMunicipality { - CityMunicipality({ - this.code, - this.zipcode, - this.province, - this.psgcCode, - this.description, - }); - - final String? code; - final String? zipcode; - final Province? province; - final String? psgcCode; - final String? description; - - factory CityMunicipality.fromJson(Map json) => CityMunicipality( - code: json["code"], - zipcode: json["zipcode"], - province: json["province"] == null ? null : Province.fromJson(json["province"]), - psgcCode: json["psgc_code"], - description: json["description"], - ); - - Map toJson() => { - "code": code, - "zipcode": zipcode, - "province": province?.toJson(), - "psgc_code": psgcCode, - "description": description, - }; -} - -class Province { - Province({ - this.code, - this.region, - this.psgcCode, - this.shortname, - this.description, - }); - - final String? code; - final Region? region; - final String? psgcCode; - final String? shortname; - final String? description; - - factory Province.fromJson(Map json) => Province( - code: json["code"], - region: json["region"] == null ? null : Region.fromJson(json["region"]), - psgcCode: json["psgc_code"], - shortname: json["shortname"], - description: json["description"], - ); - - Map toJson() => { - "code": code, - "region": region?.toJson(), - "psgc_code": psgcCode, - "shortname": shortname, - "description": description, - }; -} - -class Region { - Region({ - this.code, - this.psgcCode, - this.description, - }); - - final int? code; - final String? psgcCode; - final String? description; - - factory Region.fromJson(Map json) => Region( - code: json["code"], - psgcCode: json["psgc_code"], - description: json["description"], - ); - - Map toJson() => { - "code": code, - "psgc_code": psgcCode, - "description": description, - }; -} - -class Country { - Country({ - this.id, - this.code, - this.name, - }); - - final int? id; - final String? code; - final String? name; - - factory Country.fromJson(Map json) => Country( - id: json["id"], - code: json["code"], - name: json["name"], - ); - - Map toJson() => { - "id": id, - "code": code, - "name": name, - }; -} diff --git a/lib/model/profile/other_information/non_acedimic_recognition.dart b/lib/model/profile/other_information/non_acedimic_recognition.dart index 0697a66..9e4b6a7 100644 --- a/lib/model/profile/other_information/non_acedimic_recognition.dart +++ b/lib/model/profile/other_information/non_acedimic_recognition.dart @@ -4,6 +4,8 @@ import 'dart:convert'; +import '../../utils/category.dart'; + NonAcademicRecognition nonAcademicRecognitionFromJson(String str) => NonAcademicRecognition.fromJson(json.decode(str)); String nonAcademicRecognitionToJson(NonAcademicRecognition data) => json.encode(data.toJson()); @@ -60,50 +62,3 @@ class Presenter { }; } -class Category { - Category({ - this.id, - this.name, - this.industryClass, - }); - - final int? id; - final String? name; - final IndustryClass? industryClass; - - factory Category.fromJson(Map json) => Category( - id: json["id"], - name: json["name"], - industryClass: json["industry_class"] == null ? null : IndustryClass.fromJson(json["industry_class"]), - ); - - Map toJson() => { - "id": id, - "name": name, - "industry_class": industryClass?.toJson(), - }; -} - -class IndustryClass { - IndustryClass({ - this.id, - this.name, - this.description, - }); - - final int? id; - final String? name; - final String? description; - - factory IndustryClass.fromJson(Map json) => IndustryClass( - id: json["id"], - name: json["name"], - description: json["description"], - ); - - Map toJson() => { - "id": id, - "name": name, - "description": description, - }; -} diff --git a/lib/model/profile/other_information/organization_memberships.dart b/lib/model/profile/other_information/organization_memberships.dart index 150f54f..9d690a4 100644 --- a/lib/model/profile/other_information/organization_memberships.dart +++ b/lib/model/profile/other_information/organization_memberships.dart @@ -4,6 +4,8 @@ import 'dart:convert'; +import '../../utils/agency.dart'; + OrganizationMembership organizationMembershipFromJson(String str) => OrganizationMembership.fromJson(json.decode(str)); String organizationMembershipToJson(OrganizationMembership data) => json.encode(data.toJson()); @@ -24,78 +26,4 @@ class OrganizationMembership { }; } -class Agency { - Agency({ - this.id, - this.name, - this.category, - this.privateEntity, - }); - final int? id; - final String? name; - final Category? category; - final bool? privateEntity; - - factory Agency.fromJson(Map json) => Agency( - id: json["id"], - name: json["name"], - category: json["category"] == null ? null : Category.fromJson(json["category"]), - privateEntity: json["private_entity"], - ); - - Map toJson() => { - "id": id, - "name": name, - "category": category?.toJson(), - "private_entity": privateEntity, - }; -} - -class Category { - Category({ - this.id, - this.name, - this.industryClass, - }); - - final int? id; - final String? name; - final IndustryClass? industryClass; - - factory Category.fromJson(Map json) => Category( - id: json["id"], - name: json["name"], - industryClass: json["industry_class"] == null ? null : IndustryClass.fromJson(json["industry_class"]), - ); - - Map toJson() => { - "id": id, - "name": name, - "industry_class": industryClass?.toJson(), - }; -} - -class IndustryClass { - IndustryClass({ - this.id, - this.name, - this.description, - }); - - final int? id; - final String? name; - final String? description; - - factory IndustryClass.fromJson(Map json) => IndustryClass( - id: json["id"], - name: json["name"], - description: json["description"], - ); - - Map toJson() => { - "id": id, - "name": name, - "description": description, - }; -} diff --git a/lib/model/profile/references.dart b/lib/model/profile/references.dart index 9fda1eb..d7e1e05 100644 --- a/lib/model/profile/references.dart +++ b/lib/model/profile/references.dart @@ -1,6 +1,12 @@ // To parse this JSON data, do // // final references = referencesFromJson(jsonString); +import '../location/address_category.dart'; +import '../location/barangay.dart'; +import '../location/city.dart'; +import '../location/country.dart'; +import '../location/provinces.dart'; + class PersonalReference { PersonalReference({ required this.id, @@ -73,162 +79,6 @@ class Address { }; } -class AddressCategory { - AddressCategory({ - required this.id, - required this.name, - required this.type, - }); - final int? id; - final String? name; - final String? type; - factory AddressCategory.fromJson(Map json) => AddressCategory( - id: json["id"], - name: json["name"], - type: json["type"], - ); - Map toJson() => { - "id": id, - "name": name, - "type": type, - }; -} - -class Barangay { - Barangay({ - required this.code, - required this.description, - required this.cityMunicipality, - }); - - final String? code; - final String? description; - final CityMunicipality? cityMunicipality; - - factory Barangay.fromJson(Map json) => Barangay( - code: json["code"], - description: json["description"], - cityMunicipality: CityMunicipality.fromJson(json["city_municipality"]), - ); - - Map toJson() => { - "code": code, - "description": description, - "city_municipality": cityMunicipality!.toJson(), - }; -} - -class CityMunicipality { - CityMunicipality({ - required this.code, - required this.zipcode, - required this.province, - required this.psgcCode, - required this.description, - }); - - final String? code; - final String? zipcode; - final Province? province; - final String? psgcCode; - final String? description; - - factory CityMunicipality.fromJson(Map json) => CityMunicipality( - code: json["code"], - zipcode: json["zipcode"], - province: json["province"] == null? null : Province.fromJson(json["province"]), - psgcCode: json["psgc_code"], - description: json["description"], - ); - - Map toJson() => { - "code": code, - "zipcode": zipcode, - "province": province!.toJson(), - "psgc_code": psgcCode, - "description": description, - }; -} - -class Province { - Province({ - required this.code, - required this.region, - required this.psgcCode, - required this.shortname, - required this.description, - }); - - final String? code; - final Region? region; - final String? psgcCode; - final String? shortname; - final String? description; - - factory Province.fromJson(Map json) => Province( - code: json["code"], - region: json["region"] == null? null : Region.fromJson(json["region"]), - psgcCode: json["psgc_code"], - shortname: json["shortname"], - description: json["description"], - ); - - Map toJson() => { - "code": code, - "region": region!.toJson(), - "psgc_code": psgcCode, - "shortname": shortname, - "description": description, - }; -} - -class Region { - Region({ - required this.code, - required this.psgcCode, - required this.description, - }); - - final int? code; - final String? psgcCode; - final String? description; - - factory Region.fromJson(Map json) => Region( - code: json["code"], - psgcCode: json["psgc_code"], - description: json["description"], - ); - - Map toJson() => { - "code": code, - "psgc_code": psgcCode, - "description": description, - }; -} - -class Country { - Country({ - required this.id, - required this.code, - required this.name, - }); - - final int? id; - final String? code; - final String? name; - - factory Country.fromJson(Map json) => Country( - id: json["id"], - code: json["code"], - name: json["name"], - ); - - Map toJson() => { - "id": id, - "code": code, - "name": name, - }; -} diff --git a/lib/model/profile/voluntary_works.dart b/lib/model/profile/voluntary_works.dart index 267fb8d..8f5cdae 100644 --- a/lib/model/profile/voluntary_works.dart +++ b/lib/model/profile/voluntary_works.dart @@ -4,6 +4,12 @@ import 'dart:convert'; +import '../location/address_category.dart'; +import '../location/city.dart'; +import '../location/country.dart'; +import '../utils/agency.dart'; +import '../utils/position.dart'; + VoluntaryWork voluntaryWorkFromJson(String str) => VoluntaryWork.fromJson(json.decode(str)); String voluntaryWorkToJson(VoluntaryWork data) => json.encode(data.toJson()); @@ -80,234 +86,10 @@ class Address { }; } -class AddressCategory { - AddressCategory({ - this.id, - this.name, - this.type, - }); - final int? id; - final String? name; - final String? type; - factory AddressCategory.fromJson(Map json) => AddressCategory( - id: json["id"], - name: json["name"], - type: json["type"], - ); - Map toJson() => { - "id": id, - "name": name, - "type": type, - }; -} -class CityMunicipality { - CityMunicipality({ - this.code, - this.zipcode, - this.province, - this.psgcCode, - this.description, - }); - final String? code; - final String? zipcode; - final Province? province; - final String? psgcCode; - final String? description; - factory CityMunicipality.fromJson(Map json) => CityMunicipality( - code: json["code"], - zipcode: json["zipcode"], - province: json["province"] == null ? null : Province.fromJson(json["province"]), - psgcCode: json["psgc_code"], - description: json["description"], - ); - Map toJson() => { - "code": code, - "zipcode": zipcode, - "province": province?.toJson(), - "psgc_code": psgcCode, - "description": description, - }; -} - -class Province { - Province({ - this.code, - this.region, - this.psgcCode, - this.shortname, - this.description, - }); - - final String? code; - final Region? region; - final String? psgcCode; - final String? shortname; - final String? description; - - factory Province.fromJson(Map json) => Province( - code: json["code"], - region: json["region"] == null ? null : Region.fromJson(json["region"]), - psgcCode: json["psgc_code"], - shortname: json["shortname"], - description: json["description"], - ); - - Map toJson() => { - "code": code, - "region": region?.toJson(), - "psgc_code": psgcCode, - "shortname": shortname, - "description": description, - }; -} - -class Region { - Region({ - this.code, - this.psgcCode, - this.description, - }); - - final int? code; - final String? psgcCode; - final String? description; - - factory Region.fromJson(Map json) => Region( - code: json["code"], - psgcCode: json["psgc_code"], - description: json["description"], - ); - - Map toJson() => { - "code": code, - "psgc_code": psgcCode, - "description": description, - }; -} - -class Country { - Country({ - this.id, - this.code, - this.name, - }); - - final int? id; - final String? code; - final String? name; - - factory Country.fromJson(Map json) => Country( - id: json["id"], - code: json["code"], - name: json["name"], - ); - - Map toJson() => { - "id": id, - "code": code, - "name": name, - }; -} - -class Agency { - Agency({ - this.id, - this.name, - this.category, - this.privateEntity, - }); - - final int? id; - final String? name; - final Category? category; - final bool? privateEntity; - - factory Agency.fromJson(Map json) => Agency( - id: json["id"], - name: json["name"], - category: json["category"] == null ? null : Category.fromJson(json["category"]), - privateEntity: json["private_entity"], - ); - - Map toJson() => { - "id": id, - "name": name, - "category": category?.toJson(), - "private_entity": privateEntity, - }; -} - -class Category { - Category({ - this.id, - this.name, - this.industryClass, - }); - - final int? id; - final String? name; - final IndustryClass? industryClass; - - factory Category.fromJson(Map json) => Category( - id: json["id"], - name: json["name"], - industryClass: json["industry_class"] == null ? null : IndustryClass.fromJson(json["industry_class"]), - ); - - Map toJson() => { - "id": id, - "name": name, - "industry_class": industryClass?.toJson(), - }; -} - -class IndustryClass { - IndustryClass({ - this.id, - this.name, - this.description, - }); - - final int? id; - final String? name; - final String? description; - - factory IndustryClass.fromJson(Map json) => IndustryClass( - id: json["id"], - name: json["name"], - description: json["description"], - ); - - Map toJson() => { - "id": id, - "name": name, - "description": description, - }; -} - -class Position { - Position({ - this.id, - this.title, - }); - - final int? id; - final String? title; - - factory Position.fromJson(Map json) => Position( - id: json["id"], - title: json["title"], - ); - - Map toJson() => { - "id": id, - "title": title, - }; -} diff --git a/lib/model/profile/work_history.dart b/lib/model/profile/work_history.dart index 7a1ff98..687b1f7 100644 --- a/lib/model/profile/work_history.dart +++ b/lib/model/profile/work_history.dart @@ -4,6 +4,11 @@ import 'dart:convert'; +import '../utils/agency.dart'; +import '../utils/category.dart'; +import '../utils/industry_class.dart'; +import '../utils/position.dart'; + WorkHistory workHistoryFromJson(String str) => WorkHistory.fromJson(json.decode(str)); String workHistoryToJson(WorkHistory data) => json.encode(data.toJson()); @@ -60,98 +65,10 @@ class WorkHistory { }; } -class Agency { - Agency({ - this.id, - this.name, - this.category, - this.privateEntity, - }); - final int? id; - final String? name; - final Category? category; - final bool? privateEntity; - factory Agency.fromJson(Map json) => Agency( - id: json["id"], - name: json["name"], - category: json["category"] == null ? null : Category.fromJson(json["category"]), - privateEntity: json["private_entity"], - ); - Map toJson() => { - "id": id, - "name": name, - "category": category?.toJson(), - "private_entity": privateEntity, - }; -} -class Category { - Category({ - this.id, - this.name, - this.industryClass, - }); - final int? id; - final String? name; - final IndustryClass? industryClass; - factory Category.fromJson(Map json) => Category( - id: json["id"], - name: json["name"], - industryClass: json["industry_class"] == null ? null : IndustryClass.fromJson(json["industry_class"]), - ); - Map toJson() => { - "id": id, - "name": name, - "industry_class": industryClass?.toJson(), - }; -} - -class IndustryClass { - IndustryClass({ - this.id, - this.name, - this.description, - }); - - final int? id; - final String? name; - final String? description; - - factory IndustryClass.fromJson(Map json) => IndustryClass( - id: json["id"], - name: json["name"], - description: json["description"], - ); - - Map toJson() => { - "id": id, - "name": name, - "description": description, - }; -} - -class Position { - Position({ - this.id, - this.title, - }); - - final int? id; - final String? title; - - factory Position.fromJson(Map json) => Position( - id: json["id"], - title: json["title"], - ); - - Map toJson() => { - "id": id, - "title": title, - }; -} diff --git a/lib/model/utils/agency.dart b/lib/model/utils/agency.dart new file mode 100644 index 0000000..68056fb --- /dev/null +++ b/lib/model/utils/agency.dart @@ -0,0 +1,29 @@ +import 'package:unit2/model/utils/category.dart'; + +class Agency { + Agency({ + this.id, + this.name, + this.category, + this.privateEntity, + }); + + final int? id; + final String? name; + final Category? category; + final bool? privateEntity; + + factory Agency.fromJson(Map json) => Agency( + id: json["id"], + name: json["name"], + category: json["category"] == null ? null : Category.fromJson(json["category"]), + privateEntity: json["private_entity"], + ); + + Map toJson() => { + "id": id, + "name": name, + "category": category?.toJson(), + "private_entity": privateEntity, + }; +} \ No newline at end of file diff --git a/lib/model/utils/category.dart b/lib/model/utils/category.dart new file mode 100644 index 0000000..8319067 --- /dev/null +++ b/lib/model/utils/category.dart @@ -0,0 +1,25 @@ +import 'package:unit2/model/utils/industry_class.dart'; + +class Category { + Category({ + this.id, + this.name, + this.industryClass, + }); + + final int? id; + final String? name; + final IndustryClass? industryClass; + + factory Category.fromJson(Map json) => Category( + id: json["id"], + name: json["name"], + industryClass: json["industry_class"] == null ? null : IndustryClass.fromJson(json["industry_class"]), + ); + + Map toJson() => { + "id": id, + "name": name, + "industry_class": industryClass?.toJson(), + }; +} \ No newline at end of file diff --git a/lib/model/utils/eligibilities_choices.dart b/lib/model/utils/eligibility.dart similarity index 62% rename from lib/model/utils/eligibilities_choices.dart rename to lib/model/utils/eligibility.dart index eae00f0..c9b3a04 100644 --- a/lib/model/utils/eligibilities_choices.dart +++ b/lib/model/utils/eligibility.dart @@ -5,12 +5,12 @@ import 'package:meta/meta.dart'; import 'dart:convert'; -EligibilityList eligibilitiesFromJson(String str) => EligibilityList.fromJson(json.decode(str)); +Eligibility eligibilitiesFromJson(String str) => Eligibility.fromJson(json.decode(str)); -String eligibilitiesToJson(EligibilityList data) => json.encode(data.toJson()); +String eligibilitiesToJson(Eligibility data) => json.encode(data.toJson()); -class EligibilityList { - EligibilityList({ +class Eligibility { + Eligibility({ required this.id, required this.title, required this.type, @@ -20,7 +20,7 @@ class EligibilityList { final String title; final String type; - factory EligibilityList.fromJson(Map json) => EligibilityList( + factory Eligibility.fromJson(Map json) => Eligibility( id: json["id"], title: json["title"], type: json["type"], diff --git a/lib/model/utils/industry_class.dart b/lib/model/utils/industry_class.dart new file mode 100644 index 0000000..c6bb4bf --- /dev/null +++ b/lib/model/utils/industry_class.dart @@ -0,0 +1,23 @@ +class IndustryClass { + IndustryClass({ + this.id, + this.name, + this.description, + }); + + final int? id; + final String? name; + final String? description; + + factory IndustryClass.fromJson(Map json) => IndustryClass( + id: json["id"], + name: json["name"], + description: json["description"], + ); + + Map toJson() => { + "id": id, + "name": name, + "description": description, + }; +} \ No newline at end of file diff --git a/lib/model/utils/position.dart b/lib/model/utils/position.dart new file mode 100644 index 0000000..ff7ba26 --- /dev/null +++ b/lib/model/utils/position.dart @@ -0,0 +1,19 @@ +class Position { + Position({ + this.id, + this.title, + }); + + final int? id; + final String? title; + + factory Position.fromJson(Map json) => Position( + id: json["id"], + title: json["title"], + ); + + Map toJson() => { + "id": id, + "title": title, + }; +} \ No newline at end of file diff --git a/lib/screens/profile/components/eligibility/edit_modal.dart b/lib/screens/profile/components/eligibility/edit_modal.dart index c43b943..bc76af6 100644 --- a/lib/screens/profile/components/eligibility/edit_modal.dart +++ b/lib/screens/profile/components/eligibility/edit_modal.dart @@ -1,17 +1,17 @@ import 'package:date_time_picker/date_time_picker.dart'; 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_form_builder/flutter_form_builder.dart'; import 'package:intl/intl.dart'; import 'package:unit2/bloc/profile/profile_bloc.dart'; import 'package:unit2/bloc/user/user_bloc.dart'; +import 'package:unit2/model/location/city.dart'; +import 'package:unit2/model/login_data/employee_info/employee_info.dart'; import 'package:unit2/model/profile/eligibility.dart'; -import 'package:unit2/model/utils/eligibilities_choices.dart'; -import '../../../../model/location/country.dart' as c; -import '../../../../model/location/region.dart' as r; -import '../../../../model/location/provinces.dart' as p; +import 'package:unit2/model/utils/eligibility.dart'; +import '../../../../model/location/country.dart'; +import '../../../../model/location/region.dart'; +import '../../../../model/location/provinces.dart'; import '../../../../theme-data.dart/btn-style.dart'; import '../../../../theme-data.dart/colors.dart'; import '../../../../theme-data.dart/form-style.dart'; @@ -28,9 +28,10 @@ class EditEligibilityScreen extends StatefulWidget { class _EditEligibilityScreenState extends State { final formKey = GlobalKey(); - bool overseas = false; + final countryKey = GlobalKey(); + bool? overseas; DateFormat dteFormat2 = DateFormat.yMMMMd('en_US'); - c.Country? selectedCountry; + Country? selectedCountry; @override Widget build(BuildContext context) { //USERBLOC @@ -42,13 +43,8 @@ class _EditEligibilityScreenState extends State { return BlocBuilder( builder: (context, state) { //EDIT ELIGIBILITY STATE - if (state is EditEligibilityState) { - String? region = state.eligibityCert.examAddress! - .cityMunicipality!.province!.region!.description; - String? eligibiltyTitle = - state.eligibityCert.eligibility!.title!; - String? province = state.eligibityCert.examAddress! - .cityMunicipality!.province!.description!; + if (state is EditNotOverseasEligibilityState) { + overseas = state.isOverseas; return Center( child: Padding( padding: const EdgeInsets.symmetric( @@ -60,18 +56,18 @@ class _EditEligibilityScreenState extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ //ELIGIBILITIES DROPDOWN - FormBuilderDropdown( - initialValue: state.eligibityCert.eligibility, + FormBuilderDropdown( + initialValue: null, items: state.eligibilities - .map>( - (EligibilityList eligibility) { - return DropdownMenuItem( + .map>( + (Eligibility eligibility) { + return DropdownMenuItem( value: eligibility, child: Text(eligibility.title)); }).toList(), name: "eligibility", decoration: normalTextFieldStyle( - "Eligibility", eligibiltyTitle) + "Eligibility", "") .copyWith( hintStyle: const TextStyle( color: Colors.black, @@ -177,9 +173,12 @@ class _EditEligibilityScreenState extends State { initialValue: overseas, activeColor: second, onChanged: (value) { - setState(() { - overseas = value!; - }); + EligibityCert newEligibility = + state.eligibityCert; + newEligibility.overseas = value!; + context.read().add( + EditEligibilityOverseas( + eligibityCert: newEligibility)); }, decoration: normalTextFieldStyle("", ''), name: 'overseas', @@ -188,97 +187,68 @@ class _EditEligibilityScreenState extends State { const SizedBox( height: 20, ), - //COUNTRY DROPDOWN + Column( + children: [ + //REGION DROPDOWN + FormBuilderDropdown( + onChanged: (Region? region) {}, + // initialValue:state.eligibityCert.examAddress!.cityMunicipality!.province!.description!, - SizedBox( - child: overseas == true - ? FormBuilderDropdown( - items: state.countries - .map>( - (c.Country country) { - return DropdownMenuItem( - value: country, - child: Text(country.name!)); - }).toList(), - name: 'country', - decoration: normalTextFieldStyle( - "Country", "Country"), - onChanged: (value) { - setState(() { - selectedCountry = value; - }); - }, - ) - : Column( - children: [ - //REGION DROPDOWN - FormBuilderDropdown( - // initialValue:state.eligibityCert.examAddress!.cityMunicipality!.province!.description!, - decoration: normalTextFieldStyle( - "Region", region ?? - "Region*") - .copyWith( - hintStyle: const TextStyle( - color: Colors.black, - ), - labelStyle: const TextStyle( - color: Colors.black)), - name: 'region', - items: state.regions.map< - DropdownMenuItem>( - (r.Region region) { - return DropdownMenuItem( - value: region, - child: Text( - region.description!)); - }).toList(), - ), - const SizedBox( - height: 20, - ), - //PROVINCE DROPDOWN - FormBuilderDropdown( - name: 'province', - items: state.provinces.map< - DropdownMenuItem< - p.Province>>( - (p.Province province) { - return DropdownMenuItem( - value: province, - child: Text( - province.description!)); - }).toList(), - decoration: normalTextFieldStyle( - "Province", province) - .copyWith( - hintStyle: const TextStyle( - color: Colors.black, - ), - labelStyle: const TextStyle( - color: Colors.black), - )), - const SizedBox( - height: 20, - ), - FormBuilderDropdown( - decoration: normalTextFieldStyle( - "Municipality", "Municipality"), - name: 'municipality', - items: [], - initialValue: widget - .eligibityCert - .examAddress - ?.cityMunicipality - ?.description == - null - ? 'region' - : 'municipality', - ), - ], - )), - const SizedBox( - height: 20, + decoration: + normalTextFieldStyle("Region*", "Region"), + + name: 'region', + items: state.regions + .map>( + (Region region) { + return DropdownMenuItem( + value: region, + child: Text(region.description!)); + }).toList(), + ), + const SizedBox( + height: 20, + ), + //PROVINCE DROPDOWN + FormBuilderDropdown( + initialValue: null, + name: 'province', + items: state.provinces.isEmpty + ? [] + : state.provinces + .map>( + (Province province) { + return DropdownMenuItem( + value: province, + child: Text( + province.description!)); + }).toList(), + decoration: normalTextFieldStyle( + "Province*", "Province")), + const SizedBox( + height: 20, + ), + FormBuilderDropdown( + decoration: normalTextFieldStyle( + "Municipality*", "Municipality"), + name: 'municipality', + items: state.cityMuns.isEmpty + ? [] + : state.cityMuns.map< + DropdownMenuItem< + CityMunicipality>>( + (CityMunicipality c) { + return DropdownMenuItem( + value: c, + child: Text(c.description!)); + }).toList(), + initialValue: null), + const SizedBox( + height: 20, + ), + ], ), + SizedBox( width: screenWidth, height: 60, @@ -296,6 +266,195 @@ class _EditEligibilityScreenState extends State { ), ); } + //=========================================================================== + if (state is EditOverseasEligibilityState) { + overseas = state.isOverseas; + return Center( + child: Padding( + padding: const EdgeInsets.symmetric( + vertical: 25, horizontal: 18), + child: FormBuilder( + key: formKey, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + //ELIGIBILITIES DROPDOWN + FormBuilderDropdown( + initialValue: null, + items: state.eligibilities + .map>( + (Eligibility eligibility) { + return DropdownMenuItem( + value: eligibility, + child: Text(eligibility.title)); + }).toList(), + name: "eligibility", + decoration: normalTextFieldStyle( + "Eligibility", "") + .copyWith( + hintStyle: const TextStyle( + color: Colors.black, + ), + labelStyle: + const TextStyle(color: Colors.black)), + ), + const SizedBox( + height: 20, + ), + + SizedBox( + width: screenWidth, + child: Row( + children: [ + //LICENSE NUMBER + Flexible( + flex: 1, + child: FormBuilderTextField( + name: 'license number', + initialValue: + widget.eligibityCert.licenseNumber, + decoration: normalTextFieldStyle( + "license number", "license number"), + ), + ), + const SizedBox( + width: 12, + ), + //RATING + Flexible( + flex: 1, + child: FormBuilderTextField( + name: 'rating', + initialValue: widget.eligibityCert.rating + .toString(), + decoration: normalTextFieldStyle( + 'rating', 'rating'), + ), + ), + ], + ), + ), + const SizedBox( + height: 20, + ), + SizedBox( + width: screenWidth, + child: Row( + children: [ + //EXAM DATE + Flexible( + flex: 1, + child: DateTimePicker( + firstDate: DateTime(2000), + lastDate: DateTime(2100), + decoration: normalTextFieldStyle( + "Exam date", "Exam date"), + initialValue: widget + .eligibityCert.examDate == + null + ? '' + : dteFormat2.format( + widget.eligibityCert.examDate!), + )), + const SizedBox( + width: 12, + ), + //VALIDITY DATE + Flexible( + flex: 1, + child: DateTimePicker( + firstDate: DateTime(2000), + lastDate: DateTime(2100), + decoration: normalTextFieldStyle( + "Validity date", "Validity date"), + initialValue: + widget.eligibityCert.validityDate == + null + ? '' + : dteFormat2.format(widget + .eligibityCert.validityDate!), + ), + ), + ], + ), + ), + const SizedBox( + height: 20, + ), + Text( + "Placement of Examination/Confinement", + style: Theme.of(context) + .textTheme + .displaySmall! + .copyWith(fontSize: blockSizeVertical * 2), + ), + const SizedBox( + height: 12, + ), + //OVERSEAS ADDRESS SWITCH + FormBuilderSwitch( + initialValue: overseas, + activeColor: second, + onChanged: (value) { + EligibityCert newEligibility = + state.eligibityCert; + newEligibility.overseas = value!; + // countryKey.currentState?.fields['country'] + // ?.reset(); + + + context.read().add( + EditEligibilityNotOverseas( + eligibityCert: newEligibility)); + }, + decoration: normalTextFieldStyle("", ''), + name: 'overseas', + title: const Text("Overseas Address?"), + ), + const SizedBox( + height: 20, + ), + + FormBuilderDropdown( + key: countryKey, + onChanged: (Country? country) { + + selectedCountry = country; + }, + // initialValue:state.eligibityCert.examAddress!.cityMunicipality!.province!.description!, + initialValue:selectedCountry, + decoration: + normalTextFieldStyle("Country*", "country"), + name: 'country', + items: state.countries.isNotEmpty + ? state.countries + .map>( + (Country country) { + return DropdownMenuItem( + value: country, + child: Text(country.name!)); + }).toList() + : []), + + SizedBox( + width: screenWidth, + height: 60, + child: ElevatedButton( + style: mainBtnStyle( + primary, Colors.transparent, second), + onPressed: () {}, + child: const Text(submit)), + ), + const SizedBox( + height: 20, + ), + ]), + ), + ), + ); + } + return Container(); }, ); diff --git a/lib/screens/profile/components/eligibility_screen.dart b/lib/screens/profile/components/eligibility_screen.dart index 115fd5d..257387d 100644 --- a/lib/screens/profile/components/eligibility_screen.dart +++ b/lib/screens/profile/components/eligibility_screen.dart @@ -36,9 +36,19 @@ class EligibiltyScreen extends StatelessWidget { return ProgressHUD( child: BlocConsumer( listener: (context, state) { - if (state is EditEligibilityState) { + if(state is ProfileLoading){ + final progress = ProgressHUD.of(context); + progress!.showWithText("Loading"); + } + if (state is EditNotOverseasEligibilityState) { final progress = ProgressHUD.of(context); progress!.dismiss(); + }if (state is EditOverseasEligibilityState) { + final progress = ProgressHUD.of(context); + progress!.dismiss(); + }if(state is EligibilityLoaded){ + final progress = ProgressHUD.of(context); + progress!.dismiss(); } // TODO: implement listener }, @@ -94,7 +104,7 @@ class EligibiltyScreen extends StatelessWidget { height: 3, ), Text( - " : ${state.eligibilities[index].rating}.", + "Rating : ${state.eligibilities[index].rating}.", style: Theme.of(context) .textTheme .titleSmall) @@ -112,15 +122,35 @@ class EligibiltyScreen extends StatelessWidget { "Confirm Delete?"); } if (value == 1) { + EligibityCert eligibityCert = + state.eligibilities[index]; + bool overseas = eligibityCert + .examAddress! + .country! + .id + .toString() == + '175' + ? false + : true; + eligibityCert.overseas = + overseas; final progress = ProgressHUD.of(context); + eligibityCert.overseas = + overseas; progress! .showWithText("Loading..."); - context.read().add( - EditEligibility( - eligibityCert: - state.eligibilities[ - index])); + if (eligibityCert.overseas!) { + context.read().add( + EditEligibilityOverseas( + eligibityCert: + eligibityCert)); + } else { + context.read().add( + EditEligibilityNotOverseas( + eligibityCert: + eligibityCert)); + } } }, menuItems: [ @@ -153,9 +183,12 @@ class EligibiltyScreen extends StatelessWidget { ); }); } - if (state is EditEligibilityState) { + if (state is EditNotOverseasEligibilityState) { return EditEligibilityScreen( eligibityCert: state.eligibityCert); + }if(state is EditOverseasEligibilityState){ + return EditEligibilityScreen( + eligibityCert: state.eligibityCert); } return Container(); }, diff --git a/lib/screens/unit2/login/login.dart b/lib/screens/unit2/login/login.dart index cdce5fd..045bcc6 100644 --- a/lib/screens/unit2/login/login.dart +++ b/lib/screens/unit2/login/login.dart @@ -230,8 +230,8 @@ class _UniT2LoginState extends State { BlocProvider.of(context) .add(UserLogin( - username: "rodolfobacuinjr", - password: "nav071394", + username: "rjvincentlopeplopez", + password: "shesthequ33n", // username: _formKey // .currentState! // .value['username'], diff --git a/lib/utils/location_utilities.dart b/lib/utils/location_utilities.dart index 6d19119..a5678f6 100644 --- a/lib/utils/location_utilities.dart +++ b/lib/utils/location_utilities.dart @@ -1,5 +1,6 @@ import 'dart:convert'; +import 'package:unit2/model/location/city.dart'; import 'package:unit2/model/location/country.dart'; import 'package:http/http.dart' as http; import 'package:unit2/model/location/provinces.dart'; @@ -80,4 +81,22 @@ Future>getRegions()async{ } return provinces; } + + Future>getCities({required String code})async{ + List cities = []; + String path = Url.instance.getCities()+code; + try{ + http.Response response = await Request.instance.getRequest(path: path, param: {},headers: headers); + Map data = jsonDecode(response.body); + if(data['data'] != null){ + data['data'].forEach((var city){ + CityMunicipality cityMun = CityMunicipality.fromJson(city); + cities.add(cityMun); + }); + } + }catch(e){ + throw(e.toString()); + } + return cities; + } } \ No newline at end of file diff --git a/lib/utils/profile_utilities.dart b/lib/utils/profile_utilities.dart index e13e625..68ef45b 100644 --- a/lib/utils/profile_utilities.dart +++ b/lib/utils/profile_utilities.dart @@ -4,15 +4,15 @@ import 'dart:convert'; import 'package:unit2/model/location/country.dart'; import 'package:http/http.dart' as http; import 'package:unit2/model/location/region.dart'; -import 'package:unit2/model/utils/eligibilities_choices.dart'; +import 'package:unit2/model/utils/eligibility.dart'; import 'package:unit2/utils/request.dart'; import 'package:unit2/utils/urls.dart'; class ProfileUtilities { static final ProfileUtilities _instance = ProfileUtilities(); static ProfileUtilities get instance => _instance; - Future>getEligibilities()async{ - List eligibilities=[]; + Future>getEligibilities()async{ + List eligibilities=[]; String path = Url.instance.eligibilities(); Map headers = { @@ -24,7 +24,7 @@ class ProfileUtilities { Map data = jsonDecode(response.body); if(data['data'] != null){ data['data'].forEach((var eligibility){ - EligibilityList newEligibilities = EligibilityList.fromJson(eligibility); + Eligibility newEligibilities = Eligibility.fromJson(eligibility); eligibilities.add(newEligibilities); }); } diff --git a/lib/utils/urls.dart b/lib/utils/urls.dart index 5a33754..f79b971 100644 --- a/lib/utils/urls.dart +++ b/lib/utils/urls.dart @@ -29,4 +29,7 @@ String eligibilities(){ String getProvinces(){ return "api/web_app/location/province/"; } + String getCities(){ + return "/api/web_app/location/citymun/"; + } } \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 3f8450d..b06be86 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -971,5 +971,5 @@ packages: source: hosted version: "6.2.2" sdks: - dart: ">=2.19.0 <4.0.0" + dart: ">=2.19.0 <3.0.0" flutter: ">=3.3.0"