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

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"),
@@ -4476,8 +4482,10 @@ const reverseGeocode = async (lat, lng) => {
4476
4482
  return null;
4477
4483
  }
4478
4484
  };
4479
- const getAreaName = data => {
4480
- if (!data || !data.address) return "Unknown Address";
4485
+ const getAreaName = (data, useFull = false) => {
4486
+ if (!data) return "Unknown Address";
4487
+ if (useFull && data.display_name) return data.display_name;
4488
+ if (!data.address) return data.display_name || "Unknown Address";
4481
4489
  const {
4482
4490
  address
4483
4491
  } = data;
@@ -4580,6 +4588,9 @@ const MapController = ({
4580
4588
  return null;
4581
4589
  };
4582
4590
  const useRoute = (start, end) => {
4591
+ const {
4592
+ t
4593
+ } = useTranslation();
4583
4594
  const [routeData, setRouteData] = useState(null);
4584
4595
  const [loading, setLoading] = useState(false);
4585
4596
  const [error, setError] = useState(null);
@@ -4622,6 +4633,9 @@ const RouteLayer = ({
4622
4633
  color: _color = "#2196f3",
4623
4634
  weight: _weight = 6
4624
4635
  }) => {
4636
+ const {
4637
+ t
4638
+ } = useTranslation();
4625
4639
  const {
4626
4640
  routeData,
4627
4641
  loading,
@@ -5235,6 +5249,7 @@ function LiveTrackingSystem() {
5235
5249
  flexDirection: "column",
5236
5250
  height: "100vh",
5237
5251
  width: "100%",
5252
+ overflow: "hidden",
5238
5253
  fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, sans-serif",
5239
5254
  background: "#f0f2f5",
5240
5255
  padding: "16px",
@@ -5291,7 +5306,7 @@ function LiveTrackingSystem() {
5291
5306
  backgroundColor: isConnected ? "#4caf50" : "#f44336",
5292
5307
  boxShadow: isConnected ? "0 0 8px #4caf50" : "none"
5293
5308
  }
5294
- }), isConnected ? "CONNECTED" : "DISCONNECTED")), /*#__PURE__*/React.createElement("p", {
5309
+ }))), /*#__PURE__*/React.createElement("p", {
5295
5310
  style: {
5296
5311
  margin: "4px 0 0 0",
5297
5312
  fontSize: "14px",
@@ -5591,6 +5606,8 @@ function LiveTrackingSystem() {
5591
5606
  })))))), /*#__PURE__*/React.createElement("div", {
5592
5607
  style: {
5593
5608
  flex: 1,
5609
+ height: "100%",
5610
+ minHeight: 0,
5594
5611
  position: "relative",
5595
5612
  background: "white",
5596
5613
  borderRadius: "12px",
@@ -6026,7 +6043,8 @@ const AddFixFillAddress = ({
6026
6043
  var _item$hierarchyType;
6027
6044
  return (item === null || item === void 0 ? void 0 : (_item$hierarchyType = item.hierarchyType) === null || _item$hierarchyType === void 0 ? void 0 : _item$hierarchyType.code) === "REVENUE";
6028
6045
  });
6029
- return (revenueData === null || revenueData === void 0 ? void 0 : revenueData.boundary) || [];
6046
+ const boundary = (revenueData === null || revenueData === void 0 ? void 0 : revenueData.boundary) || [];
6047
+ return Array.isArray(boundary) ? boundary : [boundary];
6030
6048
  }, [egovLocationData]);
6031
6049
  const structuredLocality = useMemo(() => {
6032
6050
  let localities = [];
@@ -6062,12 +6080,22 @@ const AddFixFillAddress = ({
6062
6080
  structuredLocality.forEach(loc => {
6063
6081
  if (loc.pincode) {
6064
6082
  const pins = Array.isArray(loc.pincode) ? loc.pincode : [loc.pincode];
6065
- pins.forEach(p => pinSet.add(p.toString()));
6083
+ pins.forEach(p => {
6084
+ if (p) {
6085
+ const sanitizedPin = p.toString().split(".")[0];
6086
+ pinSet.add(sanitizedPin);
6087
+ }
6088
+ });
6066
6089
  }
6067
6090
  });
6068
6091
  if (pinSet.size === 0 && city !== null && city !== void 0 && city.pincode) {
6069
6092
  const pins = Array.isArray(city.pincode) ? city.pincode : [city.pincode];
6070
- pins.forEach(p => pinSet.add(p.toString()));
6093
+ pins.forEach(p => {
6094
+ if (p) {
6095
+ const sanitizedPin = p.toString().split(".")[0];
6096
+ pinSet.add(sanitizedPin);
6097
+ }
6098
+ });
6071
6099
  }
6072
6100
  return Array.from(pinSet).sort().map(pin => ({
6073
6101
  code: pin,
@@ -6091,12 +6119,13 @@ const AddFixFillAddress = ({
6091
6119
  lastBookingId.current = currentId;
6092
6120
  }
6093
6121
  if (formData !== null && formData !== void 0 && formData.address && !isInitialized.current && allCities) {
6122
+ var _addressData$pincode;
6094
6123
  const addressData = formData.address;
6095
6124
  const cityObj = allCities.find(c => c.code === addressData.cityCode || c.code === addressData.city || c.name === addressData.city) || addressData.city;
6096
6125
  if (cityObj && (!city || city.code !== cityObj.code && city !== cityObj)) {
6097
6126
  setCity(cityObj || null);
6098
6127
  }
6099
- setPincode(addressData.pincode || "");
6128
+ setPincode(((_addressData$pincode = addressData.pincode) === null || _addressData$pincode === void 0 ? void 0 : _addressData$pincode.toString().split(".")[0]) || "");
6100
6129
  setHouseNo(addressData.houseNo || "");
6101
6130
  setStreetName(addressData.streetName || "");
6102
6131
  setLandmark(addressData.landmark || "");
@@ -6108,9 +6137,12 @@ const AddFixFillAddress = ({
6108
6137
  setLatitude(addressData.latitude || "");
6109
6138
  setLongitude(addressData.longitude || "");
6110
6139
  if (boundaryData || !addressData.cityCode) {
6111
- if (boundaryData) {
6140
+ if (Array.isArray(boundaryData)) {
6112
6141
  const localityObj = boundaryData.find(l => l.code === addressData.localityCode || l.code === addressData.locality || l.i18nkey === addressData.locality);
6113
6142
  setLocality(localityObj || addressData.locality || null);
6143
+ } else if (boundaryData && typeof boundaryData === "object") {
6144
+ const match = boundaryData.code === addressData.localityCode || boundaryData.code === addressData.locality || boundaryData.i18nkey === addressData.locality;
6145
+ setLocality(match ? boundaryData : addressData.locality || null);
6114
6146
  } else {
6115
6147
  setLocality(addressData.locality || null);
6116
6148
  }
@@ -6130,7 +6162,7 @@ const AddFixFillAddress = ({
6130
6162
  if (selectedAddress && Object.keys(selectedAddress).length) {
6131
6163
  setPincode(selectedAddress.pinCode);
6132
6164
  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));
6165
+ setLocality(Array.isArray(boundaryData) ? boundaryData.find(l => l.i18nkey === selectedAddress.locality) : null);
6134
6166
  setHouseNo(selectedAddress.houseNumber);
6135
6167
  setStreetName(selectedAddress.streetName);
6136
6168
  setLandmark(selectedAddress.landmark);
@@ -6239,7 +6271,10 @@ const AddFixFillAddress = ({
6239
6271
  if (val !== null && val !== void 0 && val.ward) setBlock(val.ward);
6240
6272
  if (val !== null && val !== void 0 && val.pincode) {
6241
6273
  const p = Array.isArray(val.pincode) ? val.pincode[0] : val.pincode;
6242
- if (p) setPincode(p.toString());
6274
+ if (p) {
6275
+ const sanitizedPin = p.toString().split(".")[0];
6276
+ setPincode(sanitizedPin);
6277
+ }
6243
6278
  }
6244
6279
  },
6245
6280
  option: filteredLocalities,
@@ -6708,7 +6743,7 @@ const LocalityModal = ({
6708
6743
  data: mdmsData,
6709
6744
  isLoading: isMdmsLoading
6710
6745
  } = Digit.Hooks.hrms.useHrmsMDMS(tenantId, "egov-location", "HRMSRolesandDesignation");
6711
- const gethierarchylistdata = () => {
6746
+ const hierarchyOptions = useMemo(() => {
6712
6747
  var _ref, _ref$egovLocation;
6713
6748
  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
6749
  return tenantBoundary.map(ele => ({
@@ -6716,8 +6751,7 @@ const LocalityModal = ({
6716
6751
  code: ele.hierarchyType.code || ele.hierarchyType,
6717
6752
  boundary: ele.boundary
6718
6753
  }));
6719
- };
6720
- const hierarchyOptions = gethierarchylistdata();
6754
+ }, [mdmsData]);
6721
6755
  React.useEffect(() => {
6722
6756
  if (hierarchyOptions.length > 0 && !selectedHierarchy) {
6723
6757
  setSelectedHierarchy(hierarchyOptions[0]);
@@ -6743,17 +6777,19 @@ const LocalityModal = ({
6743
6777
  }, [selectedHierarchy]);
6744
6778
  React.useEffect(() => {
6745
6779
  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)) {
6780
+ 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
6781
  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);
6782
+ 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()) : [];
6783
+ const preSelected = structuredLocalities.filter(loc => currentLocalityCodes.some(c => c === loc.code || c.toLowerCase() === (loc.name || "").toLowerCase()));
6784
+ if (preSelected.length > 0) {
6785
+ setSelectedLocality(preSelected);
6786
+ }
6751
6787
  }
6752
- }, [structuredLocalities, initialValues, isView, isUpdate]);
6788
+ }, [structuredLocalities, initialValues, isView, isUpdate, selectedLocality]);
6753
6789
  const onFormSubmit = () => {
6754
6790
  onSubmit({
6755
6791
  hierarchyType: selectedHierarchy,
6756
- locality: selectedLocality.map(l => l[1])
6792
+ locality: selectedLocality
6757
6793
  });
6758
6794
  };
6759
6795
  if (isMdmsLoading) return /*#__PURE__*/React.createElement(Loader, null);
@@ -6828,7 +6864,7 @@ const LocalityModal = ({
6828
6864
  fontWeight: "600",
6829
6865
  marginBottom: "8px"
6830
6866
  }
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", {
6867
+ }, (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
6868
  style: {
6833
6869
  marginBottom: "16px"
6834
6870
  }
@@ -6837,7 +6873,10 @@ const LocalityModal = ({
6837
6873
  optionsKey: "i18nKey",
6838
6874
  selected: selectedLocality,
6839
6875
  onSelect: val => {
6840
- if (!isView) setSelectedLocality(val);
6876
+ if (!isView) {
6877
+ const unwrappedSelections = val.map(v => v[1]);
6878
+ setSelectedLocality(unwrappedSelections);
6879
+ }
6841
6880
  },
6842
6881
  t: t,
6843
6882
  disabled: !selectedHierarchy || isView
@@ -6847,28 +6886,7 @@ const LocalityModal = ({
6847
6886
  fontSize: "14px",
6848
6887
  color: "#666"
6849
6888
  }
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", {
6889
+ }, /*#__PURE__*/React.createElement("strong", null, t("WT_LOCALITY_CODES"), ":"), " ", selectedLocality.map(l => l.code).join(", ")))), /*#__PURE__*/React.createElement("div", {
6872
6890
  className: "custom-modal-footer",
6873
6891
  style: {
6874
6892
  padding: "16px 24px",
@@ -7088,7 +7106,7 @@ const SearchFillingPointAddress = () => {
7088
7106
  } = Digit.Hooks.wt.useUpdateFillingPointLocality(tenantId);
7089
7107
  const onLocalityModalSubmit = data => {
7090
7108
  const payload = {
7091
- FillingPointLocality: data.locality.map(loc => ({
7109
+ FillingPointLocality: data.locality.filter(loc => loc.code).map(loc => ({
7092
7110
  fillingPointId: selectedLocalityRow.bookingId || selectedLocalityRow.id,
7093
7111
  localityCode: loc.code
7094
7112
  }))