diff --git a/lib/controllers/api_routes/urls.dart b/lib/controllers/api_routes/urls.dart index c848148b..95b2085c 100644 --- a/lib/controllers/api_routes/urls.dart +++ b/lib/controllers/api_routes/urls.dart @@ -8,9 +8,9 @@ class URLs { // static const host1 = "https://atomsmuat.hmg.com"; // local UAT url // static const host1 = "http://10.201.111.125:9495"; // temporary Server UAT url - // static String _baseUrl = "$_host/mobile"; + static String _baseUrl = "$_host/mobile"; - static final String _baseUrl = "$_host/v2/mobile"; // new V2 apis + // static final String _baseUrl = "$_host/v2/mobile"; // new V2 apis // static final String _baseUrl = "$_host/v4/mobile"; // for asset inventory on UAT // static final String _baseUrl = "$_host/mobile"; // host local UAT // static final String _baseUrl = "$_host/v3/mobile"; // v3 for production CM,PM,TM diff --git a/lib/modules/cm_module/views/service_request_detail_main_view.dart b/lib/modules/cm_module/views/service_request_detail_main_view.dart index cd50f283..1f129652 100644 --- a/lib/modules/cm_module/views/service_request_detail_main_view.dart +++ b/lib/modules/cm_module/views/service_request_detail_main_view.dart @@ -87,7 +87,7 @@ class _ServiceRequestDetailMainState extends State { IconButton( icon: const Icon(Icons.feedback_rounded), onPressed: () { - Navigator.push(context, CupertinoPageRoute(builder: (context) => SurveyPage(moduleId: 1, requestId: widget.requestId, surveyId: 6))); + Navigator.push(context, CupertinoPageRoute(builder: (context) => SurveyPage(moduleId: 1, requestId: widget.requestId, surveyId: 5))); }, ), IconButton( diff --git a/lib/modules/cx_module/survey/questionnaire_model.dart b/lib/modules/cx_module/survey/questionnaire_model.dart index 9528cf87..9f2ac626 100644 --- a/lib/modules/cx_module/survey/questionnaire_model.dart +++ b/lib/modules/cx_module/survey/questionnaire_model.dart @@ -91,13 +91,15 @@ class SurveyQuestions { int? questionId; String? questionText; SurveyType? questionType; + bool? isMandatory; List? surveyAnswerOptions; - SurveyQuestions({this.questionId, this.questionText, this.questionType, this.surveyAnswerOptions}); + SurveyQuestions({this.questionId, this.questionText, this.questionType, this.surveyAnswerOptions, this.isMandatory}); SurveyQuestions.fromJson(Map json) { questionId = json['questionId']; questionText = json['questionText']; + isMandatory = json['isMandatory']; questionType = json['questionType'] != null ? new SurveyType.fromJson(json['questionType']) : null; if (json['surveyAnswerOptions'] != null) { surveyAnswerOptions = []; @@ -111,6 +113,7 @@ class SurveyQuestions { final Map data = new Map(); data['questionId'] = this.questionId; data['questionText'] = this.questionText; + data['isMandatory'] = this.isMandatory; if (this.questionType != null) { data['questionType'] = this.questionType!.toJson(); } diff --git a/lib/modules/cx_module/survey/survey_page.dart b/lib/modules/cx_module/survey/survey_page.dart index 71fa34f9..1975eef3 100644 --- a/lib/modules/cx_module/survey/survey_page.dart +++ b/lib/modules/cx_module/survey/survey_page.dart @@ -175,8 +175,8 @@ class _SurveyPageState extends State { bool isSuccess = await Provider.of(context, listen: false).submitQuestionare(payload); Utils.hideLoading(context); if (isSuccess) { - context.showConfirmDialog("Thank you for submitting the Feedback. It value for us to improve system and overall experience.", title: "Thanks!", okTitle: "Go Back", - onTap: () { + context.showConfirmDialog("Thanks for submitting the Feedback. Its value for us to improve our system and overall experience.", title: "Thank you!", onTap: () { + Navigator.pop(context); Navigator.pop(context); }); } //reload Data @@ -192,18 +192,20 @@ class _SurveyPageState extends State { bool validateAnswers() { bool status = true; for (int i = 0; i < answers.length; i++) { - if (questionnaire!.surveyQuestions![i].questionType!.value == 4) { - if (answers[i].surveyAnswerRating! < 0) { - "Please rate (${questionnaire!.surveyQuestions![i].questionText})".showToast; - status = false; - break; - } - } else if (questionnaire!.surveyQuestions![i].questionType!.value == 3) { - answers[i].surveyAnswerRating = null; - if ((answers[i].surveyAnswerText ?? "").isEmpty) { - "Please answer (${questionnaire!.surveyQuestions![i].questionText})".showToast; - status = false; - break; + if (questionnaire!.surveyQuestions![i].isMandatory ?? false) { + if (questionnaire!.surveyQuestions![i].questionType!.value == 4) { + if (answers[i].surveyAnswerRating! < 0) { + "Please rate (${questionnaire!.surveyQuestions![i].questionText})".showToast; + status = false; + break; + } + } else if (questionnaire!.surveyQuestions![i].questionType!.value == 3) { + answers[i].surveyAnswerRating = null; + if ((answers[i].surveyAnswerText ?? "").isEmpty) { + "Please answer (${questionnaire!.surveyQuestions![i].questionText})".showToast; + status = false; + break; + } } } } diff --git a/lib/modules/cx_module/survey/survey_provider.dart b/lib/modules/cx_module/survey/survey_provider.dart index 4fe0b468..cc1b73f6 100644 --- a/lib/modules/cx_module/survey/survey_provider.dart +++ b/lib/modules/cx_module/survey/survey_provider.dart @@ -22,25 +22,25 @@ class SurveyProvider with ChangeNotifier { String responseMsg = ""; Questionnaire? q; try { - final response = await ApiManager.instance.get("${URLs.getQuestionnaire.toString().replaceFirst("/mobile/", "/api/")}?surveySubmissionId=$surveySubmissionId", enableToastMessage: false); + final response = await ApiManager.instance.get("${URLs.getQuestionnaire}?surveySubmissionId=$surveySubmissionId", enableToastMessage: false); if (response.statusCode >= 200 && response.statusCode < 300) { + q = Questionnaire.fromJson(jsonDecode(response.body)["data"]); + } else { if (jsonDecode(response.body)["message"] != null && jsonDecode(response.body)["message"].toString().isNotEmpty) { responseMsg = jsonDecode(response.body)["message"]; - } else { - q = Questionnaire.fromJson(jsonDecode(response.body)["data"]); - } + } else {} } } catch (ex) { "Failed, Retry.".showToast; } onResponse(responseMsg, q); - // return null; + // return null; } Future submitQuestionare(Map payload) async { try { - final response = await ApiManager.instance.post(URLs.submitSurvey.toString().replaceFirst("/mobile/", "/api/"), body: payload); + final response = await ApiManager.instance.post(URLs.submitSurvey, body: payload); if (response.statusCode >= 200 && response.statusCode < 300) { return true; }