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 {
final String scheduledDate;
final String createdDate;
final String createdBy;
final String updatedBy;
const Application({
required this.formId,
......@@ -31,6 +32,7 @@ class Application {
required this.scheduledDate,
required this.createdDate,
required this.createdBy,
required this.updatedBy,
});
factory Application.fromJson(Map<String, dynamic> json) {
......@@ -58,6 +60,7 @@ class Application {
json['inspection'] != null ? json['inspection']['scheduledDate'] : '',
createdDate: json['createdDate'],
createdBy: json['createdBy'],
updatedBy: json['updatedBy'] ?? "",
);
}
......
......@@ -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
if (widget.application.inspectionStatus ==
InspectionStatus.leadInspectorCompleted) {
data["inspectionCompleted"] = true;
isValidForm = true;
for (int i = 0; i < fieldsLength; i++) {
_data[_data.keys.elementAt(i)].forEach((key, value) {
......
......@@ -128,6 +128,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
Future<dynamic> _getApplications() async {
String rawUserId = await Helper.getUser(Storage.userId);
String username = await Helper.getUser(Storage.username);
int userId = int.parse(rawUserId);
bool isInternetConnected = await Helper.isInternetConnected();
// await Future.delayed(const Duration(milliseconds: 10));
......@@ -154,17 +155,18 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
temp = List.from(temp.reversed);
int days = Helper.getDateDiffence(
DateTime.now(), DateTime.parse(temp.join("-")));
if ((days == 0 || days > 0) &&
if ((days == 0) &&
application.status == InspectionStatus.sentForInspection) {
if (application.leadInspector[0] == userId &&
application.inspectionStatus ==
InspectionStatus.leadInspectorCompleted) {
if (application.inspectionStatus ==
InspectionStatus.leadInspectorCompleted &&
application.updatedBy == username) {
_pastApplications.add(application);
} else {
_pendingApplications.add(application);
}
} else if ((days == 0 || days > 0) &&
application.status != InspectionStatus.sentForInspection) {
} else if (((days == 0) &&
application.status != InspectionStatus.sentForInspection) ||
(days > 0)) {
_pastApplications.add(application);
} else {
_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