@mseva/digit-ui-module-engagement 1.1.12 → 1.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19455,6 +19455,7 @@ const FillQuestions = props => {
19455
19455
  isLoading
19456
19456
  } = Digit.Hooks.useTenants();
19457
19457
  const [city, setCity] = useState(null);
19458
+ const [loading, setLoading] = useState(false);
19458
19459
  const [submitted, setSubmitted] = useState(false);
19459
19460
  const [localityList, setLocalityList] = useState(null);
19460
19461
  const [openQuesDetailsDialog, setOpenQuesDetailsDialog] = useState(false);
@@ -19462,6 +19463,7 @@ const FillQuestions = props => {
19462
19463
  latitude: null,
19463
19464
  longitude: null
19464
19465
  });
19466
+ const [getFetchAnswers, setFetchAnswers] = useState();
19465
19467
  const [pincode, setPincode] = useState("");
19466
19468
  const [isgeoLoc, setIsGeoLoc] = useState(false);
19467
19469
  const tenantId = Digit.ULBService.getCurrentTenantId();
@@ -19469,10 +19471,14 @@ const FillQuestions = props => {
19469
19471
  const [hasCitizenDetails, setHasCitizenDetails] = useState(null);
19470
19472
  useEffect(() => {
19471
19473
  (async () => {
19474
+ setLoading(true);
19472
19475
  let response = await Digit.LocationService.getLocalities(city);
19476
+ setLoading(false);
19473
19477
  let __localityList = [];
19474
19478
  if (response && response.TenantBoundary.length > 0) {
19479
+ setLoading(true);
19475
19480
  __localityList = Digit.LocalityService.get(response.TenantBoundary[0]);
19481
+ setLoading(false);
19476
19482
  }
19477
19483
  setLocalityList(__localityList);
19478
19484
  })();
@@ -19481,10 +19487,14 @@ const FillQuestions = props => {
19481
19487
  (async () => {
19482
19488
  if ((prevProps === null || prevProps === void 0 ? void 0 : prevProps.userType).toUpperCase() === "EMPLOYEE") {
19483
19489
  var _prevProps$citizenDat;
19490
+ setLoading(true);
19484
19491
  let response = await Digit.LocationService.getLocalities((_prevProps$citizenDat = prevProps.citizenData.city) === null || _prevProps$citizenDat === void 0 ? void 0 : _prevProps$citizenDat.code);
19492
+ setLoading(false);
19485
19493
  let __localityList = [];
19486
19494
  if (response && response.TenantBoundary.length > 0) {
19495
+ setLoading(true);
19487
19496
  __localityList = Digit.LocalityService.get(response.TenantBoundary[0]);
19497
+ setLoading(false);
19488
19498
  }
19489
19499
  setLocalityList(__localityList);
19490
19500
  }
@@ -19543,12 +19553,14 @@ const FillQuestions = props => {
19543
19553
  const prevFormDataRef = useRef({});
19544
19554
  const data = prevProps.surveyDetails;
19545
19555
  const fetchAnswer = async status => {
19556
+ setLoading(true);
19546
19557
  let payload = {
19547
19558
  surveyUuid: data.uuid,
19548
19559
  citizenId: prevProps.userInfo.uuid
19549
19560
  };
19550
19561
  try {
19551
19562
  Digit.Surveys.getAnswers(payload).then(response => {
19563
+ setLoading(false);
19552
19564
  if ((response === null || response === void 0 ? void 0 : response.sectionResponses.length) > 0) {
19553
19565
  let result = {};
19554
19566
  response.sectionResponses.forEach(section => {
@@ -19562,7 +19574,6 @@ const FillQuestions = props => {
19562
19574
  result[section.sectionUuid] = sectionObj;
19563
19575
  });
19564
19576
  setFormData(result);
19565
- console.log("status======", status);
19566
19577
  if (status === "draft") {
19567
19578
  handleAutoSave();
19568
19579
  } else {
@@ -19578,18 +19589,21 @@ const FillQuestions = props => {
19578
19589
  }
19579
19590
  });
19580
19591
  } catch (error) {
19592
+ setLoading(false);
19581
19593
  return error;
19582
19594
  }
19583
19595
  };
19584
19596
  const fetchSurveyAnswers = async () => {
19597
+ setLoading(true);
19585
19598
  let payload = {
19586
19599
  surveyUuid: data.uuid,
19587
19600
  citizenId: prevProps.userInfo.uuid
19588
19601
  };
19589
19602
  try {
19590
19603
  Digit.Surveys.getAnswers(payload).then(response => {
19604
+ setFetchAnswers(response);
19605
+ setLoading(false);
19591
19606
  if ((response === null || response === void 0 ? void 0 : response.sectionResponses.length) > 0) {
19592
- console.log("response.status", response.status);
19593
19607
  if (response.status == "Draft") {
19594
19608
  setSubmitted(false);
19595
19609
  if ((prevProps === null || prevProps === void 0 ? void 0 : prevProps.userType).toUpperCase() === "CITIZEN") {
@@ -19627,6 +19641,7 @@ const FillQuestions = props => {
19627
19641
  }
19628
19642
  });
19629
19643
  } catch (error) {
19644
+ setLoading(false);
19630
19645
  return error;
19631
19646
  }
19632
19647
  };
@@ -19653,6 +19668,7 @@ const FillQuestions = props => {
19653
19668
  };
19654
19669
  const fetchUserDetails = async () => {
19655
19670
  var _prevProps$userInfo, _prevProps$userInfo2, _prevProps$userInfo3;
19671
+ setLoading(true);
19656
19672
  const data = {
19657
19673
  userName: prevProps === null || prevProps === void 0 ? void 0 : (_prevProps$userInfo = prevProps.userInfo) === null || _prevProps$userInfo === void 0 ? void 0 : _prevProps$userInfo.mobileNumber,
19658
19674
  tenantId: prevProps === null || prevProps === void 0 ? void 0 : (_prevProps$userInfo2 = prevProps.userInfo) === null || _prevProps$userInfo2 === void 0 ? void 0 : _prevProps$userInfo2.tenantId
@@ -19662,6 +19678,7 @@ const FillQuestions = props => {
19662
19678
  };
19663
19679
  Digit.Surveys.userSearch(data, filters).then(response => {
19664
19680
  var _response$responseInf, _response$responseInf2;
19681
+ setLoading(false);
19665
19682
  if (((response === null || response === void 0 ? void 0 : (_response$responseInf = response.responseInfo) === null || _response$responseInf === void 0 ? void 0 : _response$responseInf.status) === "200" || (response === null || response === void 0 ? void 0 : (_response$responseInf2 = response.responseInfo) === null || _response$responseInf2 === void 0 ? void 0 : _response$responseInf2.status) === "201") && (response === null || response === void 0 ? void 0 : response.user.length) > 0) {
19666
19683
  var _response$user$, _response$user$2, _response$user$3, _response$user$4, _response$user$5, _response$user$6;
19667
19684
  if ((response === null || response === void 0 ? void 0 : (_response$user$ = response.user[0]) === null || _response$user$ === void 0 ? void 0 : _response$user$.gender) === null || (response === null || response === void 0 ? void 0 : (_response$user$2 = response.user[0]) === null || _response$user$2 === void 0 ? void 0 : _response$user$2.emailId) === null || (response === null || response === void 0 ? void 0 : (_response$user$3 = response.user[0]) === null || _response$user$3 === void 0 ? void 0 : _response$user$3.dob) === null || (response === null || response === void 0 ? void 0 : (_response$user$4 = response.user[0]) === null || _response$user$4 === void 0 ? void 0 : _response$user$4.gender) === "" || (response === null || response === void 0 ? void 0 : (_response$user$5 = response.user[0]) === null || _response$user$5 === void 0 ? void 0 : _response$user$5.emailId) === "" || (response === null || response === void 0 ? void 0 : (_response$user$6 = response.user[0]) === null || _response$user$6 === void 0 ? void 0 : _response$user$6.dob) === "") {
@@ -19692,6 +19709,7 @@ const FillQuestions = props => {
19692
19709
  });
19693
19710
  }
19694
19711
  }).catch(error => {
19712
+ setLoading(false);
19695
19713
  return error;
19696
19714
  });
19697
19715
  };
@@ -19734,14 +19752,15 @@ const FillQuestions = props => {
19734
19752
  if (JSON.stringify(prevFormDataRef.current) !== JSON.stringify(formData)) {
19735
19753
  if (prevProps.citizenFill && userType.toLowerCase() === "employee" || userType.toLowerCase() === "citizen") {
19736
19754
  prevFormDataRef.current = formData;
19737
- fetchAnswer("draft");
19755
+ if (locality) fetchAnswer("draft");
19738
19756
  }
19739
19757
  }
19740
19758
  }, 10000);
19741
19759
  return () => clearInterval(interval);
19742
19760
  }, [formData]);
19743
19761
  const handleAutoSave = async () => {
19744
- var _prevProps$citizenDat2, _prevProps$citizenDat3, _prevProps$citizenDat4, _prevProps$citizenDat5, _prevProps$citizenDat6;
19762
+ var _prevProps$citizenDat2, _prevProps$citizenDat3, _prevProps$citizenDat4;
19763
+ setLoading(true);
19745
19764
  let answerArr = [];
19746
19765
  for (const sectionId in formData) {
19747
19766
  for (const questionId in formData[sectionId]) {
@@ -19770,15 +19789,16 @@ const FillQuestions = props => {
19770
19789
  },
19771
19790
  SurveyResponse: {
19772
19791
  surveyUuid: data.uuid,
19773
- tenantId: (prevProps === null || prevProps === void 0 ? void 0 : prevProps.userType).toUpperCase() === "EMPLOYEE" ? prevProps === null || prevProps === void 0 ? void 0 : (_prevProps$citizenDat5 = prevProps.citizenData) === null || _prevProps$citizenDat5 === void 0 ? void 0 : (_prevProps$citizenDat6 = _prevProps$citizenDat5.city) === null || _prevProps$citizenDat6 === void 0 ? void 0 : _prevProps$citizenDat6.code : city === null || city === void 0 ? void 0 : city.code,
19792
+ tenantId: city,
19793
+ locality: locality,
19774
19794
  status: "Draft",
19775
- locality: locality || null,
19776
19795
  coordinates: `${geoLocation.latitude},${geoLocation.longitude}`,
19777
19796
  answers: answerArr
19778
19797
  }
19779
19798
  };
19780
19799
  try {
19781
19800
  Digit.Surveys.submitSurvey(payload).then(response => {
19801
+ setLoading(false);
19782
19802
  if ((response === null || response === void 0 ? void 0 : response.SubmitResponse) !== undefined) {} else {
19783
19803
  var _response$Errors;
19784
19804
  setShowToast({
@@ -19789,6 +19809,7 @@ const FillQuestions = props => {
19789
19809
  }
19790
19810
  });
19791
19811
  } catch (error) {
19812
+ setLoading(false);
19792
19813
  return error;
19793
19814
  }
19794
19815
  };
@@ -19844,7 +19865,8 @@ const FillQuestions = props => {
19844
19865
  return Object.keys(newErrors).length === 0;
19845
19866
  };
19846
19867
  const handleSubmitSurvey = () => {
19847
- var _prevProps$citizenDat7, _prevProps$citizenDat8, _prevProps$citizenDat9, _prevProps$citizenDat10, _prevProps$citizenDat11;
19868
+ var _prevProps$citizenDat5, _prevProps$citizenDat6, _prevProps$citizenDat7;
19869
+ setLoading(true);
19848
19870
  let answerArr = [];
19849
19871
  for (const sectionId in formData) {
19850
19872
  for (const questionId in formData[sectionId]) {
@@ -19855,6 +19877,7 @@ const FillQuestions = props => {
19855
19877
  questionUuid: questionId,
19856
19878
  sectionUuid: sectionId,
19857
19879
  comments: ((_formData$sectionId$q2 = formData[sectionId][questionId]) === null || _formData$sectionId$q2 === void 0 ? void 0 : _formData$sectionId$q2.comments) || "",
19880
+ tenantId: localStorage.getItem("CITIZEN.CITY"),
19858
19881
  answerDetails: [{
19859
19882
  answerType: formData[sectionId][questionId].answerType,
19860
19883
  answerContent: formData[sectionId][questionId].answerType === "CHECKBOX_ANSWER_TYPE" ? formData[sectionId][questionId].answer.join(",") : formData[sectionId][questionId].answer,
@@ -19867,21 +19890,23 @@ const FillQuestions = props => {
19867
19890
  User: {
19868
19891
  type: prevProps.userInfo.type,
19869
19892
  uuid: prevProps.userInfo.uuid,
19870
- gender: (prevProps === null || prevProps === void 0 ? void 0 : prevProps.userType).toUpperCase() === "EMPLOYEE" ? prevProps === null || prevProps === void 0 ? void 0 : (_prevProps$citizenDat7 = prevProps.citizenData) === null || _prevProps$citizenDat7 === void 0 ? void 0 : _prevProps$citizenDat7.gender : prevProps.userInfo.gender,
19871
- emailId: (prevProps === null || prevProps === void 0 ? void 0 : prevProps.userType).toUpperCase() === "EMPLOYEE" ? prevProps === null || prevProps === void 0 ? void 0 : (_prevProps$citizenDat8 = prevProps.citizenData) === null || _prevProps$citizenDat8 === void 0 ? void 0 : _prevProps$citizenDat8.email : prevProps.userInfo.emailId,
19872
- dob: (prevProps === null || prevProps === void 0 ? void 0 : prevProps.userType).toUpperCase() === "EMPLOYEE" ? prevProps === null || prevProps === void 0 ? void 0 : (_prevProps$citizenDat9 = prevProps.citizenData) === null || _prevProps$citizenDat9 === void 0 ? void 0 : _prevProps$citizenDat9.dob : prevProps.userInfo.dob
19893
+ gender: (prevProps === null || prevProps === void 0 ? void 0 : prevProps.userType).toUpperCase() === "EMPLOYEE" ? prevProps === null || prevProps === void 0 ? void 0 : (_prevProps$citizenDat5 = prevProps.citizenData) === null || _prevProps$citizenDat5 === void 0 ? void 0 : _prevProps$citizenDat5.gender : prevProps.userInfo.gender,
19894
+ emailId: (prevProps === null || prevProps === void 0 ? void 0 : prevProps.userType).toUpperCase() === "EMPLOYEE" ? prevProps === null || prevProps === void 0 ? void 0 : (_prevProps$citizenDat6 = prevProps.citizenData) === null || _prevProps$citizenDat6 === void 0 ? void 0 : _prevProps$citizenDat6.email : prevProps.userInfo.emailId,
19895
+ dob: (prevProps === null || prevProps === void 0 ? void 0 : prevProps.userType).toUpperCase() === "EMPLOYEE" ? prevProps === null || prevProps === void 0 ? void 0 : (_prevProps$citizenDat7 = prevProps.citizenData) === null || _prevProps$citizenDat7 === void 0 ? void 0 : _prevProps$citizenDat7.dob : prevProps.userInfo.dob
19873
19896
  },
19874
19897
  SurveyResponse: {
19875
19898
  surveyUuid: data.uuid,
19876
- tenantId: (prevProps === null || prevProps === void 0 ? void 0 : prevProps.userType).toUpperCase() === "EMPLOYEE" ? prevProps === null || prevProps === void 0 ? void 0 : (_prevProps$citizenDat10 = prevProps.citizenData) === null || _prevProps$citizenDat10 === void 0 ? void 0 : (_prevProps$citizenDat11 = _prevProps$citizenDat10.city) === null || _prevProps$citizenDat11 === void 0 ? void 0 : _prevProps$citizenDat11.code : city === null || city === void 0 ? void 0 : city.code,
19899
+ tenantId: city,
19877
19900
  status: "Submit",
19878
- locality: locality || null,
19901
+ locality: locality,
19879
19902
  coordinates: `${geoLocation.latitude},${geoLocation.longitude}`,
19903
+ tenantId: localStorage.getItem("CITIZEN.CITY"),
19880
19904
  answers: answerArr
19881
19905
  }
19882
19906
  };
19883
19907
  try {
19884
19908
  Digit.Surveys.submitSurvey(payload).then(response => {
19909
+ setLoading(false);
19885
19910
  if ((response === null || response === void 0 ? void 0 : response.SubmitResponse) !== undefined) {
19886
19911
  userType.toUpperCase() === "EMPLOYEE" ? history.push("/digit-ui/employee/engagement/surveys/submit-response", {
19887
19912
  message: "SURVEY FORM SUBMITTED SUCCESSFULLY",
@@ -19903,6 +19928,7 @@ const FillQuestions = props => {
19903
19928
  }
19904
19929
  });
19905
19930
  } catch (error) {
19931
+ setLoading(false);
19906
19932
  return error;
19907
19933
  }
19908
19934
  };
@@ -20350,7 +20376,6 @@ const FillQuestions = props => {
20350
20376
  });
20351
20377
  }
20352
20378
  };
20353
- data.sections.map(s => console.log("data sec", s.title));
20354
20379
  const closeToast = () => {
20355
20380
  setShowToast(null);
20356
20381
  };
@@ -20359,11 +20384,25 @@ const FillQuestions = props => {
20359
20384
  longitude: null
20360
20385
  });
20361
20386
  const handleCityChange = e => {
20362
- setCity(e.target.value);
20387
+ const selectedCity = e.target.value;
20388
+ setCity(selectedCity);
20363
20389
  };
20390
+ useEffect(() => {
20391
+ if (getFetchAnswers) {
20392
+ const storedCity = getFetchAnswers !== null && getFetchAnswers !== void 0 && getFetchAnswers.tenantId ? getFetchAnswers === null || getFetchAnswers === void 0 ? void 0 : getFetchAnswers.tenantId : localStorage.getItem("CITIZEN.CITY");
20393
+ if (storedCity) {
20394
+ setCity(storedCity);
20395
+ }
20396
+ }
20397
+ }, [getFetchAnswers]);
20364
20398
  const handleLocalityChangeCitizen = e => {
20365
20399
  setLocality(e.target.value);
20366
20400
  };
20401
+ useEffect(() => {
20402
+ if (getFetchAnswers) {
20403
+ setLocality(getFetchAnswers === null || getFetchAnswers === void 0 ? void 0 : getFetchAnswers.locality);
20404
+ }
20405
+ }, [getFetchAnswers]);
20367
20406
  function handleOnSubmitDialog() {
20368
20407
  setOpenQuesDetailsDialog(false);
20369
20408
  }
@@ -20519,7 +20558,7 @@ const FillQuestions = props => {
20519
20558
  color: "white",
20520
20559
  marginTop: "10px"
20521
20560
  }
20522
- }, "Fill your details : Name, Gender, DOB and Email are required")) : null
20561
+ }, "Fill your details : Name, Gender, DOB and Email are required"), loading && /*#__PURE__*/React.createElement(Loader, null)) : null
20523
20562
  );
20524
20563
  };
20525
20564
 
@@ -22002,6 +22041,10 @@ const SearchFormFieldsComponents = ({
22002
22041
  t
22003
22042
  } = useTranslation();
22004
22043
  const ulbs = Digit.SessionStorage.get("ENGAGEMENT_TENANTS");
22044
+ const {
22045
+ data: cities,
22046
+ isLoading
22047
+ } = Digit.Hooks.useTenants();
22005
22048
  const tenantId = Digit.ULBService.getCurrentTenantId();
22006
22049
  const userInfo = Digit.SessionStorage.get("citizen.userRequestObject");
22007
22050
  const userUlbs = ulbs.filter(ulb => {
@@ -22020,10 +22063,10 @@ const SearchFormFieldsComponents = ({
22020
22063
  rules: {
22021
22064
  required: t("REQUIRED_FIELD")
22022
22065
  },
22023
- defaultValue: selectedTenat === null || selectedTenat === void 0 ? void 0 : selectedTenat[0],
22066
+ defaultValue: tenantId,
22024
22067
  render: props => /*#__PURE__*/React.createElement(Dropdown, {
22025
- option: userUlbs,
22026
- optionKey: "i18nKey",
22068
+ option: cities,
22069
+ optionKey: "name",
22027
22070
  selected: props.value,
22028
22071
  select: e => props.onChange(e),
22029
22072
  t: t