@djb25/digit-ui-module-wt 1.0.26 → 1.0.27

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.
@@ -267,9 +267,11 @@ const WTCreate = () => {
267
267
  if (!isNaN(lastchar)) {
268
268
  isMultiple = true;
269
269
  }
270
+ let routeObj = config.find(routeObj => key ? routeObj.key === key : routeObj.route === currentPath);
271
+ if (!routeObj) routeObj = config.find(routeObj => routeObj.route === currentPath);
270
272
  let {
271
273
  nextStep = {}
272
- } = config.find(routeObj => routeObj.route === currentPath);
274
+ } = routeObj || {};
273
275
  let redirectWithHistory = history.push;
274
276
  if (skipStep) {
275
277
  redirectWithHistory = history.replace;
@@ -1981,6 +1983,9 @@ const WTCheckPage = ({
1981
1983
  const {
1982
1984
  t
1983
1985
  } = useTranslation();
1986
+ const {
1987
+ pathname
1988
+ } = useLocation();
1984
1989
  const {
1985
1990
  owner,
1986
1991
  requestDetails,
@@ -1992,6 +1997,7 @@ const WTCheckPage = ({
1992
1997
  const [agree, setAgree] = useState(false);
1993
1998
  const immediateRequired = requestDetails !== null && requestDetails !== void 0 && requestDetails.extraCharge ? "YES" : "NO";
1994
1999
  const [fileUrl, setFileUrl] = useState(null);
2000
+ const baseUrl = pathname.includes("citizen") ? `${APPLICATION_PATH}/citizen/wt/request-service` : `${APPLICATION_PATH}/employee/wt/request-service`;
1995
2001
  const setdeclarationhandler = () => {
1996
2002
  setAgree(!agree);
1997
2003
  };
@@ -2015,7 +2021,7 @@ const WTCheckPage = ({
2015
2021
  label: t("COMMON_APPLICANT_NAME"),
2016
2022
  text: `${t(checkForNA(owner === null || owner === void 0 ? void 0 : owner.applicantName))}`,
2017
2023
  actionButton: /*#__PURE__*/React.createElement(ActionButton, {
2018
- jumpTo: `${APPLICATION_PATH}/citizen/wt/request-service/applicant-details`
2024
+ jumpTo: `${baseUrl}/applicant-details`
2019
2025
  })
2020
2026
  }), /*#__PURE__*/React.createElement(Row, {
2021
2027
  label: t("COMMON_MOBILE_NUMBER"),
@@ -2035,7 +2041,7 @@ const WTCheckPage = ({
2035
2041
  label: t("HOUSE_NO"),
2036
2042
  text: `${t(checkForNA(address === null || address === void 0 ? void 0 : address.houseNo))}`,
2037
2043
  actionButton: /*#__PURE__*/React.createElement(ActionButton, {
2038
- jumpTo: `${APPLICATION_PATH}/citizen/wt/request-service/address-details`
2044
+ jumpTo: `${baseUrl}/address-details`
2039
2045
  })
2040
2046
  }), /*#__PURE__*/React.createElement(Row, {
2041
2047
  label: t("ADDRESS_LINE1"),
@@ -2067,7 +2073,7 @@ const WTCheckPage = ({
2067
2073
  label: t("WT_TANKER_TYPE"),
2068
2074
  text: `${t(checkForNA(requestDetails === null || requestDetails === void 0 ? void 0 : (_requestDetails$tanke = requestDetails.tankerType) === null || _requestDetails$tanke === void 0 ? void 0 : _requestDetails$tanke.value))}`,
2069
2075
  actionButton: /*#__PURE__*/React.createElement(ActionButton, {
2070
- jumpTo: `${APPLICATION_PATH}/citizen/wt/request-service/request-details`
2076
+ jumpTo: `${baseUrl}/request-details`
2071
2077
  })
2072
2078
  }), /*#__PURE__*/React.createElement(Row, {
2073
2079
  label: t("WT_WATER_TYPE"),
@@ -2110,7 +2116,7 @@ const WTCheckPage = ({
2110
2116
  label: t("MT_NUMBER_OF_MOBILE_TOILETS"),
2111
2117
  text: `${t(checkForNA(toiletRequestDetails === null || toiletRequestDetails === void 0 ? void 0 : (_toiletRequestDetails = toiletRequestDetails.mobileToilet) === null || _toiletRequestDetails === void 0 ? void 0 : _toiletRequestDetails.code))}`,
2112
2118
  actionButton: /*#__PURE__*/React.createElement(ActionButton, {
2113
- jumpTo: `${APPLICATION_PATH}/citizen/wt/request-service/toiletRequest-details`
2119
+ jumpTo: `${baseUrl}/toiletRequest-details`
2114
2120
  })
2115
2121
  }), /*#__PURE__*/React.createElement(Row, {
2116
2122
  label: t("MT_DELIVERY_FROM_DATE"),
@@ -2136,7 +2142,7 @@ const WTCheckPage = ({
2136
2142
  label: t("REASON_FOR_PRUNING"),
2137
2143
  text: `${t(checkForNA(treePruningRequestDetails === null || treePruningRequestDetails === void 0 ? void 0 : (_treePruningRequestDe = treePruningRequestDetails.reasonOfPruning) === null || _treePruningRequestDe === void 0 ? void 0 : _treePruningRequestDe.code))}`,
2138
2144
  actionButton: /*#__PURE__*/React.createElement(ActionButton, {
2139
- jumpTo: `${APPLICATION_PATH}/citizen/wt/request-service/treePruningRequest-details`
2145
+ jumpTo: `${baseUrl}/treePruningRequest-details`
2140
2146
  })
2141
2147
  }), /*#__PURE__*/React.createElement(Row, {
2142
2148
  label: t("LOCATION_GEOTAG"),
@@ -6026,7 +6032,8 @@ const AddFixFillAddress = ({
6026
6032
  var _item$hierarchyType;
6027
6033
  return (item === null || item === void 0 ? void 0 : (_item$hierarchyType = item.hierarchyType) === null || _item$hierarchyType === void 0 ? void 0 : _item$hierarchyType.code) === "REVENUE";
6028
6034
  });
6029
- return (revenueData === null || revenueData === void 0 ? void 0 : revenueData.boundary) || [];
6035
+ const boundary = (revenueData === null || revenueData === void 0 ? void 0 : revenueData.boundary) || [];
6036
+ return Array.isArray(boundary) ? boundary : [boundary];
6030
6037
  }, [egovLocationData]);
6031
6038
  const structuredLocality = useMemo(() => {
6032
6039
  let localities = [];
@@ -6062,12 +6069,22 @@ const AddFixFillAddress = ({
6062
6069
  structuredLocality.forEach(loc => {
6063
6070
  if (loc.pincode) {
6064
6071
  const pins = Array.isArray(loc.pincode) ? loc.pincode : [loc.pincode];
6065
- pins.forEach(p => pinSet.add(p.toString()));
6072
+ pins.forEach(p => {
6073
+ if (p) {
6074
+ const sanitizedPin = p.toString().split(".")[0];
6075
+ pinSet.add(sanitizedPin);
6076
+ }
6077
+ });
6066
6078
  }
6067
6079
  });
6068
6080
  if (pinSet.size === 0 && city !== null && city !== void 0 && city.pincode) {
6069
6081
  const pins = Array.isArray(city.pincode) ? city.pincode : [city.pincode];
6070
- pins.forEach(p => pinSet.add(p.toString()));
6082
+ pins.forEach(p => {
6083
+ if (p) {
6084
+ const sanitizedPin = p.toString().split(".")[0];
6085
+ pinSet.add(sanitizedPin);
6086
+ }
6087
+ });
6071
6088
  }
6072
6089
  return Array.from(pinSet).sort().map(pin => ({
6073
6090
  code: pin,
@@ -6091,12 +6108,13 @@ const AddFixFillAddress = ({
6091
6108
  lastBookingId.current = currentId;
6092
6109
  }
6093
6110
  if (formData !== null && formData !== void 0 && formData.address && !isInitialized.current && allCities) {
6111
+ var _addressData$pincode;
6094
6112
  const addressData = formData.address;
6095
6113
  const cityObj = allCities.find(c => c.code === addressData.cityCode || c.code === addressData.city || c.name === addressData.city) || addressData.city;
6096
6114
  if (cityObj && (!city || city.code !== cityObj.code && city !== cityObj)) {
6097
6115
  setCity(cityObj || null);
6098
6116
  }
6099
- setPincode(addressData.pincode || "");
6117
+ setPincode(((_addressData$pincode = addressData.pincode) === null || _addressData$pincode === void 0 ? void 0 : _addressData$pincode.toString().split(".")[0]) || "");
6100
6118
  setHouseNo(addressData.houseNo || "");
6101
6119
  setStreetName(addressData.streetName || "");
6102
6120
  setLandmark(addressData.landmark || "");
@@ -6108,9 +6126,12 @@ const AddFixFillAddress = ({
6108
6126
  setLatitude(addressData.latitude || "");
6109
6127
  setLongitude(addressData.longitude || "");
6110
6128
  if (boundaryData || !addressData.cityCode) {
6111
- if (boundaryData) {
6129
+ if (Array.isArray(boundaryData)) {
6112
6130
  const localityObj = boundaryData.find(l => l.code === addressData.localityCode || l.code === addressData.locality || l.i18nkey === addressData.locality);
6113
6131
  setLocality(localityObj || addressData.locality || null);
6132
+ } else if (boundaryData && typeof boundaryData === "object") {
6133
+ const match = boundaryData.code === addressData.localityCode || boundaryData.code === addressData.locality || boundaryData.i18nkey === addressData.locality;
6134
+ setLocality(match ? boundaryData : addressData.locality || null);
6114
6135
  } else {
6115
6136
  setLocality(addressData.locality || null);
6116
6137
  }
@@ -6130,7 +6151,7 @@ const AddFixFillAddress = ({
6130
6151
  if (selectedAddress && Object.keys(selectedAddress).length) {
6131
6152
  setPincode(selectedAddress.pinCode);
6132
6153
  setCity(allCities === null || allCities === void 0 ? void 0 : allCities.find(c => c.name === selectedAddress.city));
6133
- setLocality(boundaryData === null || boundaryData === void 0 ? void 0 : boundaryData.find(l => l.i18nkey === selectedAddress.locality));
6154
+ setLocality(Array.isArray(boundaryData) ? boundaryData.find(l => l.i18nkey === selectedAddress.locality) : null);
6134
6155
  setHouseNo(selectedAddress.houseNumber);
6135
6156
  setStreetName(selectedAddress.streetName);
6136
6157
  setLandmark(selectedAddress.landmark);
@@ -6239,7 +6260,10 @@ const AddFixFillAddress = ({
6239
6260
  if (val !== null && val !== void 0 && val.ward) setBlock(val.ward);
6240
6261
  if (val !== null && val !== void 0 && val.pincode) {
6241
6262
  const p = Array.isArray(val.pincode) ? val.pincode[0] : val.pincode;
6242
- if (p) setPincode(p.toString());
6263
+ if (p) {
6264
+ const sanitizedPin = p.toString().split(".")[0];
6265
+ setPincode(sanitizedPin);
6266
+ }
6243
6267
  }
6244
6268
  },
6245
6269
  option: filteredLocalities,
@@ -6708,7 +6732,7 @@ const LocalityModal = ({
6708
6732
  data: mdmsData,
6709
6733
  isLoading: isMdmsLoading
6710
6734
  } = Digit.Hooks.hrms.useHrmsMDMS(tenantId, "egov-location", "HRMSRolesandDesignation");
6711
- const gethierarchylistdata = () => {
6735
+ const hierarchyOptions = useMemo(() => {
6712
6736
  var _ref, _ref$egovLocation;
6713
6737
  const tenantBoundary = ((_ref = (mdmsData === null || mdmsData === void 0 ? void 0 : mdmsData.MdmsRes) || mdmsData) === null || _ref === void 0 ? void 0 : (_ref$egovLocation = _ref["egov-location"]) === null || _ref$egovLocation === void 0 ? void 0 : _ref$egovLocation["TenantBoundary"]) || [];
6714
6738
  return tenantBoundary.map(ele => ({
@@ -6716,8 +6740,7 @@ const LocalityModal = ({
6716
6740
  code: ele.hierarchyType.code || ele.hierarchyType,
6717
6741
  boundary: ele.boundary
6718
6742
  }));
6719
- };
6720
- const hierarchyOptions = gethierarchylistdata();
6743
+ }, [mdmsData]);
6721
6744
  React.useEffect(() => {
6722
6745
  if (hierarchyOptions.length > 0 && !selectedHierarchy) {
6723
6746
  setSelectedHierarchy(hierarchyOptions[0]);
@@ -6743,17 +6766,19 @@ const LocalityModal = ({
6743
6766
  }, [selectedHierarchy]);
6744
6767
  React.useEffect(() => {
6745
6768
  var _initialValues$fillin, _initialValues$addres;
6746
- if (structuredLocalities.length > 0 && ((initialValues === null || initialValues === void 0 ? void 0 : (_initialValues$fillin = initialValues.fillingPointLocalityCodes) === null || _initialValues$fillin === void 0 ? void 0 : _initialValues$fillin.length) > 0 || initialValues !== null && initialValues !== void 0 && (_initialValues$addres = initialValues.address) !== null && _initialValues$addres !== void 0 && _initialValues$addres.locality) && (isView || isUpdate)) {
6769
+ if (structuredLocalities.length > 0 && selectedLocality.length === 0 && ((initialValues === null || initialValues === void 0 ? void 0 : (_initialValues$fillin = initialValues.fillingPointLocalityCodes) === null || _initialValues$fillin === void 0 ? void 0 : _initialValues$fillin.length) > 0 || initialValues !== null && initialValues !== void 0 && (_initialValues$addres = initialValues.address) !== null && _initialValues$addres !== void 0 && _initialValues$addres.locality) && (isView || isUpdate)) {
6747
6770
  var _initialValues$fillin2;
6748
- const currentLocalityCodes = (initialValues === null || initialValues === void 0 ? void 0 : (_initialValues$fillin2 = initialValues.fillingPointLocalityCodes) === null || _initialValues$fillin2 === void 0 ? void 0 : _initialValues$fillin2.length) > 0 ? initialValues.fillingPointLocalityCodes : initialValues.address.locality.split(",").map(s => s.trim());
6749
- const preSelected = structuredLocalities.filter(loc => currentLocalityCodes.includes(loc.code)).map(loc => [loc.i18nKey, loc]);
6750
- setSelectedLocality(preSelected);
6771
+ const currentLocalityCodes = (initialValues === null || initialValues === void 0 ? void 0 : (_initialValues$fillin2 = initialValues.fillingPointLocalityCodes) === null || _initialValues$fillin2 === void 0 ? void 0 : _initialValues$fillin2.length) > 0 ? initialValues.fillingPointLocalityCodes : typeof initialValues.address.locality === "string" ? initialValues.address.locality.split(",").map(s => s.trim()) : [];
6772
+ const preSelected = structuredLocalities.filter(loc => currentLocalityCodes.some(c => c === loc.code || c.toLowerCase() === (loc.name || "").toLowerCase()));
6773
+ if (preSelected.length > 0) {
6774
+ setSelectedLocality(preSelected);
6775
+ }
6751
6776
  }
6752
- }, [structuredLocalities, initialValues, isView, isUpdate]);
6777
+ }, [structuredLocalities, initialValues, isView, isUpdate, selectedLocality]);
6753
6778
  const onFormSubmit = () => {
6754
6779
  onSubmit({
6755
6780
  hierarchyType: selectedHierarchy,
6756
- locality: selectedLocality.map(l => l[1])
6781
+ locality: selectedLocality
6757
6782
  });
6758
6783
  };
6759
6784
  if (isMdmsLoading) return /*#__PURE__*/React.createElement(Loader, null);
@@ -6828,7 +6853,7 @@ const LocalityModal = ({
6828
6853
  fontWeight: "600",
6829
6854
  marginBottom: "8px"
6830
6855
  }
6831
- }, (initialValues === null || initialValues === void 0 ? void 0 : (_initialValues$fillin3 = initialValues.fillingPointLocalityCodes) === null || _initialValues$fillin3 === void 0 ? void 0 : _initialValues$fillin3.length) > 0 ? initialValues.fillingPointLocalityCodes.join(", ") : (initialValues === null || initialValues === void 0 ? void 0 : (_initialValues$addres2 = initialValues.address) === null || _initialValues$addres2 === void 0 ? void 0 : _initialValues$addres2.locality) || "NA")), !isView ? /*#__PURE__*/React.createElement("div", {
6856
+ }, (initialValues === null || initialValues === void 0 ? void 0 : (_initialValues$fillin3 = initialValues.fillingPointLocalityCodes) === null || _initialValues$fillin3 === void 0 ? void 0 : _initialValues$fillin3.length) > 0 ? initialValues.fillingPointLocalityCodes.join(", ") : (initialValues === null || initialValues === void 0 ? void 0 : (_initialValues$addres2 = initialValues.address) === null || _initialValues$addres2 === void 0 ? void 0 : _initialValues$addres2.locality) || "NA")), !isView && /*#__PURE__*/React.createElement("div", {
6832
6857
  style: {
6833
6858
  marginBottom: "16px"
6834
6859
  }
@@ -6837,7 +6862,10 @@ const LocalityModal = ({
6837
6862
  optionsKey: "i18nKey",
6838
6863
  selected: selectedLocality,
6839
6864
  onSelect: val => {
6840
- if (!isView) setSelectedLocality(val);
6865
+ if (!isView) {
6866
+ const unwrappedSelections = val.map(v => v[1]);
6867
+ setSelectedLocality(unwrappedSelections);
6868
+ }
6841
6869
  },
6842
6870
  t: t,
6843
6871
  disabled: !selectedHierarchy || isView
@@ -6847,28 +6875,7 @@ const LocalityModal = ({
6847
6875
  fontSize: "14px",
6848
6876
  color: "#666"
6849
6877
  }
6850
- }, /*#__PURE__*/React.createElement("strong", null, t("WT_LOCALITY_CODES"), ":"), " ", selectedLocality.map(l => l[1].code).join(", "))) : /*#__PURE__*/React.createElement("div", {
6851
- style: {
6852
- marginBottom: "16px"
6853
- }
6854
- }, /*#__PURE__*/React.createElement(CardLabel, null, t("WT_SELECTED_LOCALITIES")), /*#__PURE__*/React.createElement("div", {
6855
- style: {
6856
- display: "flex",
6857
- flexWrap: "wrap",
6858
- gap: "8px",
6859
- marginTop: "8px"
6860
- }
6861
- }, (selectedLocality === null || selectedLocality === void 0 ? void 0 : selectedLocality.length) > 0 ? selectedLocality.map((l, index) => /*#__PURE__*/React.createElement("span", {
6862
- key: index,
6863
- style: {
6864
- background: "#f4f4f4",
6865
- border: "1px solid #ddd",
6866
- borderRadius: "20px",
6867
- padding: "4px 12px",
6868
- fontSize: "14px",
6869
- color: "#333"
6870
- }
6871
- }, t(l[1].i18nKey), " (", l[1].code, ")")) : null))), /*#__PURE__*/React.createElement("div", {
6878
+ }, /*#__PURE__*/React.createElement("strong", null, t("WT_LOCALITY_CODES"), ":"), " ", selectedLocality.map(l => l.code).join(", ")))), /*#__PURE__*/React.createElement("div", {
6872
6879
  className: "custom-modal-footer",
6873
6880
  style: {
6874
6881
  padding: "16px 24px",
@@ -7088,7 +7095,7 @@ const SearchFillingPointAddress = () => {
7088
7095
  } = Digit.Hooks.wt.useUpdateFillingPointLocality(tenantId);
7089
7096
  const onLocalityModalSubmit = data => {
7090
7097
  const payload = {
7091
- FillingPointLocality: data.locality.map(loc => ({
7098
+ FillingPointLocality: data.locality.filter(loc => loc.code).map(loc => ({
7092
7099
  fillingPointId: selectedLocalityRow.bookingId || selectedLocalityRow.id,
7093
7100
  localityCode: loc.code
7094
7101
  }))