integrated work history API
parent
40ff288ddd
commit
0185005ef1
|
@ -0,0 +1,145 @@
|
||||||
|
// To parse this JSON data, do
|
||||||
|
//
|
||||||
|
// final educationalBackground = educationalBackgroundFromJson(jsonString);
|
||||||
|
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
EducationalBackground educationalBackgroundFromJson(String str) => EducationalBackground.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String educationalBackgroundToJson(EducationalBackground data) => json.encode(data.toJson());
|
||||||
|
|
||||||
|
class EducationalBackground {
|
||||||
|
EducationalBackground({
|
||||||
|
this.id,
|
||||||
|
this.honors,
|
||||||
|
this.education,
|
||||||
|
this.periodTo,
|
||||||
|
this.attachments,
|
||||||
|
this.periodFrom,
|
||||||
|
this.unitsEarned,
|
||||||
|
this.yearGraduated,
|
||||||
|
});
|
||||||
|
|
||||||
|
final int? id;
|
||||||
|
final List<Honor>? honors;
|
||||||
|
final Education? education;
|
||||||
|
final String? periodTo;
|
||||||
|
final dynamic attachments;
|
||||||
|
final String? periodFrom;
|
||||||
|
final dynamic unitsEarned;
|
||||||
|
final String? yearGraduated;
|
||||||
|
|
||||||
|
factory EducationalBackground.fromJson(Map<String, dynamic> json) => EducationalBackground(
|
||||||
|
id: json["id"],
|
||||||
|
honors: json["honors"] == null ? [] : List<Honor>.from(json["honors"]!.map((x) => Honor.fromJson(x))),
|
||||||
|
education: json["education"] == null ? null : Education.fromJson(json["education"]),
|
||||||
|
periodTo: json["period_to"],
|
||||||
|
attachments: json["attachments"],
|
||||||
|
periodFrom: json["period_from"],
|
||||||
|
unitsEarned: json["units_earned"],
|
||||||
|
yearGraduated: json["year_graduated"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"id": id,
|
||||||
|
"honors": honors == null ? [] : List<dynamic>.from(honors!.map((x) => x.toJson())),
|
||||||
|
"education": education?.toJson(),
|
||||||
|
"period_to": periodTo,
|
||||||
|
"attachments": attachments,
|
||||||
|
"period_from": periodFrom,
|
||||||
|
"units_earned": unitsEarned,
|
||||||
|
"year_graduated": yearGraduated,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class Education {
|
||||||
|
Education({
|
||||||
|
this.id,
|
||||||
|
this.level,
|
||||||
|
this.course,
|
||||||
|
this.school,
|
||||||
|
});
|
||||||
|
|
||||||
|
final int? id;
|
||||||
|
final String? level;
|
||||||
|
final Course? course;
|
||||||
|
final School? school;
|
||||||
|
|
||||||
|
factory Education.fromJson(Map<String, dynamic> json) => Education(
|
||||||
|
id: json["id"],
|
||||||
|
level: json["level"],
|
||||||
|
course: json["course"] == null ? null : Course.fromJson(json["course"]),
|
||||||
|
school: json["school"] == null ? null : School.fromJson(json["school"]),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"id": id,
|
||||||
|
"level": level,
|
||||||
|
"course": course?.toJson(),
|
||||||
|
"school": school?.toJson(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class Course {
|
||||||
|
Course({
|
||||||
|
this.id,
|
||||||
|
this.program,
|
||||||
|
});
|
||||||
|
|
||||||
|
final int? id;
|
||||||
|
final String? program;
|
||||||
|
|
||||||
|
factory Course.fromJson(Map<String, dynamic> json) => Course(
|
||||||
|
id: json["id"],
|
||||||
|
program: json["program"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"id": id,
|
||||||
|
"program": program,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class School {
|
||||||
|
School({
|
||||||
|
this.id,
|
||||||
|
this.name,
|
||||||
|
});
|
||||||
|
|
||||||
|
final int? id;
|
||||||
|
final String? name;
|
||||||
|
|
||||||
|
factory School.fromJson(Map<String, dynamic> json) => School(
|
||||||
|
id: json["id"],
|
||||||
|
name: json["name"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"id": id,
|
||||||
|
"name": name,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class Honor {
|
||||||
|
Honor({
|
||||||
|
this.id,
|
||||||
|
this.name,
|
||||||
|
this.academ,
|
||||||
|
});
|
||||||
|
|
||||||
|
final int? id;
|
||||||
|
final String? name;
|
||||||
|
final bool? academ;
|
||||||
|
|
||||||
|
factory Honor.fromJson(Map<String, dynamic> json) => Honor(
|
||||||
|
id: json["id"],
|
||||||
|
name: json["name"],
|
||||||
|
academ: json["academ"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"id": id,
|
||||||
|
"name": name,
|
||||||
|
"academ": academ,
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,13 +1,17 @@
|
||||||
import 'package:unit2/model/profile/basic_info.dart';
|
import 'package:unit2/model/profile/basic_info.dart';
|
||||||
import 'package:unit2/model/profile/basic_information/primary-information.dart';
|
import 'package:unit2/model/profile/basic_information/primary-information.dart';
|
||||||
|
import 'package:unit2/model/profile/educational_background.dart';
|
||||||
import 'package:unit2/model/profile/eligibility.dart';
|
import 'package:unit2/model/profile/eligibility.dart';
|
||||||
import 'package:unit2/model/profile/learning_development.dart';
|
import 'package:unit2/model/profile/learning_development.dart';
|
||||||
import 'package:unit2/model/profile/references.dart';
|
import 'package:unit2/model/profile/references.dart';
|
||||||
|
import 'package:unit2/model/profile/work_history.dart';
|
||||||
|
|
||||||
class ProfileInformation{
|
class ProfileInformation{
|
||||||
BasicInfo basicInfo;
|
BasicInfo basicInfo;
|
||||||
List<EligibityCert> eligibilities;
|
List<EligibityCert> eligibilities;
|
||||||
List<PersonalReference> references;
|
List<PersonalReference> references;
|
||||||
List<LearningDevelopement> learningsAndDevelopment;
|
List<LearningDevelopement> learningsAndDevelopment;
|
||||||
ProfileInformation({required this.basicInfo,required this.eligibilities,required this.references, required this.learningsAndDevelopment});
|
List<EducationalBackground> educationalBackgrounds;
|
||||||
|
List<WorkHistory>workExperiences;
|
||||||
|
ProfileInformation({required this.workExperiences, required this.basicInfo,required this.eligibilities,required this.references, required this.learningsAndDevelopment,required this.educationalBackgrounds});
|
||||||
}
|
}
|
|
@ -0,0 +1,157 @@
|
||||||
|
// To parse this JSON data, do
|
||||||
|
//
|
||||||
|
// final workHistory = workHistoryFromJson(jsonString);
|
||||||
|
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
WorkHistory workHistoryFromJson(String str) => WorkHistory.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String workHistoryToJson(WorkHistory data) => json.encode(data.toJson());
|
||||||
|
|
||||||
|
class WorkHistory {
|
||||||
|
WorkHistory({
|
||||||
|
this.id,
|
||||||
|
this.agency,
|
||||||
|
this.sgStep,
|
||||||
|
this.toDate,
|
||||||
|
this.position,
|
||||||
|
this.fromDate,
|
||||||
|
// this.attachments,
|
||||||
|
this.salaryGrade,
|
||||||
|
this.monthlySalary,
|
||||||
|
this.appointmentStatus,
|
||||||
|
});
|
||||||
|
|
||||||
|
final int? id;
|
||||||
|
final Agency? agency;
|
||||||
|
final int? sgStep;
|
||||||
|
final DateTime? toDate;
|
||||||
|
final Position? position;
|
||||||
|
final DateTime? fromDate;
|
||||||
|
// final dynamic attachments;
|
||||||
|
final int? salaryGrade;
|
||||||
|
final int? monthlySalary;
|
||||||
|
final String? appointmentStatus;
|
||||||
|
|
||||||
|
factory WorkHistory.fromJson(Map<String, dynamic> json) => WorkHistory(
|
||||||
|
id: json["id"],
|
||||||
|
agency: json["agency"] == null ? null : Agency.fromJson(json["agency"]),
|
||||||
|
sgStep: json["sg_step"],
|
||||||
|
toDate: json["to_date"] == null ? null : DateTime.parse(json["to_date"]),
|
||||||
|
position: json["position"] == null ? null : Position.fromJson(json["position"]),
|
||||||
|
fromDate: json["from_date"] == null ? null : DateTime.parse(json["from_date"]),
|
||||||
|
// attachments: json["attachments"],
|
||||||
|
salaryGrade: json["salary_grade"],
|
||||||
|
monthlySalary: json["monthly_salary"],
|
||||||
|
appointmentStatus: json["appointment_status"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"id": id,
|
||||||
|
"agency": agency?.toJson(),
|
||||||
|
"sg_step": sgStep,
|
||||||
|
"to_date": "${toDate!.year.toString().padLeft(4, '0')}-${toDate!.month.toString().padLeft(2, '0')}-${toDate!.day.toString().padLeft(2, '0')}",
|
||||||
|
"position": position?.toJson(),
|
||||||
|
"from_date": "${fromDate!.year.toString().padLeft(4, '0')}-${fromDate!.month.toString().padLeft(2, '0')}-${fromDate!.day.toString().padLeft(2, '0')}",
|
||||||
|
// "attachments": attachments,
|
||||||
|
"salary_grade": salaryGrade,
|
||||||
|
"monthly_salary": monthlySalary,
|
||||||
|
"appointment_status": appointmentStatus,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
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<String, dynamic> json) => Agency(
|
||||||
|
id: json["id"],
|
||||||
|
name: json["name"],
|
||||||
|
category: json["category"] == null ? null : Category.fromJson(json["category"]),
|
||||||
|
privateEntity: json["private_entity"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> 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<String, dynamic> json) => Category(
|
||||||
|
id: json["id"],
|
||||||
|
name: json["name"],
|
||||||
|
industryClass: json["industry_class"] == null ? null : IndustryClass.fromJson(json["industry_class"]),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> 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 dynamic description;
|
||||||
|
|
||||||
|
factory IndustryClass.fromJson(Map<String, dynamic> json) => IndustryClass(
|
||||||
|
id: json["id"],
|
||||||
|
name: json["name"],
|
||||||
|
description: json["description"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"id": id,
|
||||||
|
"name": name,
|
||||||
|
"description": description,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class Position {
|
||||||
|
Position({
|
||||||
|
this.id,
|
||||||
|
this.title,
|
||||||
|
});
|
||||||
|
|
||||||
|
final int? id;
|
||||||
|
final String? title;
|
||||||
|
|
||||||
|
factory Position.fromJson(Map<String, dynamic> json) => Position(
|
||||||
|
id: json["id"],
|
||||||
|
title: json["title"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"id": id,
|
||||||
|
"title": title,
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/src/widgets/framework.dart';
|
||||||
|
import 'package:flutter/src/widgets/placeholder.dart';
|
||||||
|
import 'package:unit2/model/profile/educational_background.dart';
|
||||||
|
import 'package:unit2/theme-data.dart/colors.dart';
|
||||||
|
|
||||||
|
class EducationScreen extends StatefulWidget {
|
||||||
|
final List<EducationalBackground> educationBackgrounds;
|
||||||
|
const EducationScreen({super.key, required this.educationBackgrounds});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<EducationScreen> createState() => _EducationScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _EducationScreenState extends State<EducationScreen> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text("Educational Background"),
|
||||||
|
centerTitle: true,
|
||||||
|
backgroundColor: primary,
|
||||||
|
),
|
||||||
|
body: ListView.builder(
|
||||||
|
itemCount: widget.educationBackgrounds.length,
|
||||||
|
itemBuilder: (BuildContext context, int index) {
|
||||||
|
String level = widget.educationBackgrounds[index].education!.level!;
|
||||||
|
String periodFrom = widget.educationBackgrounds[index].periodFrom!;
|
||||||
|
String periodTo = widget.educationBackgrounds[index].periodTo!;
|
||||||
|
String? program = widget.educationBackgrounds[index].education!.course == null? null: widget.educationBackgrounds[index].education!.course!.program!;
|
||||||
|
List<Honor>? honors = widget.educationBackgrounds[index].honors!.toList();
|
||||||
|
String school = widget.educationBackgrounds[index].education!.school!.name!;
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey[200],
|
||||||
|
borderRadius:
|
||||||
|
const BorderRadius.all(Radius.circular(12))),
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Column(children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Text(level),
|
||||||
|
Text("$periodFrom $periodTo"),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Text(program??=''),
|
||||||
|
Text(school),
|
||||||
|
Container(
|
||||||
|
child: honors.isNotEmpty? Column(
|
||||||
|
children: honors.map((Honor honor) => Text(honor.name!)).toList(),
|
||||||
|
):const SizedBox()
|
||||||
|
)
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {}, icon: const Icon(Icons.more_vert))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/src/widgets/framework.dart';
|
||||||
|
import 'package:flutter/src/widgets/placeholder.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:unit2/model/profile/work_history.dart';
|
||||||
|
import 'package:unit2/theme-data.dart/colors.dart';
|
||||||
|
|
||||||
|
import '../../../utils/global.dart';
|
||||||
|
|
||||||
|
class WorkHistoryScreen extends StatefulWidget {
|
||||||
|
final List<WorkHistory>workExperiences;
|
||||||
|
const WorkHistoryScreen({super.key,required this.workExperiences});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<WorkHistoryScreen> createState() => _WorkHistoryScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _WorkHistoryScreenState extends State<WorkHistoryScreen> {
|
||||||
|
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(title: const Text("Work History"),backgroundColor: primary,centerTitle: true,),
|
||||||
|
body: ListView.builder(
|
||||||
|
itemCount: widget.workExperiences.length,
|
||||||
|
itemBuilder: (BuildContext context, int index){
|
||||||
|
String position = widget.workExperiences[index].position!.title!;
|
||||||
|
String agency = widget.workExperiences[index].agency!.name!;
|
||||||
|
String from = dteFormat2.format(widget.workExperiences[index].fromDate!);
|
||||||
|
String? to = widget.workExperiences[index].toDate == null? "Present" : dteFormat2.format(widget.workExperiences[index].toDate!);
|
||||||
|
return Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: screenWidth,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey[200],
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(12))),
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12,vertical: 8),
|
||||||
|
child: Row(children: [
|
||||||
|
Expanded(child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(position),
|
||||||
|
Text(agency),
|
||||||
|
Text("$from to $to"),
|
||||||
|
],)),
|
||||||
|
IconButton(onPressed: (){}, icon: const Icon(Icons.more_vert))
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 5,),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,10 +12,12 @@ import 'package:unit2/screens/profile/components/basic_information/citizenship_s
|
||||||
import 'package:unit2/screens/profile/components/basic_information/contact_information.dart';
|
import 'package:unit2/screens/profile/components/basic_information/contact_information.dart';
|
||||||
import 'package:unit2/screens/profile/components/basic_information/identification_information.dart';
|
import 'package:unit2/screens/profile/components/basic_information/identification_information.dart';
|
||||||
import 'package:unit2/screens/profile/components/basic_information/primary_information.dart';
|
import 'package:unit2/screens/profile/components/basic_information/primary_information.dart';
|
||||||
|
import 'package:unit2/screens/profile/components/education_screen.dart';
|
||||||
import 'package:unit2/screens/profile/components/eligibility.dart';
|
import 'package:unit2/screens/profile/components/eligibility.dart';
|
||||||
import 'package:unit2/screens/profile/components/learning_and_development_screen.dart';
|
import 'package:unit2/screens/profile/components/learning_and_development_screen.dart';
|
||||||
import 'package:unit2/screens/profile/components/loading_screen.dart';
|
import 'package:unit2/screens/profile/components/loading_screen.dart';
|
||||||
import 'package:unit2/screens/profile/components/references_screen.dart';
|
import 'package:unit2/screens/profile/components/references_screen.dart';
|
||||||
|
import 'package:unit2/screens/profile/components/work_history_screen.dart';
|
||||||
import 'package:unit2/theme-data.dart/colors.dart';
|
import 'package:unit2/theme-data.dart/colors.dart';
|
||||||
import '../../bloc/user/user_bloc.dart';
|
import '../../bloc/user/user_bloc.dart';
|
||||||
import 'components/main_menu.dart';
|
import 'components/main_menu.dart';
|
||||||
|
@ -116,7 +118,11 @@ class _ProfileInfoState extends State<ProfileInfo> {
|
||||||
MainMenu(
|
MainMenu(
|
||||||
icon: FontAwesome5.graduation_cap,
|
icon: FontAwesome5.graduation_cap,
|
||||||
title: "Education",
|
title: "Education",
|
||||||
onTap: (){},
|
onTap: (){
|
||||||
|
Navigator.push(context, MaterialPageRoute(builder: (BuildContext context){
|
||||||
|
return EducationScreen(educationBackgrounds: state.profileInformation.educationalBackgrounds);
|
||||||
|
}));
|
||||||
|
},
|
||||||
),
|
),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
MainMenu(
|
MainMenu(
|
||||||
|
@ -132,7 +138,11 @@ class _ProfileInfoState extends State<ProfileInfo> {
|
||||||
MainMenu(
|
MainMenu(
|
||||||
icon: FontAwesome5.shopping_bag,
|
icon: FontAwesome5.shopping_bag,
|
||||||
title: "Work History",
|
title: "Work History",
|
||||||
onTap: (){},
|
onTap: (){
|
||||||
|
Navigator.push(context, MaterialPageRoute(builder: (BuildContext context){
|
||||||
|
return WorkHistoryScreen(workExperiences: state.profileInformation.workExperiences);
|
||||||
|
}));
|
||||||
|
},
|
||||||
),
|
),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
MainMenu(
|
MainMenu(
|
||||||
|
|
|
@ -5,10 +5,12 @@ import 'package:unit2/model/profile/basic_info.dart';
|
||||||
import 'package:unit2/model/profile/basic_information/citizenship.dart';
|
import 'package:unit2/model/profile/basic_information/citizenship.dart';
|
||||||
import 'package:unit2/model/profile/basic_information/contact_information.dart';
|
import 'package:unit2/model/profile/basic_information/contact_information.dart';
|
||||||
import 'package:unit2/model/profile/basic_information/identification_information.dart';
|
import 'package:unit2/model/profile/basic_information/identification_information.dart';
|
||||||
|
import 'package:unit2/model/profile/educational_background.dart';
|
||||||
import 'package:unit2/model/profile/eligibility.dart';
|
import 'package:unit2/model/profile/eligibility.dart';
|
||||||
import 'package:unit2/model/profile/learning_development.dart';
|
import 'package:unit2/model/profile/learning_development.dart';
|
||||||
import 'package:unit2/model/profile/profileInfomation.dart';
|
import 'package:unit2/model/profile/profileInfomation.dart';
|
||||||
import 'package:unit2/model/profile/references.dart';
|
import 'package:unit2/model/profile/references.dart';
|
||||||
|
import 'package:unit2/model/profile/work_history.dart';
|
||||||
import 'package:unit2/utils/request.dart';
|
import 'package:unit2/utils/request.dart';
|
||||||
import 'package:unit2/utils/urls.dart';
|
import 'package:unit2/utils/urls.dart';
|
||||||
|
|
||||||
|
@ -21,16 +23,16 @@ class ProfileService {
|
||||||
Future<ProfileInformation?> getProfile(String token, int id) async {
|
Future<ProfileInformation?> getProfile(String token, int id) async {
|
||||||
String url = Url.instance.profileInformation();
|
String url = Url.instance.profileInformation();
|
||||||
String path = url + id.toString();
|
String path = url + id.toString();
|
||||||
ProfileInformation? profileInformation0;
|
ProfileInformation? profileInformation0;
|
||||||
List<PersonalReference> references = [];
|
|
||||||
ContactInfo contactInfo;
|
|
||||||
Identification identification;
|
|
||||||
List<Identification> identificationInformation =[];
|
|
||||||
List<ContactInfo> contactInformation = [];
|
|
||||||
PrimaryInformation primaryInformation;
|
PrimaryInformation primaryInformation;
|
||||||
|
List<WorkHistory> workExperiences =[];
|
||||||
|
List<PersonalReference> references = [];
|
||||||
|
List<Identification> identificationInformation = [];
|
||||||
|
List<ContactInfo> contactInformation = [];
|
||||||
List<EligibityCert> eligibilities = [];
|
List<EligibityCert> eligibilities = [];
|
||||||
List<Citizenship> citizenships = [];
|
List<Citizenship> citizenships = [];
|
||||||
List<LearningDevelopement> learningsDevelopments = [];
|
List<LearningDevelopement> learningsDevelopments = [];
|
||||||
|
List<EducationalBackground> educationalBackgrounds = [];
|
||||||
Map<String, String> headers = {
|
Map<String, String> headers = {
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
'Authorization': "Token $token"
|
'Authorization': "Token $token"
|
||||||
|
@ -39,55 +41,75 @@ class ProfileService {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.getRequest(path: path, param: {}, headers: headers);
|
.getRequest(path: path, param: {}, headers: headers);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
Map data = jsonDecode(response.body);
|
Map data = jsonDecode(response.body);
|
||||||
// get primary information
|
// get primary information
|
||||||
primaryInformation = PrimaryInformation.fromJson(
|
primaryInformation = PrimaryInformation.fromJson(
|
||||||
data['data']['basic_information']['primary_information']);
|
data['data']['basic_information']['primary_information']);
|
||||||
// get all contacts
|
// get all contacts
|
||||||
data['data']['basic_information']['contact_information']
|
data['data']['basic_information']['contact_information']
|
||||||
.forEach((var contact) {
|
.forEach((var contact) {
|
||||||
contactInfo = ContactInfo.fromJson(contact['contact_info']);
|
ContactInfo contactInfo = ContactInfo.fromJson(contact['contact_info']);
|
||||||
contactInformation.add(contactInfo);
|
contactInformation.add(contactInfo);
|
||||||
});
|
});
|
||||||
// get all identifications
|
// get all identifications
|
||||||
data['data']['basic_information']['identification_records'].forEach((var identity){
|
data['data']['basic_information']['identification_records']
|
||||||
identification = Identification.fromJson(identity);
|
.forEach((var identity) {
|
||||||
|
Identification identification = Identification.fromJson(identity);
|
||||||
identificationInformation.add(identification);
|
identificationInformation.add(identification);
|
||||||
});
|
});
|
||||||
//get all eligibilities
|
//get all eligibilities
|
||||||
data['data']['eligibilities'].forEach((var cert){
|
data['data']['eligibilities'].forEach((var cert) {
|
||||||
EligibityCert eligibility = EligibityCert.fromJson(cert);
|
EligibityCert eligibility = EligibityCert.fromJson(cert);
|
||||||
eligibilities.add(eligibility);
|
eligibilities.add(eligibility);
|
||||||
});
|
});
|
||||||
// get all citizenships
|
// get all citizenships
|
||||||
if(data['data']['citizenship']!= null){
|
if (data['data']['citizenship'] != null) {
|
||||||
data['data']['citizenships'].forEach((var citizenship){
|
data['data']['citizenships'].forEach((var citizenship) {
|
||||||
Citizenship person = Citizenship.fromJson(citizenship);
|
Citizenship person = Citizenship.fromJson(citizenship);
|
||||||
citizenships.add(person);
|
citizenships.add(person);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// get all references;
|
// get all references;
|
||||||
data['data']['personal_references'].forEach((var person){
|
data['data']['personal_references'].forEach((var person) {
|
||||||
PersonalReference reference = PersonalReference.fromJson(person);
|
PersonalReference reference = PersonalReference.fromJson(person);
|
||||||
references.add(reference);
|
references.add(reference);
|
||||||
});
|
});
|
||||||
|
|
||||||
//get all learning and developments
|
//get all learning and developments
|
||||||
|
|
||||||
data['data']['learning_development'].forEach((var training){
|
|
||||||
LearningDevelopement learnings = LearningDevelopement.fromJson(training);
|
|
||||||
learningsDevelopments.add(learnings);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
data['data']['learning_development'].forEach((var training) {
|
||||||
|
LearningDevelopement learnings =
|
||||||
|
LearningDevelopement.fromJson(training);
|
||||||
|
learningsDevelopments.add(learnings);
|
||||||
|
});
|
||||||
|
|
||||||
|
//get all educational background
|
||||||
|
data['data']['education_background'].forEach((var education) {
|
||||||
|
EducationalBackground educationalBackground =
|
||||||
|
EducationalBackground.fromJson(education);
|
||||||
|
educationalBackgrounds.add(educationalBackground);
|
||||||
|
});
|
||||||
|
|
||||||
BasicInfo basicInfo = BasicInfo(contactInformation: contactInformation,
|
// get all work history
|
||||||
primaryInformation: primaryInformation,
|
|
||||||
identifications: identificationInformation,
|
data['data']['work_experiences'].forEach((var work){
|
||||||
citizenships: citizenships
|
WorkHistory experience = WorkHistory.fromJson(work);
|
||||||
);
|
workExperiences.add(experience);
|
||||||
ProfileInformation profileInformation = ProfileInformation(basicInfo: basicInfo,eligibilities: eligibilities,references: references!,learningsAndDevelopment: learningsDevelopments);
|
});
|
||||||
profileInformation0 = profileInformation;
|
|
||||||
|
BasicInfo basicInfo = BasicInfo(
|
||||||
|
contactInformation: contactInformation,
|
||||||
|
primaryInformation: primaryInformation,
|
||||||
|
identifications: identificationInformation,
|
||||||
|
citizenships: citizenships);
|
||||||
|
ProfileInformation profileInformation = ProfileInformation(
|
||||||
|
workExperiences: workExperiences,
|
||||||
|
basicInfo: basicInfo,
|
||||||
|
eligibilities: eligibilities,
|
||||||
|
references: references,
|
||||||
|
learningsAndDevelopment: learningsDevelopments,
|
||||||
|
educationalBackgrounds: educationalBackgrounds);
|
||||||
|
profileInformation0 = profileInformation;
|
||||||
}
|
}
|
||||||
// }catch(e){
|
// }catch(e){
|
||||||
// throw(e.toString());
|
// throw(e.toString());
|
||||||
|
|
Loading…
Reference in New Issue