@djb25/digit-ui-module-wt 1.0.15 → 1.0.16

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.
@@ -3142,26 +3142,26 @@ const AddTripModal = ({
3142
3142
  defaultValues: initialValues || {}
3143
3143
  });
3144
3144
  const dayOptions = [{
3145
- label: t("MON"),
3146
- value: "Mon"
3145
+ label: t("MONDAY"),
3146
+ value: "MONDAY"
3147
3147
  }, {
3148
- label: t("TUE"),
3149
- value: "Tue"
3148
+ label: t("TUESDAY"),
3149
+ value: "TUESDAY"
3150
3150
  }, {
3151
- label: t("WED"),
3152
- value: "Wed"
3151
+ label: t("WEDNESDAY"),
3152
+ value: "WEDNESDAY"
3153
3153
  }, {
3154
- label: t("THU"),
3155
- value: "Thu"
3154
+ label: t("THURSDAY"),
3155
+ value: "THURSDAY"
3156
3156
  }, {
3157
- label: t("FRI"),
3158
- value: "Fri"
3157
+ label: t("FRIDAY"),
3158
+ value: "FRIDAY"
3159
3159
  }, {
3160
- label: t("SAT"),
3161
- value: "Sat"
3160
+ label: t("SATURDAY"),
3161
+ value: "SATURDAY"
3162
3162
  }, {
3163
- label: t("SUN"),
3164
- value: "Sun"
3163
+ label: t("SUNDAY"),
3164
+ value: "SUNDAY"
3165
3165
  }];
3166
3166
  const activeOptions = [{
3167
3167
  label: t("YES"),
@@ -3245,16 +3245,6 @@ const AddTripModal = ({
3245
3245
  marginBottom: "8px",
3246
3246
  fontWeight: "500"
3247
3247
  }
3248
- }, t("WT_SCHEDULE_ID")), /*#__PURE__*/React.createElement(TextInput, {
3249
- name: "scheduleId",
3250
- inputRef: register()
3251
- })), /*#__PURE__*/React.createElement("div", {
3252
- className: "field-group"
3253
- }, /*#__PURE__*/React.createElement(CardLabel, {
3254
- style: {
3255
- marginBottom: "8px",
3256
- fontWeight: "500"
3257
- }
3258
3248
  }, t("WT_FIXED_POINT_CODE")), /*#__PURE__*/React.createElement(TextInput, {
3259
3249
  name: "fixedPointCode",
3260
3250
  inputRef: register()
@@ -3452,6 +3442,12 @@ const FixedPointScheduleManagement = () => {
3452
3442
  value: "DL1LAG7729"
3453
3443
  });
3454
3444
  const [editingRowIndex, setEditingRowIndex] = useState(null);
3445
+ const [filters, setFilters] = useState({});
3446
+ const {
3447
+ isLoading,
3448
+ data: scheduleData,
3449
+ refetch: reSearch
3450
+ } = Digit.Hooks.wt.useFixedPointScheduleSearch(tenantId, filters);
3455
3451
  const {
3456
3452
  mutate: createSchedule
3457
3453
  } = Digit.Hooks.wt.useCreateFixedPointSchedule(tenantId);
@@ -3468,14 +3464,16 @@ const FixedPointScheduleManagement = () => {
3468
3464
  window.Digit.Download.Excel(data, filename);
3469
3465
  } else {
3470
3466
  const csvRows = [];
3471
- const headers = Object.keys(data[0]);
3472
- csvRows.push(headers.join(","));
3473
- for (const row of data) {
3474
- const values = headers.map(header => {
3475
- const escaped = ("" + row[header]).replace(/"/g, '\\"');
3476
- return `"${escaped}"`;
3477
- });
3478
- csvRows.push(values.join(","));
3467
+ if (data.length > 0) {
3468
+ const headers = Object.keys(data[0]);
3469
+ csvRows.push(headers.join(","));
3470
+ for (const row of data) {
3471
+ const values = headers.map(header => {
3472
+ const escaped = ("" + row[header]).replace(/"/g, '\\"');
3473
+ return `"${escaped}"`;
3474
+ });
3475
+ csvRows.push(values.join(","));
3476
+ }
3479
3477
  }
3480
3478
  const blob = new Blob([csvRows.join("\n")], {
3481
3479
  type: "text/csv"
@@ -3490,76 +3488,34 @@ const FixedPointScheduleManagement = () => {
3490
3488
  document.body.removeChild(a);
3491
3489
  }
3492
3490
  };
3493
- const [data, setData] = useState([{
3494
- scheduleId: "SASID-0001",
3495
- fixedPoint: "FP01",
3496
- day: "Mon",
3497
- freq: "1",
3498
- arrToFpl: "06:00",
3499
- depFromFpl: "06:10",
3500
- arrAtFixedPoint: "06:40",
3501
- depAtFixedPoint: "06:55",
3502
- returnToFpl: "07:20",
3503
- volume: "3 KL",
3504
- vehicle: "DL1LAG7729",
3505
- active: "Y"
3506
- }, {
3507
- scheduleId: "SASID-0002",
3508
- fixedPoint: "FP01",
3509
- day: "Mon",
3510
- freq: "2",
3511
- arrToFpl: "07:20",
3512
- depFromFpl: "07:30",
3513
- arrAtFixedPoint: "08:00",
3514
- depAtFixedPoint: "08:15",
3515
- returnToFpl: "08:40",
3516
- volume: "3 KL",
3517
- vehicle: "DL1LAG7729",
3518
- active: "Y"
3519
- }, {
3520
- scheduleId: "SASID-0003",
3521
- fixedPoint: "FP02",
3522
- day: "Tue",
3523
- freq: "3",
3524
- arrToFpl: "08:40",
3525
- depFromFpl: "08:50",
3526
- arrAtFixedPoint: "09:20",
3527
- depAtFixedPoint: "09:35",
3528
- returnToFpl: "10:00",
3529
- volume: "3 KL",
3530
- vehicle: "DL1LAG7730",
3531
- active: "Y"
3532
- }, {
3533
- scheduleId: "SASID-0004",
3534
- fixedPoint: "FP03",
3535
- day: "Wed",
3536
- freq: "1",
3537
- arrToFpl: "09:00",
3538
- depFromFpl: "09:10",
3539
- arrAtFixedPoint: "09:40",
3540
- depAtFixedPoint: "09:55",
3541
- returnToFpl: "10:20",
3542
- volume: "5 KL",
3543
- vehicle: "DL1LAG7731",
3544
- active: "N"
3545
- }]);
3546
- const [masterData] = useState(data);
3547
- const handleSearch = () => {
3548
- let filteredData = [...masterData];
3549
- if (fixedPoint !== null && fixedPoint !== void 0 && fixedPoint.value && fixedPoint.value !== "all") {
3550
- filteredData = filteredData.filter(item => item.fixedPoint === fixedPoint.value);
3551
- }
3552
- if (day !== null && day !== void 0 && day.value && day.value !== "all") {
3553
- filteredData = filteredData.filter(item => item.day === day.value);
3554
- }
3555
- if (status !== null && status !== void 0 && status.value && status.value !== "all") {
3556
- const activeStatus = status.value === "Active" ? "Y" : "N";
3557
- filteredData = filteredData.filter(item => item.active === activeStatus);
3558
- }
3559
- if (vehicle !== null && vehicle !== void 0 && vehicle.value && vehicle.value !== "all") {
3560
- filteredData = filteredData.filter(item => item.vehicle === vehicle.value);
3491
+ const [data, setData] = useState([]);
3492
+ React.useEffect(() => {
3493
+ if (scheduleData !== null && scheduleData !== void 0 && scheduleData.fixedPointTimeTableDetails) {
3494
+ const mappedData = scheduleData.fixedPointTimeTableDetails.map(item => ({
3495
+ scheduleId: item.systemAssignedScheduleId,
3496
+ fixedPoint: item.fixedPointCode,
3497
+ day: item.day,
3498
+ freq: item.tripNo,
3499
+ arrToFpl: item.arrivalTimeToFpl,
3500
+ depFromFpl: item.departureTimeFromFpl,
3501
+ arrAtFixedPoint: item.arrivalTimeDeliveryPoint,
3502
+ depAtFixedPoint: item.departureTimeDeliveryPoint,
3503
+ returnToFpl: item.timeOfArrivingBackFplAfterDelivery,
3504
+ volume: item.volumeWaterTobeDelivery,
3505
+ vehicle: item.vehicleId,
3506
+ active: item.isEnable ? "Y" : "N"
3507
+ }));
3508
+ setData(mappedData);
3561
3509
  }
3562
- setData(filteredData);
3510
+ }, [scheduleData]);
3511
+ const handleSearch = () => {
3512
+ var _day$value;
3513
+ setFilters({
3514
+ fixedPointCode: (fixedPoint === null || fixedPoint === void 0 ? void 0 : fixedPoint.value) === "all" ? "" : fixedPoint === null || fixedPoint === void 0 ? void 0 : fixedPoint.value,
3515
+ day: (day === null || day === void 0 ? void 0 : day.value) === "all" ? "" : day === null || day === void 0 ? void 0 : (_day$value = day.value) === null || _day$value === void 0 ? void 0 : _day$value.toUpperCase(),
3516
+ status: (status === null || status === void 0 ? void 0 : status.value) === "all" ? "" : status === null || status === void 0 ? void 0 : status.value,
3517
+ vehicleId: (vehicle === null || vehicle === void 0 ? void 0 : vehicle.value) === "all" ? "" : vehicle === null || vehicle === void 0 ? void 0 : vehicle.value
3518
+ });
3563
3519
  };
3564
3520
  const columns = React.useMemo(() => [{
3565
3521
  Header: t("WT_SCHEDULE_ID"),
@@ -3817,7 +3773,8 @@ const FixedPointScheduleManagement = () => {
3817
3773
  },
3818
3774
  inboxStyles: {
3819
3775
  overflowX: "auto"
3820
- }
3776
+ },
3777
+ isLoading: isLoading
3821
3778
  }), /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("button", {
3822
3779
  onClick: () => {
3823
3780
  setEditingRowIndex(null);
@@ -3897,6 +3854,7 @@ const FixedPointScheduleManagement = () => {
3897
3854
  setTimeout(closeToast, 5000);
3898
3855
  setShowModal(false);
3899
3856
  setEditingRowIndex(null);
3857
+ reSearch();
3900
3858
  }
3901
3859
  });
3902
3860
  }
@@ -5059,13 +5017,6 @@ const AddFillingPointMetaData = ({
5059
5017
  }) => {
5060
5018
  const sectionKey = (_config === null || _config === void 0 ? void 0 : _config.key) || "metaData";
5061
5019
  const inputs = [{
5062
- label: "WT_FILLING_POINT_NAME",
5063
- name: "fillingPointName",
5064
- isMandatory: true
5065
- }, {
5066
- label: "WT_EMERGENCY_NAME",
5067
- name: "emergencyName"
5068
- }, {
5069
5020
  label: "WT_AE_NAME",
5070
5021
  name: "aeName",
5071
5022
  validation: {