@djb25/digit-ui-module-wt 1.0.22 → 1.0.23

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.
@@ -3757,6 +3757,7 @@ const FixedPointScheduleManagement = ({
3757
3757
  const {
3758
3758
  t
3759
3759
  } = useTranslation();
3760
+ const queryClient = useQueryClient();
3760
3761
  const tenantId = Digit.ULBService.getCurrentTenantId();
3761
3762
  const [showModal, setShowModal] = useState(false);
3762
3763
  const [toast, setToast] = useState(null);
@@ -3782,8 +3783,7 @@ const FixedPointScheduleManagement = ({
3782
3783
  });
3783
3784
  const {
3784
3785
  isLoading,
3785
- data: scheduleData,
3786
- refetch: reSearch
3786
+ data: scheduleData
3787
3787
  } = Digit.Hooks.wt.useFixedPointScheduleSearch(tenantId, filters);
3788
3788
  const {
3789
3789
  data: fixedPointData,
@@ -3855,10 +3855,10 @@ const FixedPointScheduleManagement = ({
3855
3855
  document.body.removeChild(a);
3856
3856
  }
3857
3857
  };
3858
- const [data, setData] = useState([]);
3859
3858
  const mapScheduleRows = React.useCallback((rows = []) => rows.map(item => ({
3860
3859
  scheduleId: item.systemAssignedScheduleId,
3861
- fixedPoint: item.fixedPointCode,
3860
+ fixedPointName: item.fixedPointName,
3861
+ fixedPoint: item.fixedPointId,
3862
3862
  day: item.day,
3863
3863
  freq: item.tripNo,
3864
3864
  arrToFpl: item.arrivalTimeToFpl,
@@ -3871,11 +3871,9 @@ const FixedPointScheduleManagement = ({
3871
3871
  active: item.isEnable ? "Y" : "N",
3872
3872
  totalCount: item.totalCount
3873
3873
  })), []);
3874
- React.useEffect(() => {
3875
- if (scheduleData !== null && scheduleData !== void 0 && scheduleData.fixedPointTimeTableDetails) {
3876
- setData(mapScheduleRows(scheduleData.fixedPointTimeTableDetails));
3877
- }
3878
- }, [mapScheduleRows, scheduleData]);
3874
+ const data = React.useMemo(() => {
3875
+ return mapScheduleRows((scheduleData === null || scheduleData === void 0 ? void 0 : scheduleData.fixedPointTimeTableDetails) || []);
3876
+ }, [scheduleData, mapScheduleRows]);
3879
3877
  const fetchNextPage = () => {
3880
3878
  setPageOffset(prevState => prevState + pageSize);
3881
3879
  };
@@ -3906,7 +3904,10 @@ const FixedPointScheduleManagement = ({
3906
3904
  }
3907
3905
  }, [pageOffset, pageSize]);
3908
3906
  const columns = React.useMemo(() => [{
3909
- Header: t("WT_FIXED_POINT"),
3907
+ Header: t("WT_FIXED_POINT_NAME"),
3908
+ accessor: "fixedPointName"
3909
+ }, {
3910
+ Header: t("WT_FIXED_POINT_CODE"),
3910
3911
  accessor: "fixedPoint"
3911
3912
  }, {
3912
3913
  Header: t("WT_DAY"),
@@ -4030,6 +4031,26 @@ const FixedPointScheduleManagement = ({
4030
4031
  accessor: "active"
4031
4032
  }], [t]);
4032
4033
  const days = ["MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"];
4034
+ const clearSearch = () => {
4035
+ setSelectedDay("all");
4036
+ setDay({
4037
+ label: "All Days",
4038
+ value: "all"
4039
+ });
4040
+ setFixedPoint({
4041
+ label: "All Fixed Points",
4042
+ value: "all"
4043
+ });
4044
+ setStatus({
4045
+ label: "All Status",
4046
+ value: "all"
4047
+ });
4048
+ setPageOffset(0);
4049
+ setFilters({
4050
+ limit: pageSize,
4051
+ offset: 0
4052
+ });
4053
+ };
4033
4054
  return /*#__PURE__*/React.createElement("div", {
4034
4055
  className: "fixed-point-schedule-management"
4035
4056
  }, /*#__PURE__*/React.createElement(Card, {
@@ -4142,6 +4163,17 @@ const FixedPointScheduleManagement = ({
4142
4163
  style: {
4143
4164
  alignSelf: "flex-end"
4144
4165
  }
4166
+ }, /*#__PURE__*/React.createElement("span", {
4167
+ className: "clear-search",
4168
+ onClick: clearSearch,
4169
+ style: {
4170
+ alignSelf: "center"
4171
+ }
4172
+ }, t("ES_COMMON_CLEAR_SEARCH"))), /*#__PURE__*/React.createElement("div", {
4173
+ className: "finance-mainlayout-col1",
4174
+ style: {
4175
+ alignSelf: "flex-end"
4176
+ }
4145
4177
  }, /*#__PURE__*/React.createElement(SubmitBar, {
4146
4178
  label: t("ES_COMMON_SEARCH"),
4147
4179
  onSubmit: () => handleSearch()
@@ -4306,7 +4338,7 @@ const FixedPointScheduleManagement = ({
4306
4338
  setTimeout(closeToast, 5000);
4307
4339
  setShowModal(false);
4308
4340
  setEditingRowIndex(null);
4309
- reSearch();
4341
+ queryClient.invalidateQueries(["FIXED_POINT_SCHEDULE_SEARCH", tenantId]);
4310
4342
  }
4311
4343
  });
4312
4344
  } else {
@@ -4326,7 +4358,7 @@ const FixedPointScheduleManagement = ({
4326
4358
  setTimeout(closeToast, 5000);
4327
4359
  setShowModal(false);
4328
4360
  setEditingRowIndex(null);
4329
- reSearch();
4361
+ queryClient.invalidateQueries(["FIXED_POINT_SCHEDULE_SEARCH", tenantId]);
4330
4362
  }
4331
4363
  });
4332
4364
  }
@@ -4753,7 +4785,8 @@ const StatusBadge = ({
4753
4785
  const DriverCard = ({
4754
4786
  driver,
4755
4787
  isSelected,
4756
- onClick
4788
+ onClick,
4789
+ vendorList
4757
4790
  }) => {
4758
4791
  const [currentAddress, setCurrentAddress] = useState("Resolving area...");
4759
4792
  const [deliveryAddress, setDeliveryAddress] = useState("Resolving area...");
@@ -4797,6 +4830,21 @@ const DriverCard = ({
4797
4830
  };
4798
4831
  resolveDest();
4799
4832
  }, [driver.deliveryLat, driver.deliveryLng]);
4833
+ const vehicleNumber = useMemo(() => {
4834
+ if (!vendorList || !vendorList.length) return null;
4835
+ for (const vendor of vendorList) {
4836
+ if (!vendor.drivers || !vendor.drivers.length) continue;
4837
+ const driverMatch = vendor.drivers.find(d => {
4838
+ var _d$owner, _d$owner2, _d$owner3, _d$owner4;
4839
+ return ((_d$owner = d.owner) === null || _d$owner === void 0 ? void 0 : _d$owner.mobileNumber) === driver.driverId || ((_d$owner2 = d.owner) === null || _d$owner2 === void 0 ? void 0 : _d$owner2.uuid) === driver.driverId || d.id === driver.driverId || String((_d$owner3 = d.owner) === null || _d$owner3 === void 0 ? void 0 : _d$owner3.mobileNumber) === String(driver.driverId) || String((_d$owner4 = d.owner) === null || _d$owner4 === void 0 ? void 0 : _d$owner4.uuid) === String(driver.driverId);
4840
+ });
4841
+ if (driverMatch && vendor.vehicles && vendor.vehicles.length > 0) {
4842
+ var _vendor$vehicles$, _vendor$vehicles$2;
4843
+ return ((_vendor$vehicles$ = vendor.vehicles[0]) === null || _vendor$vehicles$ === void 0 ? void 0 : _vendor$vehicles$.registrationNumber) || ((_vendor$vehicles$2 = vendor.vehicles[0]) === null || _vendor$vehicles$2 === void 0 ? void 0 : _vendor$vehicles$2.vehicleNo) || null;
4844
+ }
4845
+ }
4846
+ return null;
4847
+ }, [vendorList, driver.driverId]);
4800
4848
  const calculateETA = () => {
4801
4849
  if (!driver.lat || !driver.lng || !driver.deliveryLat || !driver.deliveryLng) return null;
4802
4850
  const distance = calculateDistance$1(driver.lat, driver.lng, driver.deliveryLat, driver.deliveryLng);
@@ -4952,7 +5000,16 @@ const DriverCard = ({
4952
5000
  gridTemplateColumns: "1fr 1fr",
4953
5001
  gap: "4px"
4954
5002
  }
4955
- }, driver.accuracy && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, "Accuracy"), /*#__PURE__*/React.createElement("span", null, Math.round(driver.accuracy), "m")), driver.heading && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, "Heading"), /*#__PURE__*/React.createElement("span", null, Math.round(driver.heading), "\xB0")), driver.lastSeen && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, "Last seen"), /*#__PURE__*/React.createElement("span", null, new Date(driver.lastSeen).toLocaleTimeString()))));
5003
+ }, vehicleNumber && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
5004
+ style: {
5005
+ color: "#555"
5006
+ }
5007
+ }, "Vehicle"), /*#__PURE__*/React.createElement("span", {
5008
+ style: {
5009
+ fontWeight: "600",
5010
+ color: "#667eea"
5011
+ }
5012
+ }, vehicleNumber)), driver.accuracy && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, "Accuracy"), /*#__PURE__*/React.createElement("span", null, Math.round(driver.accuracy), "m")), driver.heading && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, "Heading"), /*#__PURE__*/React.createElement("span", null, Math.round(driver.heading), "\xB0")), driver.lastSeen && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, "Last seen"), /*#__PURE__*/React.createElement("span", null, new Date(driver.lastSeen).toLocaleTimeString()))));
4956
5013
  };
4957
5014
  function calculateDistance$1(lat1, lon1, lat2, lon2) {
4958
5015
  return calculateDistance(lat1, lon1, lat2, lon2);
@@ -4996,8 +5053,33 @@ function LiveTrackingSystem() {
4996
5053
  select: data => (data === null || data === void 0 ? void 0 : data.vendor) || []
4997
5054
  }
4998
5055
  });
5056
+ const filteredVendorOptions = useMemo(() => {
5057
+ if (!vendorOptions || !vendorOptions.length) return [];
5058
+ if (!selectedFillingPoint) return vendorOptions;
5059
+ return vendorOptions.filter(vendor => {
5060
+ var _vendor$fillingPoint;
5061
+ return (vendor === null || vendor === void 0 ? void 0 : (_vendor$fillingPoint = vendor.fillingPoint) === null || _vendor$fillingPoint === void 0 ? void 0 : _vendor$fillingPoint.id) === (selectedFillingPoint === null || selectedFillingPoint === void 0 ? void 0 : selectedFillingPoint.id);
5062
+ });
5063
+ }, [vendorOptions, selectedFillingPoint]);
5064
+ useEffect(() => {
5065
+ if (vendorOptions !== null && vendorOptions !== void 0 && vendorOptions.length && Object.keys(drivers).length) {
5066
+ var _vendorOptions$, _vendorOptions$2, _vendorOptions$2$driv;
5067
+ console.log("=== VENDOR DEBUG ===");
5068
+ console.log("Vendor[0] vehicles:", (_vendorOptions$ = vendorOptions[0]) === null || _vendorOptions$ === void 0 ? void 0 : _vendorOptions$.vehicles);
5069
+ console.log("Vendor[0] drivers:", (_vendorOptions$2 = vendorOptions[0]) === null || _vendorOptions$2 === void 0 ? void 0 : (_vendorOptions$2$driv = _vendorOptions$2.drivers) === null || _vendorOptions$2$driv === void 0 ? void 0 : _vendorOptions$2$driv.map(d => {
5070
+ var _d$owner5, _d$owner6;
5071
+ return {
5072
+ id: d.id,
5073
+ mobile: (_d$owner5 = d.owner) === null || _d$owner5 === void 0 ? void 0 : _d$owner5.mobileNumber,
5074
+ uuid: (_d$owner6 = d.owner) === null || _d$owner6 === void 0 ? void 0 : _d$owner6.uuid
5075
+ };
5076
+ }));
5077
+ console.log("Socket driverId example:", Object.keys(drivers)[0]);
5078
+ }
5079
+ }, [vendorOptions, drivers]);
4999
5080
  const handleFillingPointSelect = value => {
5000
5081
  setSelectedFillingPoint(value);
5082
+ setSelectedVendor(null);
5001
5083
  };
5002
5084
  useEffect(() => {
5003
5085
  const handleResize = () => {
@@ -5084,8 +5166,24 @@ function LiveTrackingSystem() {
5084
5166
  const filteredDrivers = Object.values(drivers).filter(driver => {
5085
5167
  const matchesSearch = driver.driverId.toLowerCase().includes(searchTerm.toLowerCase());
5086
5168
  const matchesStatus = filterOnline === "all" || filterOnline === "online" && driver.isOnline || filterOnline === "offline" && !driver.isOnline;
5087
- const matchesFillingPoint = !selectedFillingPoint || driver.fillingPointId === selectedFillingPoint.id;
5088
- const matchesVendor = !selectedVendor || driver.vendorId === (selectedVendor.id || selectedVendor.code);
5169
+ const matchesFillingPoint = !selectedFillingPoint || (() => {
5170
+ if (!vendorOptions || !vendorOptions.length) return false;
5171
+ return vendorOptions.some(vendor => {
5172
+ var _vendor$fillingPoint2, _vendor$drivers;
5173
+ if ((vendor === null || vendor === void 0 ? void 0 : (_vendor$fillingPoint2 = vendor.fillingPoint) === null || _vendor$fillingPoint2 === void 0 ? void 0 : _vendor$fillingPoint2.id) !== (selectedFillingPoint === null || selectedFillingPoint === void 0 ? void 0 : selectedFillingPoint.id)) return false;
5174
+ return (_vendor$drivers = vendor.drivers) === null || _vendor$drivers === void 0 ? void 0 : _vendor$drivers.some(d => {
5175
+ var _d$owner7, _d$owner8, _d$owner9, _d$owner0;
5176
+ return ((_d$owner7 = d.owner) === null || _d$owner7 === void 0 ? void 0 : _d$owner7.mobileNumber) === driver.driverId || ((_d$owner8 = d.owner) === null || _d$owner8 === void 0 ? void 0 : _d$owner8.uuid) === driver.driverId || d.id === driver.driverId || String((_d$owner9 = d.owner) === null || _d$owner9 === void 0 ? void 0 : _d$owner9.mobileNumber) === String(driver.driverId) || String((_d$owner0 = d.owner) === null || _d$owner0 === void 0 ? void 0 : _d$owner0.uuid) === String(driver.driverId);
5177
+ });
5178
+ });
5179
+ })();
5180
+ const matchesVendor = !selectedVendor || (_selectedVendor$drive => {
5181
+ const vendorDriverIds = ((_selectedVendor$drive = selectedVendor.drivers) === null || _selectedVendor$drive === void 0 ? void 0 : _selectedVendor$drive.map(d => {
5182
+ var _d$owner1, _d$owner10, _d$owner11, _d$owner12;
5183
+ return [(_d$owner1 = d.owner) === null || _d$owner1 === void 0 ? void 0 : _d$owner1.mobileNumber, (_d$owner10 = d.owner) === null || _d$owner10 === void 0 ? void 0 : _d$owner10.uuid, d.id, String((_d$owner11 = d.owner) === null || _d$owner11 === void 0 ? void 0 : _d$owner11.mobileNumber), String((_d$owner12 = d.owner) === null || _d$owner12 === void 0 ? void 0 : _d$owner12.uuid)];
5184
+ }).flat().filter(Boolean)) || [];
5185
+ return vendorDriverIds.some(id => driver.driverId === id);
5186
+ })();
5089
5187
  return matchesSearch && matchesStatus && matchesFillingPoint && matchesVendor;
5090
5188
  });
5091
5189
  const onlineCount = Object.values(drivers).filter(d => d.isOnline).length;
@@ -5292,7 +5390,7 @@ function LiveTrackingSystem() {
5292
5390
  }
5293
5391
  }), /*#__PURE__*/React.createElement(Dropdown, {
5294
5392
  t: t,
5295
- option: vendorOptions,
5393
+ option: filteredVendorOptions,
5296
5394
  optionKey: "name",
5297
5395
  select: setSelectedVendor,
5298
5396
  selected: selectedVendor,
@@ -5395,6 +5493,7 @@ function LiveTrackingSystem() {
5395
5493
  key: driver.driverId,
5396
5494
  driver: driver,
5397
5495
  isSelected: (selectedDriver === null || selectedDriver === void 0 ? void 0 : selectedDriver.driverId) === driver.driverId,
5496
+ vendorList: vendorOptions,
5398
5497
  onClick: () => {
5399
5498
  setSelectedDriver(driver);
5400
5499
  if (isMobile) {
@@ -6630,7 +6729,7 @@ const SearchFillingPointAddress = () => {
6630
6729
  placeholder: "WT_ENTER_FIXED_POINT_NAME"
6631
6730
  },
6632
6731
  FILLING_POINT: {
6633
- label: "WT_FILLING_POINT_CODE",
6732
+ label: "WT_FILLING_POINT_NAME",
6634
6733
  placeholder: "WT_ENTER_FILLING_POINT_NAME"
6635
6734
  }
6636
6735
  };
@@ -6761,10 +6860,17 @@ const SearchFillingPointAddress = () => {
6761
6860
  const columns = React.useMemo(() => {
6762
6861
  if (selectedTab === "FIXED_POINT") {
6763
6862
  return [{
6764
- Header: t("WT_FIXING_POINT_APPLICANT_DETAILS"),
6863
+ Header: t("WT_FIXED_POINT_CODE"),
6765
6864
  accessor: row => {
6766
6865
  var _row$applicantDetail;
6767
- return (row === null || row === void 0 ? void 0 : (_row$applicantDetail = row.applicantDetail) === null || _row$applicantDetail === void 0 ? void 0 : _row$applicantDetail.name) || "NA";
6866
+ return (row === null || row === void 0 ? void 0 : (_row$applicantDetail = row.applicantDetail) === null || _row$applicantDetail === void 0 ? void 0 : _row$applicantDetail.fixedPointId) || "NA";
6867
+ },
6868
+ id: "fixedPointId"
6869
+ }, {
6870
+ Header: t("WT_FIXING_POINT_APPLICANT_DETAILS"),
6871
+ accessor: row => {
6872
+ var _row$applicantDetail2;
6873
+ return (row === null || row === void 0 ? void 0 : (_row$applicantDetail2 = row.applicantDetail) === null || _row$applicantDetail2 === void 0 ? void 0 : _row$applicantDetail2.name) || "NA";
6768
6874
  },
6769
6875
  id: "applicantName",
6770
6876
  Cell: ({
@@ -6780,8 +6886,8 @@ const SearchFillingPointAddress = () => {
6780
6886
  }, {
6781
6887
  Header: t("WT_MOBILE_NUMBER"),
6782
6888
  accessor: row => {
6783
- var _row$applicantDetail2;
6784
- return (row === null || row === void 0 ? void 0 : (_row$applicantDetail2 = row.applicantDetail) === null || _row$applicantDetail2 === void 0 ? void 0 : _row$applicantDetail2.mobileNumber) || "NA";
6889
+ var _row$applicantDetail3;
6890
+ return (row === null || row === void 0 ? void 0 : (_row$applicantDetail3 = row.applicantDetail) === null || _row$applicantDetail3 === void 0 ? void 0 : _row$applicantDetail3.mobileNumber) || "NA";
6785
6891
  },
6786
6892
  id: "mobileNumber"
6787
6893
  }, {
@@ -6824,6 +6930,10 @@ const SearchFillingPointAddress = () => {
6824
6930
  } else {
6825
6931
  return [{
6826
6932
  Header: t("WT_FILLING_POINT_CODE"),
6933
+ accessor: row => (row === null || row === void 0 ? void 0 : row.fillingPointId) || "NA",
6934
+ id: "fillingPointId"
6935
+ }, {
6936
+ Header: t("WT_FILLING_POINT_NAME"),
6827
6937
  accessor: row => (row === null || row === void 0 ? void 0 : row.fillingPointName) || "NA",
6828
6938
  id: "fillingPointName",
6829
6939
  Cell: ({
@@ -6975,14 +7085,14 @@ const SearchFillingPointAddress = () => {
6975
7085
  return [{
6976
7086
  Header: t("WT_APPLICANT_NAME"),
6977
7087
  exportAccessor: row => {
6978
- var _row$applicantDetail3;
6979
- return (row === null || row === void 0 ? void 0 : (_row$applicantDetail3 = row.applicantDetail) === null || _row$applicantDetail3 === void 0 ? void 0 : _row$applicantDetail3.name) || "NA";
7088
+ var _row$applicantDetail4;
7089
+ return (row === null || row === void 0 ? void 0 : (_row$applicantDetail4 = row.applicantDetail) === null || _row$applicantDetail4 === void 0 ? void 0 : _row$applicantDetail4.name) || "NA";
6980
7090
  }
6981
7091
  }, {
6982
7092
  Header: t("WT_MOBILE_NUMBER"),
6983
7093
  exportAccessor: row => {
6984
- var _row$applicantDetail4;
6985
- return (row === null || row === void 0 ? void 0 : (_row$applicantDetail4 = row.applicantDetail) === null || _row$applicantDetail4 === void 0 ? void 0 : _row$applicantDetail4.mobileNumber) || "NA";
7094
+ var _row$applicantDetail5;
7095
+ return (row === null || row === void 0 ? void 0 : (_row$applicantDetail5 = row.applicantDetail) === null || _row$applicantDetail5 === void 0 ? void 0 : _row$applicantDetail5.mobileNumber) || "NA";
6986
7096
  }
6987
7097
  }, {
6988
7098
  Header: t("WT_LOCALITY"),