Commit 9492ecd3 authored by devendra's avatar devendra
Browse files

Feat: two-lead-assessor- api changes adopted

1 merge request!3Two lead assessor
Showing with 12 additions and 6 deletions
+12 -6
...@@ -14,6 +14,7 @@ class Application { ...@@ -14,6 +14,7 @@ class Application {
final String scheduledDate; final String scheduledDate;
final String createdDate; final String createdDate;
final String createdBy; final String createdBy;
final String updatedBy;
const Application({ const Application({
required this.formId, required this.formId,
...@@ -31,6 +32,7 @@ class Application { ...@@ -31,6 +32,7 @@ class Application {
required this.scheduledDate, required this.scheduledDate,
required this.createdDate, required this.createdDate,
required this.createdBy, required this.createdBy,
required this.updatedBy,
}); });
factory Application.fromJson(Map<String, dynamic> json) { factory Application.fromJson(Map<String, dynamic> json) {
...@@ -58,6 +60,7 @@ class Application { ...@@ -58,6 +60,7 @@ class Application {
json['inspection'] != null ? json['inspection']['scheduledDate'] : '', json['inspection'] != null ? json['inspection']['scheduledDate'] : '',
createdDate: json['createdDate'], createdDate: json['createdDate'],
createdBy: json['createdBy'], createdBy: json['createdBy'],
updatedBy: json['updatedBy'] ?? "",
); );
} }
......
...@@ -284,6 +284,7 @@ class _ApplicationDetailsPageState extends State<ApplicationDetailsPage> ...@@ -284,6 +284,7 @@ class _ApplicationDetailsPageState extends State<ApplicationDetailsPage>
//Validate assessment form to make sure all inputs are given by the assessor when second assessor submmits the form //Validate assessment form to make sure all inputs are given by the assessor when second assessor submmits the form
if (widget.application.inspectionStatus == if (widget.application.inspectionStatus ==
InspectionStatus.leadInspectorCompleted) { InspectionStatus.leadInspectorCompleted) {
data["inspectionCompleted"] = true;
isValidForm = true; isValidForm = true;
for (int i = 0; i < fieldsLength; i++) { for (int i = 0; i < fieldsLength; i++) {
_data[_data.keys.elementAt(i)].forEach((key, value) { _data[_data.keys.elementAt(i)].forEach((key, value) {
......
...@@ -128,6 +128,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver { ...@@ -128,6 +128,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
Future<dynamic> _getApplications() async { Future<dynamic> _getApplications() async {
String rawUserId = await Helper.getUser(Storage.userId); String rawUserId = await Helper.getUser(Storage.userId);
String username = await Helper.getUser(Storage.username);
int userId = int.parse(rawUserId); int userId = int.parse(rawUserId);
bool isInternetConnected = await Helper.isInternetConnected(); bool isInternetConnected = await Helper.isInternetConnected();
// await Future.delayed(const Duration(milliseconds: 10)); // await Future.delayed(const Duration(milliseconds: 10));
...@@ -154,17 +155,18 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver { ...@@ -154,17 +155,18 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
temp = List.from(temp.reversed); temp = List.from(temp.reversed);
int days = Helper.getDateDiffence( int days = Helper.getDateDiffence(
DateTime.now(), DateTime.parse(temp.join("-"))); DateTime.now(), DateTime.parse(temp.join("-")));
if ((days == 0 || days > 0) && if ((days == 0) &&
application.status == InspectionStatus.sentForInspection) { application.status == InspectionStatus.sentForInspection) {
if (application.leadInspector[0] == userId && if (application.inspectionStatus ==
application.inspectionStatus == InspectionStatus.leadInspectorCompleted &&
InspectionStatus.leadInspectorCompleted) { application.updatedBy == username) {
_pastApplications.add(application); _pastApplications.add(application);
} else { } else {
_pendingApplications.add(application); _pendingApplications.add(application);
} }
} else if ((days == 0 || days > 0) && } else if (((days == 0) &&
application.status != InspectionStatus.sentForInspection) { application.status != InspectionStatus.sentForInspection) ||
(days > 0)) {
_pastApplications.add(application); _pastApplications.add(application);
} else { } else {
_upcomingApplications.add(application); _upcomingApplications.add(application);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment