@djb25/digit-ui-module-wt 1.0.37 → 1.0.38

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.
@@ -6131,7 +6131,7 @@ const AddFixFillAddress = ({
6131
6131
  isEdit,
6132
6132
  userDetails
6133
6133
  }) => {
6134
- var _location$state, _formData$address, _formData$address2, _formData$address3, _formData$address4, _formData$address5, _formData$address6, _formData$address7, _formData$address8, _formData$address9, _formData$address0, _formData$address1, _formData$address10, _formData$address11, _userDetails$addresse;
6134
+ var _location$state, _formData$address, _formData$address2, _formData$address3, _formData$address4, _formData$address5, _formData$address6, _formData$address7, _formData$address8, _formData$address9, _formData$address0, _formData$address1, _formData$address10, _formData$address11, _formData$address12, _userDetails$addresse;
6135
6135
  const {
6136
6136
  data: allCities
6137
6137
  } = Digit.Hooks.useTenants();
@@ -6146,12 +6146,14 @@ const AddFixFillAddress = ({
6146
6146
  const [landmark, setLandmark] = useState((formData === null || formData === void 0 ? void 0 : (_formData$address6 = formData.address) === null || _formData$address6 === void 0 ? void 0 : _formData$address6.landmark) || "");
6147
6147
  const [addressLine1, setAddressLine1] = useState((formData === null || formData === void 0 ? void 0 : (_formData$address7 = formData.address) === null || _formData$address7 === void 0 ? void 0 : _formData$address7.addressLine1) || "");
6148
6148
  const [addressLine2, setAddressLine2] = useState((formData === null || formData === void 0 ? void 0 : (_formData$address8 = formData.address) === null || _formData$address8 === void 0 ? void 0 : _formData$address8.addressLine2) || "");
6149
- const [addressType, setAddressType] = useState((formData === null || formData === void 0 ? void 0 : (_formData$address9 = formData.address) === null || _formData$address9 === void 0 ? void 0 : _formData$address9.addressType) || null);
6149
+ const [addressType, setAddressType] = useState(formData !== null && formData !== void 0 && (_formData$address9 = formData.address) !== null && _formData$address9 !== void 0 && _formData$address9.addressType ? allOptions.find(a => a.code === formData.address.addressType) || formData.address.addressType : allOptions.find(a => a.code === "PERMANENT"));
6150
6150
  const [zone, setZone] = useState((formData === null || formData === void 0 ? void 0 : (_formData$address0 = formData.address) === null || _formData$address0 === void 0 ? void 0 : _formData$address0.zone) || "");
6151
6151
  const [block, setBlock] = useState((formData === null || formData === void 0 ? void 0 : (_formData$address1 = formData.address) === null || _formData$address1 === void 0 ? void 0 : _formData$address1.block) || "");
6152
- const [latitude, setLatitude] = useState((formData === null || formData === void 0 ? void 0 : (_formData$address10 = formData.address) === null || _formData$address10 === void 0 ? void 0 : _formData$address10.latitude) || "");
6153
- const [longitude, setLongitude] = useState((formData === null || formData === void 0 ? void 0 : (_formData$address11 = formData.address) === null || _formData$address11 === void 0 ? void 0 : _formData$address11.longitude) || "");
6152
+ const [assembly, setAssembly] = useState((formData === null || formData === void 0 ? void 0 : (_formData$address10 = formData.address) === null || _formData$address10 === void 0 ? void 0 : _formData$address10.assembly) || "");
6153
+ const [latitude, setLatitude] = useState((formData === null || formData === void 0 ? void 0 : (_formData$address11 = formData.address) === null || _formData$address11 === void 0 ? void 0 : _formData$address11.latitude) || "");
6154
+ const [longitude, setLongitude] = useState((formData === null || formData === void 0 ? void 0 : (_formData$address12 = formData.address) === null || _formData$address12 === void 0 ? void 0 : _formData$address12.longitude) || "");
6154
6155
  const [selectedAddress, setSelectedAddress] = useState("");
6156
+ const [showPincodeSuggestions, setShowPincodeSuggestions] = useState(false);
6155
6157
  const isInitialized = useRef(!isEdit);
6156
6158
  const lastSyncedAddress = useRef(null);
6157
6159
  const lastBookingId = useRef(null);
@@ -6183,27 +6185,32 @@ const AddFixFillAddress = ({
6183
6185
  const structuredLocality = useMemo(() => {
6184
6186
  let localities = [];
6185
6187
  const boundaries = Array.isArray(boundaryData) ? boundaryData : boundaryData ? [boundaryData] : [];
6186
- const extractLocalities = (node, zone = null, ward = null) => {
6188
+ const extractLocalities = (node, zone = null, ward = null, assembly = null) => {
6187
6189
  if (!node) return;
6188
6190
  let currentZone = zone;
6189
6191
  let currentWard = ward;
6192
+ let currentAssembly = assembly;
6190
6193
  if (node.label === "Zone" || node.label === "ZONE") {
6191
6194
  currentZone = node.localname || node.code || node.name;
6192
6195
  }
6193
6196
  if (node.label === "Ward" || node.label === "WARD" || node.label === "Block" || node.label === "BLOCK") {
6194
6197
  currentWard = node.code || node.localname || node.name;
6195
6198
  }
6199
+ if (node.label === "Assembly Constituency" || node.label === "ASSEMBLY_CONSTITUENCY") {
6200
+ currentAssembly = node.code || node.localname || node.name;
6201
+ }
6196
6202
  if (node.label === "Locality" || node.label === "LOCALITY") {
6197
6203
  localities.push({
6198
6204
  ...node,
6199
6205
  name: node.localname || node.name || node.code,
6200
6206
  i18nkey: node.i18nkey || `${tenantId.replace(".", "_")}_REVENUE_${node.code}`.toUpperCase(),
6201
6207
  zone: currentZone,
6202
- ward: currentWard
6208
+ ward: currentWard,
6209
+ assembly: currentAssembly
6203
6210
  });
6204
6211
  }
6205
6212
  if (node.children && node.children.length > 0) {
6206
- node.children.forEach(child => extractLocalities(child, currentZone, currentWard));
6213
+ node.children.forEach(child => extractLocalities(child, currentZone, currentWard, currentAssembly));
6207
6214
  }
6208
6215
  };
6209
6216
  boundaries.forEach(rootNode => extractLocalities(rootNode));
@@ -6239,15 +6246,17 @@ const AddFixFillAddress = ({
6239
6246
  }, [structuredLocality, city]);
6240
6247
  const filteredLocalities = useMemo(() => {
6241
6248
  if (!pincode) return structuredLocality;
6249
+ const isPincodeInList = fetchedPincodes.some(p => p.code === pincode);
6250
+ if (!isPincodeInList) return structuredLocality;
6242
6251
  return structuredLocality.filter(loc => {
6243
6252
  if (!loc.pincode) return false;
6244
6253
  const pins = Array.isArray(loc.pincode) ? loc.pincode : [loc.pincode];
6245
6254
  return pins.some(p => p.toString() === pincode);
6246
6255
  });
6247
- }, [structuredLocality, pincode]);
6256
+ }, [structuredLocality, pincode, fetchedPincodes]);
6248
6257
  useEffect(() => {
6249
- var _formData$address12;
6250
- const currentId = (formData === null || formData === void 0 ? void 0 : formData.id) || (formData === null || formData === void 0 ? void 0 : formData.bookingId) || (formData === null || formData === void 0 ? void 0 : (_formData$address12 = formData.address) === null || _formData$address12 === void 0 ? void 0 : _formData$address12.id);
6258
+ var _formData$address13;
6259
+ const currentId = (formData === null || formData === void 0 ? void 0 : formData.id) || (formData === null || formData === void 0 ? void 0 : formData.bookingId) || (formData === null || formData === void 0 ? void 0 : (_formData$address13 = formData.address) === null || _formData$address13 === void 0 ? void 0 : _formData$address13.id);
6251
6260
  if (currentId && lastBookingId.current !== currentId) {
6252
6261
  isInitialized.current = false;
6253
6262
  lastBookingId.current = currentId;
@@ -6265,26 +6274,25 @@ const AddFixFillAddress = ({
6265
6274
  setLandmark(addressData.landmark || "");
6266
6275
  setAddressLine1(addressData.addressLine1 || "");
6267
6276
  setAddressLine2(addressData.addressLine2 || "");
6268
- setAddressType(allOptions.find(a => a.code === addressData.addressType) || addressData.addressType || null);
6277
+ setAddressType(allOptions.find(a => a.code === addressData.addressType) || addressData.addressType || allOptions.find(a => a.code === "PERMANENT"));
6269
6278
  setZone(addressData.zone || "");
6270
6279
  setBlock(addressData.block || "");
6280
+ setAssembly(addressData.assembly || "");
6271
6281
  setLatitude(addressData.latitude || "");
6272
6282
  setLongitude(addressData.longitude || "");
6273
- if (boundaryData || !addressData.cityCode) {
6274
- if (Array.isArray(boundaryData)) {
6275
- const localityObj = boundaryData.find(l => l.code === addressData.localityCode || l.code === addressData.locality || l.i18nkey === addressData.locality);
6276
- setLocality(localityObj || addressData.locality || null);
6277
- } else if (boundaryData && typeof boundaryData === "object") {
6278
- const match = boundaryData.code === addressData.localityCode || boundaryData.code === addressData.locality || boundaryData.i18nkey === addressData.locality;
6279
- setLocality(match ? boundaryData : addressData.locality || null);
6280
- } else {
6281
- setLocality(addressData.locality || null);
6283
+ if ((structuredLocality === null || structuredLocality === void 0 ? void 0 : structuredLocality.length) > 0 || !addressData.cityCode) {
6284
+ const localityObj = structuredLocality.find(l => l.code === addressData.localityCode || l.code === addressData.locality || l.i18nkey === addressData.locality);
6285
+ setLocality(localityObj || addressData.locality || null);
6286
+ if (localityObj) {
6287
+ if (!addressData.zone && localityObj.zone) setZone(localityObj.zone);
6288
+ if (!addressData.block && localityObj.ward) setBlock(localityObj.ward);
6289
+ if (!addressData.assembly && localityObj.assembly) setAssembly(localityObj.assembly);
6282
6290
  }
6283
6291
  isInitialized.current = true;
6284
6292
  lastSyncedAddress.current = JSON.stringify(addressData);
6285
6293
  }
6286
6294
  }
6287
- }, [formData === null || formData === void 0 ? void 0 : formData.address, city, allCities, boundaryData]);
6295
+ }, [formData === null || formData === void 0 ? void 0 : formData.address, city, allCities, structuredLocality]);
6288
6296
  useEffect(() => {
6289
6297
  if (!navigator.geolocation) return;
6290
6298
  navigator.geolocation.getCurrentPosition(pos => {
@@ -6304,11 +6312,12 @@ const AddFixFillAddress = ({
6304
6312
  setAddressLine2(selectedAddress.address2);
6305
6313
  setZone(selectedAddress.zone);
6306
6314
  setBlock(selectedAddress.block);
6315
+ setAssembly(selectedAddress.assembly);
6307
6316
  setLatitude(selectedAddress.latitude);
6308
6317
  setLongitude(selectedAddress.longitude);
6309
6318
  setAddressType(allOptions.find(a => a.code === selectedAddress.addressType));
6310
6319
  }
6311
- }, [selectedAddress]);
6320
+ }, [selectedAddress, structuredLocality]);
6312
6321
  useEffect(() => {
6313
6322
  if (!onSelect || !isInitialized.current) return;
6314
6323
  const currentAddress = {
@@ -6323,6 +6332,7 @@ const AddFixFillAddress = ({
6323
6332
  addressType: (addressType === null || addressType === void 0 ? void 0 : addressType.code) || addressType || null,
6324
6333
  zone: zone || "",
6325
6334
  block: block || "",
6335
+ assembly: assembly || "",
6326
6336
  latitude: latitude || "",
6327
6337
  longitude: longitude || ""
6328
6338
  };
@@ -6331,7 +6341,7 @@ const AddFixFillAddress = ({
6331
6341
  lastSyncedAddress.current = addressString;
6332
6342
  onSelect((config === null || config === void 0 ? void 0 : config.key) || "address", currentAddress);
6333
6343
  }
6334
- }, [pincode, city, locality, houseNo, landmark, addressLine1, addressLine2, streetName, addressType, zone, block, latitude, longitude]);
6344
+ }, [pincode, city, locality, houseNo, landmark, addressLine1, addressLine2, streetName, addressType, zone, block, assembly, latitude, longitude]);
6335
6345
  return /*#__PURE__*/React.createElement(CollapsibleCardPage$1, {
6336
6346
  title: t("WT_ADDRESS_DETAILS"),
6337
6347
  defaultOpen: true
@@ -6364,16 +6374,16 @@ const AddFixFillAddress = ({
6364
6374
  optionKey: "i18nKey",
6365
6375
  t: t,
6366
6376
  disable: true
6367
- })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(CardLabel, null, t("PINCODE"), " ", /*#__PURE__*/React.createElement("span", {
6377
+ })), /*#__PURE__*/React.createElement("div", {
6378
+ style: {
6379
+ position: "relative"
6380
+ }
6381
+ }, /*#__PURE__*/React.createElement(CardLabel, null, t("PINCODE"), " ", /*#__PURE__*/React.createElement("span", {
6368
6382
  className: "astericColor"
6369
- }, "*")), /*#__PURE__*/React.createElement(Dropdown, {
6370
- selected: (fetchedPincodes === null || fetchedPincodes === void 0 ? void 0 : fetchedPincodes.find(p => p.code === pincode)) || (pincode ? {
6371
- code: pincode,
6372
- name: pincode,
6373
- i18nKey: pincode
6374
- } : null),
6375
- select: val => {
6376
- const newPin = val === null || val === void 0 ? void 0 : val.code;
6383
+ }, "*")), /*#__PURE__*/React.createElement(TextInput, {
6384
+ value: pincode,
6385
+ onChange: e => {
6386
+ const newPin = e.target.value.replace(/\D/g, "").slice(0, 6);
6377
6387
  if (newPin !== pincode) {
6378
6388
  setLocality(null);
6379
6389
  setZone("");
@@ -6384,14 +6394,40 @@ const AddFixFillAddress = ({
6384
6394
  setAddressLine2("");
6385
6395
  }
6386
6396
  setPincode(newPin);
6397
+ setShowPincodeSuggestions(true);
6398
+ },
6399
+ onFocus: () => setShowPincodeSuggestions(true),
6400
+ onBlur: () => {
6401
+ setTimeout(() => setShowPincodeSuggestions(false), 200);
6387
6402
  },
6388
- option: fetchedPincodes || [],
6389
- optionKey: "i18nKey",
6390
- t: t,
6391
6403
  style: {
6392
6404
  width: "100%"
6405
+ },
6406
+ maxlength: 6
6407
+ }), showPincodeSuggestions && (fetchedPincodes === null || fetchedPincodes === void 0 ? void 0 : fetchedPincodes.length) > 0 && /*#__PURE__*/React.createElement("div", {
6408
+ className: "options-card",
6409
+ style: {
6410
+ position: "absolute",
6411
+ zIndex: 100,
6412
+ width: "100%",
6413
+ maxHeight: "200px",
6414
+ overflowY: "auto",
6415
+ backgroundColor: "white",
6416
+ boxShadow: "0 2px 5px rgba(0,0,0,0.1)"
6393
6417
  }
6394
- })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(CardLabel, null, t("LOCALITY"), " ", /*#__PURE__*/React.createElement("span", {
6418
+ }, fetchedPincodes.filter(p => !pincode || p.code.toLowerCase().includes(pincode.toLowerCase())).map((p, index) => /*#__PURE__*/React.createElement("div", {
6419
+ key: index,
6420
+ className: "cp profile-dropdown--item",
6421
+ style: {
6422
+ padding: "10px",
6423
+ borderBottom: "1px solid #eee",
6424
+ cursor: "pointer"
6425
+ },
6426
+ onClick: () => {
6427
+ setPincode(p.code);
6428
+ setShowPincodeSuggestions(false);
6429
+ }
6430
+ }, p.code)))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(CardLabel, null, t("LOCALITY"), " ", /*#__PURE__*/React.createElement("span", {
6395
6431
  className: "astericColor"
6396
6432
  }, "*")), /*#__PURE__*/React.createElement(Dropdown, {
6397
6433
  selected: locality,
@@ -6403,13 +6439,7 @@ const AddFixFillAddress = ({
6403
6439
  if (val !== null && val !== void 0 && val.name) setAddressLine2(val.name);
6404
6440
  if (val !== null && val !== void 0 && val.zone) setZone(val.zone);
6405
6441
  if (val !== null && val !== void 0 && val.ward) setBlock(val.ward);
6406
- if (val !== null && val !== void 0 && val.pincode) {
6407
- const p = Array.isArray(val.pincode) ? val.pincode[0] : val.pincode;
6408
- if (p) {
6409
- const sanitizedPin = p.toString().split(".")[0];
6410
- setPincode(sanitizedPin);
6411
- }
6412
- }
6442
+ if (val !== null && val !== void 0 && val.assembly) setAssembly(val.assembly);
6413
6443
  },
6414
6444
  option: filteredLocalities,
6415
6445
  optionKey: "i18nkey",
@@ -6465,6 +6495,14 @@ const AddFixFillAddress = ({
6465
6495
  style: {
6466
6496
  width: "100%"
6467
6497
  }
6498
+ })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(CardLabel, null, t("ASSEMBLY_CONSTITUENCY"), " ", /*#__PURE__*/React.createElement("span", {
6499
+ className: "astericColor"
6500
+ }, "*")), /*#__PURE__*/React.createElement(TextInput, {
6501
+ value: assembly,
6502
+ onChange: e => setAssembly(e.target.value),
6503
+ style: {
6504
+ width: "100%"
6505
+ }
6468
6506
  })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(CardLabel, null, t("LATITUDE"), " ", /*#__PURE__*/React.createElement("span", {
6469
6507
  className: "astericColor"
6470
6508
  }, "*")), /*#__PURE__*/React.createElement(TextInput, {
@@ -6501,6 +6539,7 @@ const AddFillingPointAddress = () => {
6501
6539
  } = useTranslation();
6502
6540
  const location = useLocation();
6503
6541
  const history = useHistory();
6542
+ const queryClient = useQueryClient();
6504
6543
  const queryParams = new URLSearchParams(location.search);
6505
6544
  const editId = queryParams.get("id");
6506
6545
  const [formData, setFormData] = useState({});
@@ -6580,6 +6619,7 @@ const AddFillingPointAddress = () => {
6580
6619
  setShowToast({
6581
6620
  label: editId ? t("WT_FILLING_POINT_UPDATED_SUCCESS") : t("WT_FILLING_POINT_CREATED_SUCCESS")
6582
6621
  });
6622
+ queryClient.invalidateQueries("wtFillPointSearchList");
6583
6623
  setTimeout(() => {
6584
6624
  setShowToast(null);
6585
6625
  history.push(`/digit-ui/employee/wt/search-filling-fix-point`);