@djb25/digit-ui-module-wt 1.0.47 → 1.0.49

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.
@@ -699,12 +699,14 @@ const fixedPointPayload = data => {
699
699
  };
700
700
  };
701
701
  const emergencyWaterTankerPayload = data => {
702
- var _data$owner29, _data$owner30, _ref2, _data$requestDetails12, _data$requestDetails13, _data$requestDetails14, _data$requestDetails15, _data$requestDetails16, _data$requestDetails17, _data$requestDetails18, _data$requestDetails19, _data$requestDetails20, _data$requestDetails21, _data$requestDetails22, _data$requestDetails23, _data$requestDetails24, _data$requestDetails25, _data$requestDetails26, _data$requestDetails27, _data$requestDetails28, _data$requestDetails29, _data$address82, _data$dispatchDetails, _data$dispatchDetails2, _data$owner31, _data$owner31$vendor, _data$dispatchDetails3, _data$dispatchDetails4, _data$owner32, _data$owner32$vehicle, _data$dispatchDetails5, _data$dispatchDetails6, _data$owner33, _data$owner33$driver, _data$dispatchDetails7, _data$dispatchDetails8, _data$owner34, _data$owner34$filling, _data$dispatchDetails9, _data$dispatchDetails0, _data$owner35, _data$owner35$vehicle, _data$dispatchDetails1, _data$dispatchDetails10, _data$owner36, _data$owner36$vehicle, _data$owner37, _data$owner38, _data$owner39, _data$owner40, _data$owner41, _data$owner42, _data$address83, _data$address84, _data$address84$addre, _data$address85, _data$address86, _data$address87, _data$address87$city, _data$address87$city$, _data$address88, _data$address88$city, _data$address89, _data$address90, _data$address90$city, _data$address90$city$, _data$address91, _data$address92, _data$address93, _data$address94, _data$address94$local, _data$address95, _data$address95$local, _data$address96, _data$address97, _data$address97$local, _data$address98, _data$address99, _data$address100, _data$address101, _data$address102, _data$address103, _data$address104, _data$address105, _data$address106, _data$address107, _data$address108, _data$requestDetails30;
702
+ var _data$owner29, _data$waterTankerBook, _data$waterTankerBook2, _data$owner30, _ref2, _data$requestDetails12, _data$requestDetails13, _data$requestDetails14, _data$requestDetails15, _data$requestDetails16, _data$requestDetails17, _data$requestDetails18, _data$requestDetails19, _data$requestDetails20, _data$requestDetails21, _data$requestDetails22, _data$requestDetails23, _data$requestDetails24, _data$requestDetails25, _data$requestDetails26, _data$requestDetails27, _data$requestDetails28, _data$requestDetails29, _data$address82, _data$dispatchDetails, _data$dispatchDetails2, _data$owner31, _data$owner31$vendor, _data$dispatchDetails3, _data$dispatchDetails4, _data$owner32, _data$owner32$vehicle, _data$dispatchDetails5, _data$dispatchDetails6, _data$owner33, _data$owner33$driver, _data$dispatchDetails7, _data$dispatchDetails8, _data$owner34, _data$owner34$filling, _data$dispatchDetails9, _data$dispatchDetails0, _data$owner35, _data$owner35$vehicle, _data$dispatchDetails1, _data$dispatchDetails10, _data$owner36, _data$owner36$vehicle, _data$owner37, _data$owner38, _data$owner39, _data$owner40, _data$owner41, _data$owner42, _data$address83, _data$address84, _data$address84$addre, _data$address85, _data$address86, _data$address87, _data$address87$city, _data$address87$city$, _data$address88, _data$address88$city, _data$address89, _data$address90, _data$address90$city, _data$address90$city$, _data$address91, _data$address92, _data$address93, _data$address94, _data$address94$local, _data$address95, _data$address95$local, _data$address96, _data$address97, _data$address97$local, _data$address98, _data$address99, _data$address100, _data$address101, _data$address102, _data$address103, _data$address104, _data$address105, _data$address106, _data$address107, _data$address108, _data$requestDetails30;
703
703
  const fixedPoint = data === null || data === void 0 ? void 0 : (_data$owner29 = data.owner) === null || _data$owner29 === void 0 ? void 0 : _data$owner29.fixedPoint;
704
704
  const applicantDetailFromFP = (fixedPoint === null || fixedPoint === void 0 ? void 0 : fixedPoint.applicantDetail) || {};
705
705
  const addressFromFP = (fixedPoint === null || fixedPoint === void 0 ? void 0 : fixedPoint.address) || {};
706
706
  const formdata = {
707
707
  waterTankerBookingDetail: {
708
+ id: (data === null || data === void 0 ? void 0 : data.id) || (data === null || data === void 0 ? void 0 : (_data$waterTankerBook = data.waterTankerBookingDetail) === null || _data$waterTankerBook === void 0 ? void 0 : _data$waterTankerBook.id) || "",
709
+ bookingNo: (data === null || data === void 0 ? void 0 : data.bookingNo) || (data === null || data === void 0 ? void 0 : (_data$waterTankerBook2 = data.waterTankerBookingDetail) === null || _data$waterTankerBook2 === void 0 ? void 0 : _data$waterTankerBook2.bookingNo) || null,
708
710
  applicantId: (applicantDetailFromFP === null || applicantDetailFromFP === void 0 ? void 0 : applicantDetailFromFP.applicantId) || (data === null || data === void 0 ? void 0 : (_data$owner30 = data.owner) === null || _data$owner30 === void 0 ? void 0 : _data$owner30.applicantId) || "",
709
711
  tenantId: data === null || data === void 0 ? void 0 : data.tenantId,
710
712
  tankerType: (_ref2 = (data === null || data === void 0 ? void 0 : (_data$requestDetails12 = data.requestDetails) === null || _data$requestDetails12 === void 0 ? void 0 : (_data$requestDetails13 = _data$requestDetails12.tankerType) === null || _data$requestDetails13 === void 0 ? void 0 : _data$requestDetails13.code) || (data === null || data === void 0 ? void 0 : (_data$requestDetails14 = data.requestDetails) === null || _data$requestDetails14 === void 0 ? void 0 : _data$requestDetails14.tankerType) || "") === null || _ref2 === void 0 ? void 0 : _ref2.toUpperCase(),
@@ -1096,13 +1098,7 @@ const WTSearchApplication = ({
1096
1098
  }),
1097
1099
  type: "number",
1098
1100
  maxlength: 10
1099
- }), /*#__PURE__*/React.createElement(CardLabelError, null, formState === null || formState === void 0 ? void 0 : (_formState$errors = formState.errors) === null || _formState$errors === void 0 ? void 0 : (_formState$errors$mob = _formState$errors["mobileNumber"]) === null || _formState$errors$mob === void 0 ? void 0 : _formState$errors$mob.message)), /*#__PURE__*/React.createElement("div", {
1100
- className: "search-field-wrapper"
1101
- }, /*#__PURE__*/React.createElement("label", null, t("WT_BOOKING_NO")), /*#__PURE__*/React.createElement(TextInput, {
1102
- name: "bookingNo",
1103
- inputRef: register({}),
1104
- id: "wt-booking-no-input"
1105
- }))), activeTab === t("WT_ADVANCED_SEARCH") && /*#__PURE__*/React.createElement("div", {
1101
+ }), /*#__PURE__*/React.createElement(CardLabelError, null, formState === null || formState === void 0 ? void 0 : (_formState$errors = formState.errors) === null || _formState$errors === void 0 ? void 0 : (_formState$errors$mob = _formState$errors["mobileNumber"]) === null || _formState$errors$mob === void 0 ? void 0 : _formState$errors$mob.message))), activeTab === t("WT_ADVANCED_SEARCH") && /*#__PURE__*/React.createElement("div", {
1106
1102
  className: "formcomposer-section-grid"
1107
1103
  }, /*#__PURE__*/React.createElement("div", {
1108
1104
  className: "search-field-wrapper"
@@ -3714,25 +3710,25 @@ const AddTripModal = ({
3714
3710
  onSubmit,
3715
3711
  initialValues
3716
3712
  }) => {
3717
- var _formData$day;
3718
3713
  const now = new Date();
3719
3714
  const currentTime = `${String(now.getHours()).padStart(2, "0")}:${String(now.getMinutes()).padStart(2, "0")}`;
3720
3715
  const defaultValues = initialValues ? {
3721
3716
  ...initialValues,
3722
- arrivalTimeFpl: initialValues.arrivalTimeFpl || currentTime,
3723
- departureTimeFpl: initialValues.departureTimeFpl || currentTime,
3724
- arrivalFixedPoint: initialValues.arrivalFixedPoint || currentTime,
3725
- departureFixedPoint: initialValues.departureFixedPoint || currentTime,
3726
- returnFpl: initialValues.returnFpl || currentTime,
3727
- frequencyNo: initialValues.frequencyNo,
3728
- vehicleId: initialValues.vehicleId,
3729
- fixedPointCode: initialValues.fixedPointCode,
3717
+ arrivalTimeFpl: initialValues.arrivalTimeFpl || initialValues.arrival_time_to_fpl || currentTime,
3718
+ departureTimeFpl: initialValues.departureTimeFpl || initialValues.departure_time_from_fpl || currentTime,
3719
+ arrivalFixedPoint: initialValues.arrivalFixedPoint || initialValues.arrival_time_delivery_point || currentTime,
3720
+ departureFixedPoint: initialValues.departureFixedPoint || initialValues.departure_time_delivery_point || currentTime,
3721
+ returnFpl: initialValues.returnFpl || initialValues.time_of_arriving_back_fpl_after_delivery || currentTime,
3722
+ frequencyNo: initialValues.frequencyNo || initialValues.trip_no || 1,
3723
+ vehicleId: initialValues.vehicleId || initialValues.vehicle_id || "",
3724
+ fixedPointCode: initialValues.fixedPointCode || initialValues.fixed_point_code || "",
3725
+ fillingPointCode: initialValues.fillingPointCode || initialValues.fillingPointId || "",
3730
3726
  day: initialValues.day || [],
3731
- volume: initialValues.volume || "",
3732
- active: initialValues.active || null,
3727
+ volume: initialValues.volume || initialValues.volume_water_tobe_delivery || "",
3733
3728
  remarks: initialValues.remarks || ""
3734
3729
  } : {
3735
3730
  fixedPointCode: "",
3731
+ fillingPointCode: "",
3736
3732
  day: [],
3737
3733
  arrivalTimeFpl: currentTime,
3738
3734
  departureTimeFpl: currentTime,
@@ -3740,7 +3736,6 @@ const AddTripModal = ({
3740
3736
  departureFixedPoint: currentTime,
3741
3737
  returnFpl: currentTime,
3742
3738
  volume: "",
3743
- active: null,
3744
3739
  remarks: "",
3745
3740
  frequencyNo: 1
3746
3741
  };
@@ -3751,33 +3746,69 @@ const AddTripModal = ({
3751
3746
  formState: {
3752
3747
  errors
3753
3748
  },
3754
- watch,
3755
- setValue
3749
+ watch
3756
3750
  } = useForm({
3757
3751
  defaultValues
3758
3752
  });
3759
3753
  const tenantId = Digit.ULBService.getCurrentTenantId();
3754
+ const [searchQuery, setSearchQuery] = useState("");
3755
+ const [debouncedSearchQuery, setDebouncedSearchQuery] = useState("");
3756
+ useEffect(() => {
3757
+ const handler = setTimeout(() => {
3758
+ setDebouncedSearchQuery(searchQuery);
3759
+ }, 500);
3760
+ return () => clearTimeout(handler);
3761
+ }, [searchQuery]);
3762
+ const handleSearch = useCallback(val => {
3763
+ setSearchQuery(val);
3764
+ }, []);
3760
3765
  const {
3761
3766
  isLoading: isFixedPointLoading,
3762
3767
  data: fixedPointsData
3763
3768
  } = Digit.Hooks.wt.useFixedPointSearchAPI({
3769
+ tenantId,
3770
+ filters: {
3771
+ limit: 1000,
3772
+ ...(debouncedSearchQuery ? {
3773
+ name: debouncedSearchQuery
3774
+ } : {})
3775
+ }
3776
+ }, {
3777
+ keepPreviousData: true
3778
+ });
3779
+ const {
3780
+ isLoading: isFillingPointLoading,
3781
+ data: fillingPointsData
3782
+ } = Digit.Hooks.wt.useFillPointSearch({
3764
3783
  tenantId,
3765
3784
  filters: {
3766
3785
  limit: 1000
3767
3786
  }
3768
3787
  });
3769
3788
  const fixedPoints = (fixedPointsData === null || fixedPointsData === void 0 ? void 0 : fixedPointsData.waterTankerBookingDetail) || [];
3789
+ const fillingPoints = (fillingPointsData === null || fillingPointsData === void 0 ? void 0 : fillingPointsData.fillingPoints) || [];
3770
3790
  const fixedPointOptions = fixedPoints.map(fp => {
3771
- var _fp$applicantDetail, _fp$applicantDetail2, _fp$address, _fp$applicantDetail3, _fp$applicantDetail4, _fp$address2, _fp$applicantDetail5, _fp$address3, _fp$address4, _fp$address5, _fp$address6;
3791
+ var _fp$applicantDetail, _fp$applicantDetail2, _fp$applicantDetail3, _fp$address, _fp$applicantDetail4, _fp$address2, _fp$applicantDetail5, _fp$applicantDetail6, _fp$applicantDetail7, _fp$address3, _fp$address4, _fp$address5, _fp$address6;
3792
+ const name = (fp === null || fp === void 0 ? void 0 : (_fp$applicantDetail = fp.applicantDetail) === null || _fp$applicantDetail === void 0 ? void 0 : _fp$applicantDetail.name) || "NA";
3793
+ const fixedPointId = (fp === null || fp === void 0 ? void 0 : (_fp$applicantDetail2 = fp.applicantDetail) === null || _fp$applicantDetail2 === void 0 ? void 0 : _fp$applicantDetail2.fixedPointId) || (fp === null || fp === void 0 ? void 0 : fp.fixedPointCode) || "";
3794
+ const displayName = fixedPointId ? `${name} (${fixedPointId})` : name;
3772
3795
  return {
3773
- name: (fp === null || fp === void 0 ? void 0 : (_fp$applicantDetail = fp.applicantDetail) === null || _fp$applicantDetail === void 0 ? void 0 : _fp$applicantDetail.name) || "NA",
3774
- mobileNumber: (fp === null || fp === void 0 ? void 0 : (_fp$applicantDetail2 = fp.applicantDetail) === null || _fp$applicantDetail2 === void 0 ? void 0 : _fp$applicantDetail2.mobileNumber) || "NA",
3796
+ name: displayName,
3797
+ mobileNumber: (fp === null || fp === void 0 ? void 0 : (_fp$applicantDetail3 = fp.applicantDetail) === null || _fp$applicantDetail3 === void 0 ? void 0 : _fp$applicantDetail3.mobileNumber) || "NA",
3775
3798
  locality: (fp === null || fp === void 0 ? void 0 : (_fp$address = fp.address) === null || _fp$address === void 0 ? void 0 : _fp$address.locality) || "NA",
3776
- displayLabel: `${(fp === null || fp === void 0 ? void 0 : (_fp$applicantDetail3 = fp.applicantDetail) === null || _fp$applicantDetail3 === void 0 ? void 0 : _fp$applicantDetail3.name) || "NA"} | ${(fp === null || fp === void 0 ? void 0 : (_fp$applicantDetail4 = fp.applicantDetail) === null || _fp$applicantDetail4 === void 0 ? void 0 : _fp$applicantDetail4.mobileNumber) || "NA"} | ${(fp === null || fp === void 0 ? void 0 : (_fp$address2 = fp.address) === null || _fp$address2 === void 0 ? void 0 : _fp$address2.locality) || "NA"}`,
3777
- value: fp.fixedPointCode || (fp === null || fp === void 0 ? void 0 : (_fp$applicantDetail5 = fp.applicantDetail) === null || _fp$applicantDetail5 === void 0 ? void 0 : _fp$applicantDetail5.fixedPointId) || fp.bookingId,
3799
+ displayLabel: `${displayName} | ${(fp === null || fp === void 0 ? void 0 : (_fp$applicantDetail4 = fp.applicantDetail) === null || _fp$applicantDetail4 === void 0 ? void 0 : _fp$applicantDetail4.mobileNumber) || "NA"} | ${(fp === null || fp === void 0 ? void 0 : (_fp$address2 = fp.address) === null || _fp$address2 === void 0 ? void 0 : _fp$address2.locality) || "NA"}`,
3800
+ value: (fp === null || fp === void 0 ? void 0 : (_fp$applicantDetail5 = fp.applicantDetail) === null || _fp$applicantDetail5 === void 0 ? void 0 : _fp$applicantDetail5.applicantId) || (fp === null || fp === void 0 ? void 0 : fp.id) || (fp === null || fp === void 0 ? void 0 : fp.bookingId),
3801
+ code: fp.fixedPointCode || (fp === null || fp === void 0 ? void 0 : (_fp$applicantDetail6 = fp.applicantDetail) === null || _fp$applicantDetail6 === void 0 ? void 0 : _fp$applicantDetail6.fixedPointId) || "",
3802
+ id: (fp === null || fp === void 0 ? void 0 : (_fp$applicantDetail7 = fp.applicantDetail) === null || _fp$applicantDetail7 === void 0 ? void 0 : _fp$applicantDetail7.fixedPointId) || "",
3778
3803
  fullAddress: [(fp === null || fp === void 0 ? void 0 : (_fp$address3 = fp.address) === null || _fp$address3 === void 0 ? void 0 : _fp$address3.houseNo) && `${t("WT_HOUSE_NO")} = ${fp.address.houseNo}`, (fp === null || fp === void 0 ? void 0 : (_fp$address4 = fp.address) === null || _fp$address4 === void 0 ? void 0 : _fp$address4.streetName) && `${t("WT_STREET_NAME")} = ${fp.address.streetName}`, (fp === null || fp === void 0 ? void 0 : (_fp$address5 = fp.address) === null || _fp$address5 === void 0 ? void 0 : _fp$address5.landmark) && `${t("WT_LANDMARK")} = ${fp.address.landmark}`, (fp === null || fp === void 0 ? void 0 : (_fp$address6 = fp.address) === null || _fp$address6 === void 0 ? void 0 : _fp$address6.locality) && `${t("WT_LOCALITY")} = ${fp.address.locality}`].filter(Boolean).join(", ")
3779
3804
  };
3780
3805
  });
3806
+ const fillingPointOptions = fillingPoints.map(fp => ({
3807
+ displayLabel: (fp === null || fp === void 0 ? void 0 : fp.fillingPointName) || "NA",
3808
+ value: fp === null || fp === void 0 ? void 0 : fp.id,
3809
+ eeName: (fp === null || fp === void 0 ? void 0 : fp.eeName) || "NA",
3810
+ aeName: (fp === null || fp === void 0 ? void 0 : fp.aeName) || "NA"
3811
+ }));
3781
3812
  const selectedFixedPointCode = watch("fixedPointCode");
3782
3813
  const selectedFixedPoint = fixedPointOptions.find(opt => opt.value === selectedFixedPointCode);
3783
3814
  const dayOptions = [{
@@ -3802,20 +3833,15 @@ const AddTripModal = ({
3802
3833
  label: t("SUNDAY"),
3803
3834
  value: "SUNDAY"
3804
3835
  }];
3805
- const activeOptions = [{
3806
- label: t("YES"),
3807
- value: "Yes"
3808
- }, {
3809
- label: t("NO"),
3810
- value: "No"
3811
- }];
3812
3836
  const formData = watch();
3813
- const isFormValid = (formData === null || formData === void 0 ? void 0 : formData.fixedPointCode) && (formData === null || formData === void 0 ? void 0 : formData.day) && Array.isArray(formData === null || formData === void 0 ? void 0 : formData.day) && (formData === null || formData === void 0 ? void 0 : (_formData$day = formData.day) === null || _formData$day === void 0 ? void 0 : _formData$day.length) > 0 && (formData === null || formData === void 0 ? void 0 : formData.arrivalTimeFpl) && (formData === null || formData === void 0 ? void 0 : formData.departureTimeFpl) && (formData === null || formData === void 0 ? void 0 : formData.arrivalFixedPoint) && (formData === null || formData === void 0 ? void 0 : formData.departureFixedPoint) && (formData === null || formData === void 0 ? void 0 : formData.returnFpl) && (formData === null || formData === void 0 ? void 0 : formData.volume) !== "" && (formData === null || formData === void 0 ? void 0 : formData.volume) !== undefined && (formData === null || formData === void 0 ? void 0 : formData.volume) !== null && (formData === null || formData === void 0 ? void 0 : formData.active);
3814
3837
  const onFormSubmit = data => {
3815
- onSubmit({
3816
- ...initialValues,
3817
- ...data
3818
- });
3838
+ const selectedFixedPoint = fixedPointOptions.find(opt => opt.value === data.fixedPointCode);
3839
+ const enrichedData = {
3840
+ ...data,
3841
+ fixedPointId: selectedFixedPoint ? selectedFixedPoint.id : (initialValues === null || initialValues === void 0 ? void 0 : initialValues.fixedPointId) || "",
3842
+ fixedPointCode: selectedFixedPoint ? selectedFixedPoint.code : (initialValues === null || initialValues === void 0 ? void 0 : initialValues.fixedPointCode) || ""
3843
+ };
3844
+ onSubmit(enrichedData);
3819
3845
  };
3820
3846
  return /*#__PURE__*/React.createElement("div", {
3821
3847
  className: "custom-modal-overlay",
@@ -3832,61 +3858,117 @@ const AddTripModal = ({
3832
3858
  zIndex: 200000
3833
3859
  }
3834
3860
  }, /*#__PURE__*/React.createElement("style", null, `
3861
+
3835
3862
  .custom-modal-content {
3863
+
3836
3864
  background-color: #fff;
3865
+
3837
3866
  border-radius: 8px;
3867
+
3838
3868
  width: 70%;
3869
+
3839
3870
  max-width: 800px;
3871
+
3840
3872
  max-height: 90vh;
3873
+
3841
3874
  display: flex;
3875
+
3842
3876
  flex-direction: column;
3877
+
3843
3878
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
3879
+
3844
3880
  position: relative;
3881
+
3845
3882
  }
3883
+
3846
3884
  .add-trip-form {
3885
+
3847
3886
  display: grid;
3887
+
3848
3888
  grid-template-columns: repeat(2, 1fr);
3889
+
3849
3890
  gap: 20px;
3891
+
3850
3892
  }
3893
+
3851
3894
  @media (max-width: 768px) {
3895
+
3852
3896
  .custom-modal-content {
3897
+
3853
3898
  width: 90%;
3899
+
3854
3900
  max-height: 85vh;
3901
+
3855
3902
  }
3903
+
3856
3904
  .add-trip-form {
3905
+
3857
3906
  grid-template-columns: 1fr;
3907
+
3858
3908
  gap: 15px;
3909
+
3859
3910
  }
3911
+
3860
3912
  }
3913
+
3861
3914
  @media (max-width: 480px) {
3915
+
3862
3916
  .custom-modal-content {
3917
+
3863
3918
  width: 95%;
3919
+
3864
3920
  max-height: 95vh;
3921
+
3865
3922
  }
3923
+
3866
3924
  .custom-modal-body {
3925
+
3867
3926
  padding: 15px !important;
3927
+
3868
3928
  }
3929
+
3869
3930
  .custom-modal-footer {
3931
+
3870
3932
  padding: 12px 15px !important;
3933
+
3871
3934
  flex-direction: row;
3935
+
3872
3936
  justify-content: flex-end;
3937
+
3873
3938
  }
3939
+
3874
3940
  .custom-modal-header {
3941
+
3875
3942
  padding: 12px 15px !important;
3943
+
3876
3944
  }
3945
+
3877
3946
  .custom-modal-header h1 {
3947
+
3878
3948
  font-size: 18px !important;
3949
+
3879
3950
  }
3951
+
3880
3952
  }
3953
+
3881
3954
  @media (max-width: 320px) {
3955
+
3882
3956
  .custom-modal-footer {
3957
+
3883
3958
  flex-direction: column-reverse;
3959
+
3884
3960
  align-items: stretch;
3961
+
3885
3962
  }
3963
+
3886
3964
  .custom-modal-footer button {
3965
+
3887
3966
  width: 100%;
3967
+
3888
3968
  }
3969
+
3889
3970
  }
3971
+
3890
3972
  `), /*#__PURE__*/React.createElement("div", {
3891
3973
  className: "custom-modal-content"
3892
3974
  }, /*#__PURE__*/React.createElement("div", {
@@ -3932,7 +4014,7 @@ const AddTripModal = ({
3932
4014
  }, t("WT_FIXED_POINT_CODE")), isFixedPointLoading ? /*#__PURE__*/React.createElement(Loader, null) : /*#__PURE__*/React.createElement(Controller, {
3933
4015
  control: control,
3934
4016
  name: "fixedPointCode",
3935
- defaultValue: defaultValues.fixedPointCode,
4017
+ defaultValue: defaultValues.fixedPointId || defaultValues.fixedPointCode,
3936
4018
  render: props => /*#__PURE__*/React.createElement(CustomNameDropdown, {
3937
4019
  option: fixedPointOptions,
3938
4020
  optionKey: "displayLabel",
@@ -3943,7 +4025,8 @@ const AddTripModal = ({
3943
4025
  name: "WT_NAME",
3944
4026
  mobileNumber: "WT_MOBILE_NUMBER",
3945
4027
  locality: "WT_LOCALITY"
3946
- }
4028
+ },
4029
+ onSearch: handleSearch
3947
4030
  })
3948
4031
  }), selectedFixedPoint && /*#__PURE__*/React.createElement("div", {
3949
4032
  style: {
@@ -3962,6 +4045,24 @@ const AddTripModal = ({
3962
4045
  marginBottom: "8px",
3963
4046
  fontWeight: "500"
3964
4047
  }
4048
+ }, t("WT_FILLING_POINT")), isFillingPointLoading ? /*#__PURE__*/React.createElement(Loader, null) : /*#__PURE__*/React.createElement(Controller, {
4049
+ control: control,
4050
+ name: "fillingPointCode",
4051
+ defaultValue: defaultValues.fillingPointCode,
4052
+ render: props => /*#__PURE__*/React.createElement(CustomNameDropdown, {
4053
+ option: fillingPointOptions,
4054
+ optionKey: "displayLabel",
4055
+ selected: fillingPointOptions.find(opt => opt.value === props.value),
4056
+ select: val => props.onChange(val.value),
4057
+ t: t
4058
+ })
4059
+ })), /*#__PURE__*/React.createElement("div", {
4060
+ className: "field-group"
4061
+ }, /*#__PURE__*/React.createElement(CardLabel, {
4062
+ style: {
4063
+ marginBottom: "8px",
4064
+ fontWeight: "500"
4065
+ }
3965
4066
  }, t("WT_DAY")), /*#__PURE__*/React.createElement(Controller, {
3966
4067
  control: control,
3967
4068
  name: "day",
@@ -3975,7 +4076,14 @@ const AddTripModal = ({
3975
4076
  },
3976
4077
  t: t,
3977
4078
  defaultLabel: t("WT_SELECT_DAYS"),
3978
- defaultUnit: t("WT_DAYS")
4079
+ defaultUnit: t("WT_DAYS"),
4080
+ ServerStyle: {
4081
+ backgroundColor: "#fff",
4082
+ zIndex: 1000,
4083
+ border: "1px solid #ccc",
4084
+ boxShadow: "0px 4px 6px rgba(0,0,0,0.1)",
4085
+ borderRadius: "4px"
4086
+ }
3979
4087
  })
3980
4088
  })), /*#__PURE__*/React.createElement("div", {
3981
4089
  className: "field-group"
@@ -4078,23 +4186,6 @@ const AddTripModal = ({
4078
4186
  onChange: e => props.onChange(e.target.value),
4079
4187
  onBlur: props.onBlur
4080
4188
  })
4081
- })), /*#__PURE__*/React.createElement("div", {
4082
- className: "field-group"
4083
- }, /*#__PURE__*/React.createElement(CardLabel, {
4084
- style: {
4085
- marginBottom: "8px",
4086
- fontWeight: "500"
4087
- }
4088
- }, t("WT_ACTIVE")), /*#__PURE__*/React.createElement(Controller, {
4089
- control: control,
4090
- name: "active",
4091
- render: props => /*#__PURE__*/React.createElement(Dropdown, {
4092
- option: activeOptions,
4093
- optionKey: "label",
4094
- selected: props.value,
4095
- select: props.onChange,
4096
- t: t
4097
- })
4098
4189
  })), /*#__PURE__*/React.createElement("div", {
4099
4190
  className: "field-group remarks-field-group",
4100
4191
  style: {
@@ -4135,16 +4226,14 @@ const AddTripModal = ({
4135
4226
  }
4136
4227
  }, t("CS_COMMON_CANCEL")), /*#__PURE__*/React.createElement("button", {
4137
4228
  className: "button-save",
4138
- disabled: !isFormValid,
4139
4229
  onClick: handleSubmit(onFormSubmit),
4140
4230
  style: {
4141
4231
  padding: "8px 20px",
4142
- background: !isFormValid ? "#ccc" : "#1D4E7F",
4143
- color: "#fff",
4232
+ background: "#1D4E7F",
4233
+ color: "#ffffffff",
4144
4234
  border: "none",
4145
4235
  borderRadius: "4px",
4146
- cursor: !isFormValid ? "not-allowed" : "pointer",
4147
- opacity: !isFormValid ? 0.7 : 1
4236
+ cursor: "pointer"
4148
4237
  }
4149
4238
  }, initialValues ? t("WT_UPDATE") : t("CS_COMMON_SAVE")))));
4150
4239
  };
@@ -4260,6 +4349,7 @@ const FixedPointScheduleManagement = ({
4260
4349
  scheduleId: item.systemAssignedScheduleId,
4261
4350
  fixedPointName: item.fixedPointName,
4262
4351
  fixedPoint: item.fixedPointCode || item.fixedPointId,
4352
+ fixedPointId: item.fixedPointId || item.id || null,
4263
4353
  day: item.day,
4264
4354
  freq: item.tripNo,
4265
4355
  arrToFpl: item.arrivalTimeToFpl,
@@ -4602,7 +4692,24 @@ const FixedPointScheduleManagement = ({
4602
4692
  color: selectedDay === dayItem ? "#fff" : "#333",
4603
4693
  cursor: "pointer"
4604
4694
  }
4605
- }, t(dayItem.toUpperCase())))), /*#__PURE__*/React.createElement("div", {
4695
+ }, t(dayItem.toUpperCase())))), /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("button", {
4696
+ onClick: () => {
4697
+ setEditingRowIndex(null);
4698
+ setShowModal(true);
4699
+ },
4700
+ style: {
4701
+ background: "#1E8E3E",
4702
+ color: "#fff",
4703
+ border: "none",
4704
+ padding: "10px 20px",
4705
+ borderRadius: "4px",
4706
+ cursor: "pointer",
4707
+ display: "flex",
4708
+ alignItems: "center",
4709
+ gap: "5px",
4710
+ marginBottom: "10px"
4711
+ }
4712
+ }, /*#__PURE__*/React.createElement("span", null, "+"), " ", t("WT_ADD_TRIP"))), /*#__PURE__*/React.createElement("div", {
4606
4713
  style: {
4607
4714
  width: "100%",
4608
4715
  overflowX: "auto"
@@ -4632,24 +4739,7 @@ const FixedPointScheduleManagement = ({
4632
4739
  getCSVExportData: getCSVExportData,
4633
4740
  csvExportColumns: csvExportColumns,
4634
4741
  csvExportFileName: "wt-fixed-point-schedule"
4635
- })), /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("button", {
4636
- onClick: () => {
4637
- setEditingRowIndex(null);
4638
- setShowModal(true);
4639
- },
4640
- style: {
4641
- background: "#1E8E3E",
4642
- color: "#fff",
4643
- border: "none",
4644
- padding: "10px 20px",
4645
- borderRadius: "4px",
4646
- cursor: "pointer",
4647
- display: "flex",
4648
- alignItems: "center",
4649
- gap: "5px",
4650
- marginBottom: "10px"
4651
- }
4652
- }, /*#__PURE__*/React.createElement("span", null, "+"), " ", t("WT_ADD_TRIP")))), showModal && /*#__PURE__*/React.createElement(AddTripModal, {
4742
+ }))), showModal && /*#__PURE__*/React.createElement(AddTripModal, {
4653
4743
  t: t,
4654
4744
  closeModal: () => {
4655
4745
  setShowModal(false);
@@ -4658,6 +4748,7 @@ const FixedPointScheduleManagement = ({
4658
4748
  initialValues: editingRowIndex !== null ? {
4659
4749
  scheduleId: data[editingRowIndex].scheduleId,
4660
4750
  fixedPointCode: data[editingRowIndex].fixedPoint,
4751
+ fixedPointId: data[editingRowIndex].fixedPointId,
4661
4752
  day: [{
4662
4753
  label: t(data[editingRowIndex].day),
4663
4754
  value: data[editingRowIndex].day
@@ -4676,86 +4767,68 @@ const FixedPointScheduleManagement = ({
4676
4767
  }
4677
4768
  } : null,
4678
4769
  onSubmit: formData => {
4679
- var _formData$active, _formData$active2;
4770
+ var _formData$active, _scheduleData$fixedPo, _scheduleData$fixedPo2;
4771
+ console.log(formData, 'dsdsdsdsdsdsds');
4680
4772
  const formDataDay = formData === null || formData === void 0 ? void 0 : formData.day;
4681
4773
  let daysArr = [];
4682
4774
  if (Array.isArray(formDataDay)) {
4683
- daysArr = formDataDay.map(d => typeof d === "string" ? d : (d === null || d === void 0 ? void 0 : d.value) || (Array.isArray(d) ? d[1] : d)).filter(d => typeof d === "string" && d !== "WT_SELECT_ALL");
4684
- if (daysArr.length === 0 && formDataDay.some(d => {
4685
- const val = typeof d === "string" ? d : (d === null || d === void 0 ? void 0 : d.value) || (Array.isArray(d) ? d[1] : d);
4686
- return val === "WT_SELECT_ALL";
4687
- })) {
4688
- daysArr = ["MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"];
4689
- }
4775
+ daysArr = formDataDay.map(d => typeof d === "string" ? d : (d === null || d === void 0 ? void 0 : d.value) || d).filter(d => d && d !== "WT_SELECT_ALL");
4690
4776
  } else if (formDataDay) {
4691
- const dayVal = typeof formDataDay === "string" ? formDataDay : (formDataDay === null || formDataDay === void 0 ? void 0 : formDataDay.value) || (Array.isArray(formDataDay) ? formDataDay[1] : formDataDay);
4692
- if (dayVal && dayVal !== "WT_SELECT_ALL") daysArr = [dayVal];
4777
+ const val = (formDataDay === null || formDataDay === void 0 ? void 0 : formDataDay.value) || formDataDay;
4778
+ if (val && val !== "WT_SELECT_ALL") daysArr = [val];
4693
4779
  }
4780
+ const existingData = editingRowIndex !== null ? data[editingRowIndex] : {};
4781
+ const isFormActive = ((_formData$active = formData.active) === null || _formData$active === void 0 ? void 0 : _formData$active.value) === "Yes" || formData.active === "Yes" || formData.active === true;
4782
+ const isExistingActive = (existingData === null || existingData === void 0 ? void 0 : existingData.active) === "Y";
4783
+ const finalActiveStatus = formData.active !== undefined ? isFormActive : editingRowIndex !== null ? isExistingActive : true;
4694
4784
  const fixedPointDetails = {
4695
- tenantId,
4696
- system_assigned_schedule_id: formData.scheduleId,
4697
- fixed_point_code: formData.fixedPointCode,
4698
- day: daysArr.map(d => {
4699
- var _d$toUpperCase;
4700
- return (d === null || d === void 0 ? void 0 : (_d$toUpperCase = d.toUpperCase) === null || _d$toUpperCase === void 0 ? void 0 : _d$toUpperCase.call(d)) || d;
4701
- }),
4702
- trip_no: Number(formData.frequencyNo) || Number(formData.tripNo) || 1,
4785
+ system_assigned_schedule_id: formData.scheduleId || existingData.scheduleId || null,
4786
+ fixed_point_code: formData.fixedPointId || formData.fixedPointCode || "",
4787
+ fillingPointId: formData.fillingPointCode || null,
4788
+ day: daysArr.map(d => d.toUpperCase()),
4789
+ trip_no: Number(formData.frequencyNo) || 1,
4703
4790
  arrival_time_to_fpl: formData.arrivalTimeFpl,
4704
4791
  departure_time_from_fpl: formData.departureTimeFpl,
4705
4792
  arrival_time_delivery_point: formData.arrivalFixedPoint,
4706
4793
  departure_time_delivery_point: formData.departureFixedPoint,
4707
4794
  time_of_arriving_back_fpl_after_delivery: formData.returnFpl,
4708
- volume_water_tobe_delivery: formData.volume || "0",
4709
- active: ((_formData$active = formData.active) === null || _formData$active === void 0 ? void 0 : _formData$active.value) === "Yes" || formData.active === "Yes",
4710
- is_enable: ((_formData$active2 = formData.active) === null || _formData$active2 === void 0 ? void 0 : _formData$active2.value) === "Yes" || formData.active === "Yes",
4711
- remarks: formData.remarks,
4712
- vehicle_id: formData.vehicleId
4795
+ volume_water_tobe_delivery: formData.volume,
4796
+ active: finalActiveStatus,
4797
+ is_enable: finalActiveStatus,
4798
+ remarks: formData.remarks || "",
4799
+ vehicle_id: formData.vehicleId || existingData.vehicle || null,
4800
+ audit_details: (scheduleData === null || scheduleData === void 0 ? void 0 : (_scheduleData$fixedPo = scheduleData.fixedPointTimeTableDetails) === null || _scheduleData$fixedPo === void 0 ? void 0 : (_scheduleData$fixedPo2 = _scheduleData$fixedPo[editingRowIndex]) === null || _scheduleData$fixedPo2 === void 0 ? void 0 : _scheduleData$fixedPo2.auditDetails) || null
4713
4801
  };
4802
+ if (!fixedPointDetails.system_assigned_schedule_id) delete fixedPointDetails.system_assigned_schedule_id;
4803
+ if (!fixedPointDetails.vehicle_id) delete fixedPointDetails.vehicle_id;
4804
+ if (!fixedPointDetails.audit_details) delete fixedPointDetails.audit_details;
4714
4805
  const payload = editingRowIndex !== null ? {
4715
4806
  fixedPointDetailsList: [fixedPointDetails]
4716
4807
  } : {
4717
4808
  fixedPointDetails
4718
4809
  };
4810
+ const mutationOptions = {
4811
+ onError: error => {
4812
+ var _error$response, _error$response$data, _error$response$data$, _error$response$data$2;
4813
+ setToast({
4814
+ key: "error",
4815
+ label: (error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : (_error$response$data$ = _error$response$data.Errors) === null || _error$response$data$ === void 0 ? void 0 : (_error$response$data$2 = _error$response$data$[0]) === null || _error$response$data$2 === void 0 ? void 0 : _error$response$data$2.message) || "Operation Failed"
4816
+ });
4817
+ setTimeout(closeToast, 5000);
4818
+ },
4819
+ onSuccess: () => {
4820
+ setToast({
4821
+ label: editingRowIndex !== null ? t("WT_SCHEDULE_UPDATE_SUCCESS") : t("WT_SCHEDULE_CREATE_SUCCESS")
4822
+ });
4823
+ setShowModal(false);
4824
+ setEditingRowIndex(null);
4825
+ queryClient.invalidateQueries(["FIXED_POINT_SCHEDULE_SEARCH", tenantId]);
4826
+ }
4827
+ };
4719
4828
  if (editingRowIndex !== null) {
4720
- updateSchedule(payload, {
4721
- onError: (error, variables) => {
4722
- var _error$response, _error$response$data, _error$response$data$, _error$response$data$2;
4723
- setToast({
4724
- key: "error",
4725
- label: (error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : (_error$response$data$ = _error$response$data.Errors) === null || _error$response$data$ === void 0 ? void 0 : (_error$response$data$2 = _error$response$data$[0]) === null || _error$response$data$2 === void 0 ? void 0 : _error$response$data$2.message) || "ERROR_WHILE_UPDATING_SCHEDULE"
4726
- });
4727
- setTimeout(closeToast, 5000);
4728
- },
4729
- onSuccess: (data, variables) => {
4730
- setToast({
4731
- label: t("WT_SCHEDULE_UPDATE_SUCCESS")
4732
- });
4733
- setTimeout(closeToast, 5000);
4734
- setShowModal(false);
4735
- setEditingRowIndex(null);
4736
- queryClient.invalidateQueries(["FIXED_POINT_SCHEDULE_SEARCH", tenantId]);
4737
- }
4738
- });
4829
+ updateSchedule(payload, mutationOptions);
4739
4830
  } else {
4740
- createSchedule(payload, {
4741
- onError: (error, variables) => {
4742
- var _error$response2, _error$response2$data, _error$response2$data2, _error$response2$data3;
4743
- setToast({
4744
- key: "error",
4745
- label: (error === null || error === void 0 ? void 0 : (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : (_error$response2$data = _error$response2.data) === null || _error$response2$data === void 0 ? void 0 : (_error$response2$data2 = _error$response2$data.Errors) === null || _error$response2$data2 === void 0 ? void 0 : (_error$response2$data3 = _error$response2$data2[0]) === null || _error$response2$data3 === void 0 ? void 0 : _error$response2$data3.message) || "ERROR_WHILE_CREATING_SCHEDULE"
4746
- });
4747
- setTimeout(closeToast, 5000);
4748
- },
4749
- onSuccess: (data, variables) => {
4750
- setToast({
4751
- label: t("WT_SCHEDULE_CREATE_SUCCESS")
4752
- });
4753
- setTimeout(closeToast, 5000);
4754
- setShowModal(false);
4755
- setEditingRowIndex(null);
4756
- queryClient.invalidateQueries(["FIXED_POINT_SCHEDULE_SEARCH", tenantId]);
4757
- }
4758
- });
4831
+ createSchedule(payload, mutationOptions);
4759
4832
  }
4760
4833
  }
4761
4834
  }), toast && /*#__PURE__*/React.createElement(Toast, {
@@ -28617,6 +28690,16 @@ const WTModule = ({
28617
28690
  path,
28618
28691
  url
28619
28692
  } = useRouteMatch();
28693
+ const moduleCode = "WT";
28694
+ const language = Digit.StoreData.getCurrentLanguage();
28695
+ const {
28696
+ isLoading,
28697
+ data: store
28698
+ } = Digit.Services.useStore({
28699
+ stateCode,
28700
+ moduleCode,
28701
+ language
28702
+ });
28620
28703
  Digit.SessionStorage.set("WT_TENANTS", tenants);
28621
28704
  useEffect(() => userType === "employee" && Digit.LocalizationService.getLocale({
28622
28705
  modules: [`rainmaker-${Digit.ULBService.getCurrentTenantId()}`],