Organization membership refactor and created its own bloc

feature/passo/PASSO-#1-Sync-data-from-device-to-postgre-and-vice-versa
PGAN-MIS 2023-03-06 13:29:38 +08:00
parent 4151038ff3
commit acc74653d1
13 changed files with 496 additions and 131 deletions

View File

@ -0,0 +1,24 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/sevices/profile/orgmembership_services.dart';
import '../../model/profile/other_information/organization_memberships.dart';
part 'organization_membership_event.dart';
part 'organization_membership_state.dart';
class OrganizationMembershipBloc extends Bloc<OrganizationMembershipEvent, OrganizationMembershipState> {
OrganizationMembershipBloc() : super(OrganizationMembershipInitial()) {
List<OrganizationMembership> organizationMemberships=[];
on<GetOrganizationMembership>((event, emit) async{
emit(OrgmembershipLoadingState());
try{
List<OrganizationMembership> orgs = await OrganizationMembershipServices.instance.getOrgMemberships(event.profileId, event.token);
organizationMemberships = orgs;
emit(OrganizationMembershipLoaded(orgMemberships: organizationMemberships));
}catch(e){
OrganizationMembershipErrorState(message: e.toString());
}
});
}
}

View File

@ -0,0 +1,16 @@
part of 'organization_membership_bloc.dart';
abstract class OrganizationMembershipEvent extends Equatable {
const OrganizationMembershipEvent();
@override
List<Object> get props => [];
}
class GetOrganizationMembership extends OrganizationMembershipEvent{
final int profileId;
final String token;
const GetOrganizationMembership({required this.profileId, required this.token});
@override
List<Object> get props => [profileId,token];
}

View File

@ -0,0 +1,28 @@
part of 'organization_membership_bloc.dart';
abstract class OrganizationMembershipState extends Equatable {
const OrganizationMembershipState();
@override
List<Object> get props => [];
}
class OrganizationMembershipInitial extends OrganizationMembershipState {}
class OrganizationMembershipLoaded extends OrganizationMembershipState{
final List<OrganizationMembership>orgMemberships;
const OrganizationMembershipLoaded({required this.orgMemberships});
@override
List<Object> get props => [orgMemberships];
}
class OrganizationMembershipErrorState extends OrganizationMembershipState{
final String message;
const OrganizationMembershipErrorState({required this.message});
@override
List<Object> get props => [message];
}
class OrgmembershipLoadingState extends OrganizationMembershipState{
}

View File

@ -0,0 +1,24 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/sevices/skillshobbies_services.dart';
import '../../model/profile/other_information/skills_and_hobbies.dart';
part 'hoobies_event.dart';
part 'hoobies_state.dart';
class HoobiesBloc extends Bloc<HobbiesEvent, HobbiesState> {
HoobiesBloc() : super(HoobiesInitial()) {
List<SkillsHobbies> skillsAndHobbies = [];
on<GetSkillsHobbies>((event, emit)async {
emit(HobbiesLoadingState());
try{
List<SkillsHobbies> hobbies = await SkillsHobbiesServices.instance.getSkillsHobbies(event.profileId, event.token);
skillsAndHobbies = hobbies;
emit(HobbiesLoadedState(skillsAndHobbies: skillsAndHobbies));
}catch(e){
emit(HobbiesErrorState(message: e.toString()));
}
});
}
}

View File

@ -0,0 +1,16 @@
part of 'hoobies_bloc.dart';
abstract class HobbiesEvent extends Equatable {
const HobbiesEvent();
@override
List<Object> get props => [];
}
class GetSkillsHobbies extends HobbiesEvent{
final int profileId;
final String token;
const GetSkillsHobbies({required this.profileId, required this.token});
@override
List<Object> get props => [profileId,token];
}

View File

@ -0,0 +1,29 @@
part of 'hoobies_bloc.dart';
abstract class HobbiesState extends Equatable {
const HobbiesState();
@override
List<Object> get props => [];
}
class HoobiesInitial extends HobbiesState {}
class HobbiesLoadedState extends HobbiesState{
final List<SkillsHobbies> skillsAndHobbies;
const HobbiesLoadedState({required this.skillsAndHobbies});
@override
List<Object> get props => [skillsAndHobbies];
}
class HobbiesErrorState extends HobbiesState{
final String message;
const HobbiesErrorState({required this.message});
@override
List<Object> get props => [message];
}
class HobbiesLoadingState extends HobbiesState{
}

View File

@ -15,7 +15,6 @@ import 'package:unit2/widgets/empty_data.dart';
import 'package:unit2/widgets/error_state.dart'; import 'package:unit2/widgets/error_state.dart';
class EducationScreen extends StatelessWidget { class EducationScreen extends StatelessWidget {
const EducationScreen({super.key}); const EducationScreen({super.key});
@override @override
@ -31,8 +30,7 @@ class EducationScreen extends StatelessWidget {
body: ProgressHUD( body: ProgressHUD(
padding: const EdgeInsets.all(24), padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87, backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle( indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
color: Colors.white),
child: BlocBuilder<UserBloc, UserState>( child: BlocBuilder<UserBloc, UserState>(
builder: (context, state) { builder: (context, state) {
if (state is UserLoggedIn) { if (state is UserLoggedIn) {
@ -47,7 +45,8 @@ class EducationScreen extends StatelessWidget {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait..."); progress!.showWithText("Please wait...");
} }
if(state is EducationalBackgroundLoadedState || state is EducationalBackgroundErrorState){ if (state is EducationalBackgroundLoadedState ||
state is EducationalBackgroundErrorState) {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress!.dismiss(); progress!.dismiss();
} }
@ -59,13 +58,15 @@ class EducationScreen extends StatelessWidget {
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
vertical: 8, horizontal: 10), vertical: 8, horizontal: 10),
itemCount: state.educationalBackground.length, itemCount: state.educationalBackground.length,
itemBuilder: (BuildContext context, int index) { itemBuilder:
(BuildContext context, int index) {
String level = state String level = state
.educationalBackground[index] .educationalBackground[index]
.education! .education!
.level!; .level!;
String periodFrom = state String periodFrom = state
.educationalBackground[index].periodFrom!; .educationalBackground[index]
.periodFrom!;
String periodTo = state String periodTo = state
.educationalBackground[index].periodTo!; .educationalBackground[index].periodTo!;
String? program = state String? program = state
@ -97,7 +98,8 @@ class EducationScreen extends StatelessWidget {
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.start, MainAxisAlignment.start,
crossAxisAlignment: crossAxisAlignment:
CrossAxisAlignment.start, CrossAxisAlignment
.start,
children: [ children: [
Row( Row(
children: [ children: [
@ -115,8 +117,8 @@ class EducationScreen extends StatelessWidget {
)), )),
Text( Text(
"$periodFrom - ", "$periodFrom - ",
style: style: Theme.of(
Theme.of(context) context)
.textTheme .textTheme
.bodyMedium, .bodyMedium,
), ),
@ -135,7 +137,8 @@ class EducationScreen extends StatelessWidget {
padding: padding:
const EdgeInsets const EdgeInsets
.only(top: 8), .only(top: 8),
child: honors.isNotEmpty child: honors
.isNotEmpty
? Column( ? Column(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment MainAxisAlignment
@ -152,8 +155,7 @@ class EducationScreen extends StatelessWidget {
), ),
Column( Column(
children: honors children: honors
.map((Honor .map((Honor honor) =>
honor) =>
Text(" - ${honor.name!}")) Text(" - ${honor.name!}"))
.toList(), .toList(),
), ),
@ -198,8 +200,10 @@ class EducationScreen extends StatelessWidget {
message: message:
"You don't have any Educational Background added. Please click + to add."); "You don't have any Educational Background added. Please click + to add.");
} }
}if(state is EducationalBackgroundErrorState){ }
return SomethingWentWrong(message: state.message, onpressed: (){}); if (state is EducationalBackgroundErrorState) {
return SomethingWentWrong(
message: state.message, onpressed: () {});
} }
return Container(); return Container();
}, },

View File

@ -1,4 +1,10 @@
import 'package:flutter/material.dart'; 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:unit2/bloc/bloc/organization_membership_bloc.dart';
import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/user/user_bloc.dart';
import 'package:unit2/model/profile/other_information/organization_memberships.dart'; import 'package:unit2/model/profile/other_information/organization_memberships.dart';
import 'package:unit2/theme-data.dart/box_shadow.dart'; import 'package:unit2/theme-data.dart/box_shadow.dart';
import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/theme-data.dart/colors.dart';
@ -9,8 +15,7 @@ import 'package:unit2/widgets/empty_data.dart';
import '../../../../utils/global.dart'; import '../../../../utils/global.dart';
class OrgMembershipsScreen extends StatelessWidget { class OrgMembershipsScreen extends StatelessWidget {
final List<OrganizationMembership> orgMemberships; const OrgMembershipsScreen({super.key});
const OrgMembershipsScreen({super.key, required this.orgMemberships});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -21,42 +26,104 @@ class OrgMembershipsScreen extends StatelessWidget {
centerTitle: true, centerTitle: true,
actions: [AddLeading(onPressed: () {})], actions: [AddLeading(onPressed: () {})],
), ),
body: orgMemberships.isNotEmpty? ListView.builder( body: ProgressHUD(
itemCount: orgMemberships.length, padding: const EdgeInsets.all(24),
padding: const EdgeInsets.symmetric(vertical: 8,horizontal: 10), backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocBuilder<UserBloc, UserState>(
builder: (context, state) {
if (state is UserLoggedIn) {
return BlocBuilder<ProfileBloc, ProfileState>(
builder: (context, state) {
if (state is ProfileLoaded) {
return BlocConsumer<OrganizationMembershipBloc,
OrganizationMembershipState>(
listener: (context, state) {
if(state is OrgmembershipLoadingState){
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if(state is OrganizationMembershipLoaded || state is OrganizationMembershipErrorState){
final progress = ProgressHUD.of(context);
progress!.dismiss();
}
},
builder: (context, state) {
if (state is OrganizationMembershipLoaded) {
return ListView.builder(
itemCount: state.orgMemberships.length,
padding: const EdgeInsets.symmetric(
vertical: 8, horizontal: 10),
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
String entity = String entity = state.orgMemberships[index]
orgMemberships[index].agency!.privateEntity == false .agency!
.privateEntity ==
false
? governmentText.toUpperCase() ? governmentText.toUpperCase()
: privateText.toUpperCase(); : privateText.toUpperCase();
String agencyName = orgMemberships[index].agency!.name!; String agencyName =
state.orgMemberships[index].agency!.name!;
return Column( return Column(
children: [ children: [
Container( Container(
width: screenWidth, width: screenWidth,
decoration: box1(), decoration: box1(),
padding: padding: const EdgeInsets.symmetric(
const EdgeInsets.symmetric(horizontal: 12, vertical: 8), horizontal: 12, vertical: 8),
child: Row(children: [ child: Row(children: [
Expanded( Expanded(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment:
crossAxisAlignment: CrossAxisAlignment.start, MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [ children: [
Text(
Text(agencyName,style: Theme.of(context).textTheme.titleMedium!.copyWith(fontWeight: FontWeight.w500),), agencyName,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
fontWeight:
FontWeight.w500),
),
const Divider(), const Divider(),
Text(entity,style: Theme.of(context).textTheme.labelLarge,), Text(
entity,
style: Theme.of(context)
.textTheme
.labelLarge,
),
], ],
)), )),
IconButton( IconButton(
onPressed: () {}, icon: const Icon(Icons.more_vert,color: Colors.grey,)) onPressed: () {},
icon: const Icon(
Icons.more_vert,
color: Colors.grey,
))
]), ]),
), ),
const SizedBox(height: 5,), const SizedBox(
height: 5,
),
], ],
); );
}):const EmptyData(message: "You don't have any Organization Membership added. Please click + to add."), });
}
return Container();
},
); );
} }
return Container();
},
);
} }
return Container();
},
),
));
}
}
// const EmptyData(message: "You don't have any Organization Membership added. Please click + to add."),

View File

@ -1,6 +1,12 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart'; import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/placeholder.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';
import 'package:unit2/bloc/hobbies/hoobies_bloc.dart';
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/model/profile/other_information/skills_and_hobbies.dart';
import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/utils/global.dart'; import 'package:unit2/utils/global.dart';
@ -9,19 +15,41 @@ import 'package:unit2/widgets/Leadings/add_leading.dart';
import 'package:unit2/widgets/empty_data.dart'; import 'package:unit2/widgets/empty_data.dart';
class SkillHobbiesScreen extends StatelessWidget { class SkillHobbiesScreen extends StatelessWidget {
final List<SkillsHobbies>skillsHobbies; const SkillHobbiesScreen({super.key});
const SkillHobbiesScreen({super.key,required this.skillsHobbies});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(title: const Text(skillAndHobbiesTitle), appBar: AppBar(
title: const Text(skillAndHobbiesTitle),
backgroundColor: primary, backgroundColor: primary,
centerTitle: true, centerTitle: true,
actions: [AddLeading(onPressed: () {})], actions: [AddLeading(onPressed: () {})],
), ),
body: skillsHobbies.isNotEmpty? Padding( body: ProgressHUD(
padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocBuilder<UserBloc, UserState>(
builder: (context, state) {
if (state is UserLoggedIn) {
return BlocBuilder<ProfileBloc, ProfileState>(
builder: (context, state) {
if (state is ProfileLoaded) {
return BlocConsumer<HoobiesBloc, HobbiesState>(
listener: (context, state) {
if (state is HobbiesLoadingState) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}if(state is HobbiesLoadedState || state is HobbiesErrorState){
final progress = ProgressHUD.of(context);
progress!.dismiss();
}
},
builder: (context, state) {
if (state is HobbiesLoadedState) {
if (state.skillsAndHobbies.isNotEmpty) {
return Padding(
padding: const EdgeInsets.all(24), padding: const EdgeInsets.all(24),
child: Wrap( child: Wrap(
spacing: 8, spacing: 8,
@ -29,9 +57,11 @@ class SkillHobbiesScreen extends StatelessWidget {
alignment: WrapAlignment.start, alignment: WrapAlignment.start,
clipBehavior: Clip.none, clipBehavior: Clip.none,
verticalDirection: VerticalDirection.up, verticalDirection: VerticalDirection.up,
crossAxisAlignment: WrapCrossAlignment.start, crossAxisAlignment:
WrapCrossAlignment.start,
direction: Axis.horizontal, direction: Axis.horizontal,
children:skillsHobbies.map((SkillsHobbies sh){ children:
state.skillsAndHobbies.map((SkillsHobbies sh) {
return FittedBox( return FittedBox(
child: Row( child: Row(
children: [ children: [
@ -42,10 +72,25 @@ class SkillHobbiesScreen extends StatelessWidget {
], ],
), ),
); );
}).toList() }).toList()),
);
), } else {
):const EmptyData(message: "You don't have any Skills and Hobbies added. Please click + to add"), const EmptyData(
message:
"You don't have any Skills and Hobbies added. Please click + to add");
}
}
return Container();
},
); );
} }
return Container();
},
);
}
return Container();
},
),
));
}
} }

View File

@ -8,8 +8,10 @@ import 'package:fluttericon/elusive_icons.dart';
import 'package:fluttericon/entypo_icons.dart'; import 'package:fluttericon/entypo_icons.dart';
import 'package:fluttericon/font_awesome5_icons.dart'; import 'package:fluttericon/font_awesome5_icons.dart';
import 'package:fluttericon/modern_pictograms_icons.dart'; import 'package:fluttericon/modern_pictograms_icons.dart';
import 'package:unit2/bloc/bloc/organization_membership_bloc.dart';
import 'package:unit2/bloc/education/education_bloc.dart'; import 'package:unit2/bloc/education/education_bloc.dart';
import 'package:unit2/bloc/eligibility/eligibility_bloc.dart'; import 'package:unit2/bloc/eligibility/eligibility_bloc.dart';
import 'package:unit2/bloc/hobbies/hoobies_bloc.dart';
import 'package:unit2/bloc/learningDevelopment/learning_development_bloc.dart'; import 'package:unit2/bloc/learningDevelopment/learning_development_bloc.dart';
import 'package:unit2/bloc/profile/profile_bloc.dart'; import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/references/references_bloc.dart'; import 'package:unit2/bloc/references/references_bloc.dart';
@ -153,9 +155,7 @@ class _ProfileInfoState extends State<ProfileInfo> {
MainMenu( MainMenu(
icon: Elusive.group, icon: Elusive.group,
title: "Family", title: "Family",
onTap: () { onTap: () {},
},
), ),
const Divider(), const Divider(),
MainMenu( MainMenu(
@ -165,7 +165,9 @@ class _ProfileInfoState extends State<ProfileInfo> {
Navigator.push(context, MaterialPageRoute( Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {
return BlocProvider( return BlocProvider(
create: (context) => EducationBloc()..add(GetEducationalBackground(profileId: profileId!, token: token!)), create: (context) => EducationBloc()
..add(GetEducationalBackground(
profileId: profileId!, token: token!)),
child: const EducationScreen(), child: const EducationScreen(),
); );
})); }));
@ -179,7 +181,9 @@ class _ProfileInfoState extends State<ProfileInfo> {
Navigator.push(context, MaterialPageRoute( Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {
return BlocProvider( return BlocProvider(
create: (context) => EligibilityBloc()..add(GetEligibilities(profileId: profileId!, token: token!)), create: (context) => EligibilityBloc()
..add(GetEligibilities(
profileId: profileId!, token: token!)),
child: const EligibiltyScreen(), child: const EligibiltyScreen(),
); );
})); }));
@ -193,11 +197,12 @@ class _ProfileInfoState extends State<ProfileInfo> {
Navigator.push(context, MaterialPageRoute( Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {
return BlocProvider( return BlocProvider(
create: (context) => WorkHistoryBloc()..add(GetWorkHistories(profileId: profileId!, token: token!)), create: (context) => WorkHistoryBloc()
..add(GetWorkHistories(
profileId: profileId!, token: token!)),
child: const WorkHistoryScreen(), child: const WorkHistoryScreen(),
); );
})); }));
}, },
), ),
const Divider(), const Divider(),
@ -208,7 +213,9 @@ class _ProfileInfoState extends State<ProfileInfo> {
Navigator.push(context, MaterialPageRoute( Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {
return BlocProvider( return BlocProvider(
create: (context) => VoluntaryWorkBloc()..add(GetVoluntarWorks(profileId: profileId!, token: token!)), create: (context) => VoluntaryWorkBloc()
..add(GetVoluntarWorks(
profileId: profileId!, token: token!)),
child: const VolunataryWorkScreen(), child: const VolunataryWorkScreen(),
); );
})); }));
@ -222,7 +229,9 @@ class _ProfileInfoState extends State<ProfileInfo> {
Navigator.push(context, MaterialPageRoute( Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {
return BlocProvider( return BlocProvider(
create: (context) => LearningDevelopmentBloc()..add(GetLearningDevelopments(profileId: profileId!, token: token!)), create: (context) => LearningDevelopmentBloc()
..add(GetLearningDevelopments(
profileId: profileId!, token: token!)),
child: const LearningAndDevelopmentScreen(), child: const LearningAndDevelopmentScreen(),
); );
})); }));
@ -236,7 +245,9 @@ class _ProfileInfoState extends State<ProfileInfo> {
Navigator.push(context, MaterialPageRoute( Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {
return BlocProvider( return BlocProvider(
create: (context) => ReferencesBloc()..add(GetReferences(profileId: profileId!, token: token!)), create: (context) => ReferencesBloc()
..add(GetReferences(
profileId: profileId!, token: token!)),
child: const ReferencesScreen(), child: const ReferencesScreen(),
); );
})); }));
@ -260,24 +271,33 @@ class _ProfileInfoState extends State<ProfileInfo> {
subMenu( subMenu(
Icons.fitness_center, "Skills & Hobbies", Icons.fitness_center, "Skills & Hobbies",
() { () {
// Navigator.push(context, MaterialPageRoute( Navigator.push(context, MaterialPageRoute(
// builder: (BuildContext context) { builder: (BuildContext context) {
// return SkillHobbiesScreen( return BlocProvider(
// skillsHobbies: state.profileInformation create: (context) => HoobiesBloc()
// .otherInformation.skillsAndHobbies); ..add(GetSkillsHobbies(
// })); profileId: profileId!,
token: token!)),
child: const SkillHobbiesScreen(),
);
}));
}), }),
subMenu(FontAwesome5.certificate, subMenu(FontAwesome5.certificate,
"Organization Memberships", () { "Organization Memberships", () {
// Navigator.push(context, MaterialPageRoute( Navigator.push(context, MaterialPageRoute(
// builder: (BuildContext context) { builder: (BuildContext context) {
// return OrgMembershipsScreen( return BlocProvider(
// orgMemberships: state.profileInformation create: (context) => OrganizationMembershipBloc()
// .otherInformation.orgMemberships); ..add(GetOrganizationMembership(
// })); profileId: profileId!,
token: token!)),
child: const OrgMembershipsScreen(),
);
}));
}), }),
subMenu(Entypo.doc_text, subMenu(Entypo.doc_text,
"Non-Academic Recognitions", () { "Non-Academic Recognitions", () {
// Navigator.push(context, MaterialPageRoute( // Navigator.push(context, MaterialPageRoute(
// builder: (BuildContext context) { // builder: (BuildContext context) {
// return NonAcademicRecognitionScreen( // return NonAcademicRecognitionScreen(

View File

@ -0,0 +1,42 @@
import 'dart:convert';
import 'package:unit2/utils/request.dart';
import '../../model/profile/other_information/organization_memberships.dart';
import 'package:http/http.dart' as http;
import '../../utils/urls.dart';
class OrganizationMembershipServices {
static final OrganizationMembershipServices _instance =
OrganizationMembershipServices();
static OrganizationMembershipServices get instance => _instance;
Future<List<OrganizationMembership>> getOrgMemberships(
int profileId, String token) async {
List<OrganizationMembership> orgMemberships = [];
String authToken = "Token $token";
String path = "${Url.instance.getOrgMemberShips()}$profileId/";
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': authToken
};
try {
http.Response response = await Request.instance
.getRequest(path: path, param: {}, headers: headers);
if (response.statusCode == 200) {
Map data = jsonDecode(response.body);
if (data['data'] != null) {
data['data'].forEach((var org) {
OrganizationMembership organizationMembership =
OrganizationMembership.fromJson(org);
orgMemberships.add(organizationMembership);
});
}
}
} catch (e) {
throw e.toString();
}
return orgMemberships;
}
}

View File

@ -0,0 +1,40 @@
import 'dart:convert';
import 'package:unit2/utils/request.dart';
import '../model/profile/other_information/skills_and_hobbies.dart';
import '../utils/urls.dart';
import 'package:http/http.dart' as http;
class SkillsHobbiesServices{
static final SkillsHobbiesServices _instance = SkillsHobbiesServices();
static SkillsHobbiesServices get instance => _instance;
Future<List<SkillsHobbies>> getSkillsHobbies(int profileId, String token)async{
List<SkillsHobbies> skillsAndHobbies = [];
String authToken = "Token $token";
String path = "${Url.instance.getSkillsHobbies()}$profileId/";
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': authToken
};
try{
http.Response response = await Request.instance.getRequest(path: path,param: {},headers: headers);
if(response.statusCode == 200){
Map data = jsonDecode(response.body);
if(data['data']['skill_hobby'] != null){
data['data']['skill_hobby'].forEach((var hobby){
SkillsHobbies skillsHobby = SkillsHobbies.fromJson(hobby);
skillsAndHobbies.add(skillsHobby);
});
}
}
}catch(e){
throw e.toString();
}
return skillsAndHobbies;
}
}

View File

@ -67,6 +67,16 @@ String getRefences(){
String getVoluntaryWorks(){ String getVoluntaryWorks(){
return "/api/jobnet_app/profile/pds/voluntary_work/"; return "/api/jobnet_app/profile/pds/voluntary_work/";
} }
//// skills hobbies
String getSkillsHobbies(){
return "/api/jobnet_app/profile/pds/other/skill_hobby/";
}
//// orgmemberships
String getOrgMemberShips(){
return "/api/jobnet_app/profile/pds/other/org_membership/";
}
// location utils path // location utils path
String getCounties(){ String getCounties(){
return "/api/jobnet_app/countries/"; return "/api/jobnet_app/countries/";