kupos-ui-components-lib 2.0.0 → 2.0.1
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.
- package/dist/components/FilterBar/FilterBarDesktop.d.ts +1 -1
- package/dist/components/FilterBar/FilterBarDesktop.js +9 -4
- package/dist/components/FilterBar/ServiceFilter.js +6 -7
- package/dist/components/FilterBar/ServiceFilterProps.d.ts +1 -0
- package/dist/components/FilterBar/tyoes.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/FilterBar/FilterBarDesktop.tsx +10 -3
- package/src/components/FilterBar/ServiceFilter.tsx +7 -9
- package/src/components/FilterBar/ServiceFilterProps.ts +1 -0
- package/src/components/FilterBar/tyoes.ts +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { FilterBarProps } from "./tyoes";
|
|
3
|
-
declare const FilterBarDesktop: ({ t, serviceList, setServiceList, allSchedules, showReturnTripModal, filterArrData, isBlankTicket, operatorId, filtersArray, setFiltersArray, metaData, busTerminals, setTypes, colors, icons, translation, isTrain, isPeru, }: FilterBarProps) => React.JSX.Element;
|
|
3
|
+
declare const FilterBarDesktop: ({ t, serviceList, setServiceList, allSchedules, showReturnTripModal, filterArrData, isBlankTicket, operatorId, filtersArray, setFiltersArray, metaData, busTerminals, setTypes, colors, icons, translation, isTrain, isPeru, hideOperator, }: FilterBarProps) => React.JSX.Element;
|
|
4
4
|
export default FilterBarDesktop;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import commonService from "../../utils/CommonService";
|
|
3
3
|
import ServiceFilter from "./ServiceFilter";
|
|
4
|
-
const FilterBarDesktop = ({ t, serviceList, setServiceList, allSchedules, showReturnTripModal, filterArrData, isBlankTicket, operatorId, filtersArray, setFiltersArray, metaData, busTerminals, setTypes, colors, icons, translation, isTrain, isPeru, }) => {
|
|
4
|
+
const FilterBarDesktop = ({ t, serviceList, setServiceList, allSchedules, showReturnTripModal, filterArrData, isBlankTicket, operatorId, filtersArray, setFiltersArray, metaData, busTerminals, setTypes, colors, icons, translation, isTrain, isPeru, hideOperator, }) => {
|
|
5
5
|
const filterBy = (filters) => {
|
|
6
|
-
console.log("🚀 ~ filterBy ~ filters:", filters);
|
|
7
6
|
try {
|
|
8
7
|
let routes = allSchedules;
|
|
9
8
|
let filteredRoutes = commonService.copyObject(routes);
|
|
@@ -466,7 +465,13 @@ const FilterBarDesktop = ({ t, serviceList, setServiceList, allSchedules, showRe
|
|
|
466
465
|
console.log(e);
|
|
467
466
|
}
|
|
468
467
|
};
|
|
469
|
-
const onFilterSelected = (option, key, i) => {
|
|
468
|
+
// const onFilterSelected = (option, key: number, i: number) => {
|
|
469
|
+
// let filters = commonService.copyObject(filtersArray);
|
|
470
|
+
// filters[key].options[i].active = !filters[key].options[i].active;
|
|
471
|
+
// filterBy(filters);
|
|
472
|
+
// setFiltersArray(filters);
|
|
473
|
+
// };
|
|
474
|
+
const onFilterSelected = (key, i) => {
|
|
470
475
|
let filters = commonService.copyObject(filtersArray);
|
|
471
476
|
filters[key].options[i].active = !filters[key].options[i].active;
|
|
472
477
|
filterBy(filters);
|
|
@@ -475,6 +480,6 @@ const FilterBarDesktop = ({ t, serviceList, setServiceList, allSchedules, showRe
|
|
|
475
480
|
return (React.createElement(ServiceFilter, { filtersArray: filtersArray, onFilterSelected: onFilterSelected, onFilterClear: (val) => {
|
|
476
481
|
setFiltersArray(val);
|
|
477
482
|
filterBy(val);
|
|
478
|
-
}, showReturnTripModal: showReturnTripModal, initialOpenFilters: isBlankTicket ? ["operator"] : [], colors: colors, icons: icons, translation: translation, isTrain: isTrain, t: t }));
|
|
483
|
+
}, showReturnTripModal: showReturnTripModal, initialOpenFilters: isBlankTicket ? ["operator"] : [], colors: colors, icons: icons, translation: translation, isTrain: isTrain, hideOperator: hideOperator, t: t }));
|
|
479
484
|
};
|
|
480
485
|
export default FilterBarDesktop;
|
|
@@ -30,7 +30,7 @@ class ServiceFilter extends React.Component {
|
|
|
30
30
|
}
|
|
31
31
|
componentDidMount() {
|
|
32
32
|
window.addEventListener("scroll", this.handleScroll);
|
|
33
|
-
this.clearFilter();
|
|
33
|
+
// this.clearFilter();
|
|
34
34
|
}
|
|
35
35
|
componentWillUnmount() {
|
|
36
36
|
window.removeEventListener("scroll", this.handleScroll);
|
|
@@ -108,17 +108,17 @@ class ServiceFilter extends React.Component {
|
|
|
108
108
|
(option.type === "special_departure" && showSpecialDeparture) ||
|
|
109
109
|
(option.type === "train_type" && showTrainType) ||
|
|
110
110
|
(option.type === "amenities" && showAmenities);
|
|
111
|
-
|
|
111
|
+
console.log("🚀 ~ ServiceFilter ~ renderFilterItem ~ isOpen:", isOpen);
|
|
112
112
|
if ((option === null || option === void 0 ? void 0 : option.type) === "train_type" && !this.props.isTrain) {
|
|
113
113
|
return null;
|
|
114
114
|
}
|
|
115
|
-
|
|
115
|
+
if ((option === null || option === void 0 ? void 0 : option.type) === "operator" && this.props.hideOperator) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
116
118
|
if (this.props.isTrain &&
|
|
117
119
|
!["time", "tipo", "train_type"].includes(option === null || option === void 0 ? void 0 : option.type)) {
|
|
118
120
|
return null;
|
|
119
121
|
}
|
|
120
|
-
// This logic is similar to the functional component's conditional rendering
|
|
121
|
-
// Only show certain filter types for trains, similar to the functional component
|
|
122
122
|
const shouldShowHeader = (option === null || option === void 0 ? void 0 : option.type) === "time" ||
|
|
123
123
|
((option === null || option === void 0 ? void 0 : option.type) === "train_type" && this.props.isTrain) ||
|
|
124
124
|
((option === null || option === void 0 ? void 0 : option.type) === "tipo" && this.props.isTrain) ||
|
|
@@ -213,7 +213,6 @@ class ServiceFilter extends React.Component {
|
|
|
213
213
|
var _a, _b;
|
|
214
214
|
const { onFilterSelected } = this.props;
|
|
215
215
|
const { sortedFilters } = this.state;
|
|
216
|
-
// console.log(this.props, "sortedFilters");
|
|
217
216
|
return (React.createElement("div", null,
|
|
218
217
|
React.createElement("div", { style: {
|
|
219
218
|
overflowY: "scroll",
|
|
@@ -226,7 +225,7 @@ class ServiceFilter extends React.Component {
|
|
|
226
225
|
React.createElement("div", { className: "text-[13.33px] pb-[10px]" }, sortedFilters === null || sortedFilters === void 0 ? void 0 : sortedFilters.map((val, key) => {
|
|
227
226
|
var _a;
|
|
228
227
|
return ((_a = val.options) === null || _a === void 0 ? void 0 : _a.length)
|
|
229
|
-
? this.renderFilterItem(val, (i) => onFilterSelected(
|
|
228
|
+
? this.renderFilterItem(val, (i) => onFilterSelected(key, i), key)
|
|
230
229
|
: null;
|
|
231
230
|
}))),
|
|
232
231
|
this.showClearFilter() && (React.createElement("div", { onClick: this.clearFilter, className: "text-[13.33px] bold-text items-center cursor-pointer absolute flex justify-center bg-[#eaeaea] pt-[35px] pb-[7px] w-full left-0 z-[1] -bottom-[1px] rounded-b-[10px]" },
|
package/package.json
CHANGED
|
@@ -22,9 +22,9 @@ const FilterBarDesktop = ({
|
|
|
22
22
|
translation,
|
|
23
23
|
isTrain,
|
|
24
24
|
isPeru,
|
|
25
|
+
hideOperator,
|
|
25
26
|
}: FilterBarProps) => {
|
|
26
27
|
const filterBy = (filters) => {
|
|
27
|
-
console.log("🚀 ~ filterBy ~ filters:", filters);
|
|
28
28
|
try {
|
|
29
29
|
let routes = allSchedules;
|
|
30
30
|
let filteredRoutes = commonService.copyObject(routes);
|
|
@@ -520,11 +520,17 @@ const FilterBarDesktop = ({
|
|
|
520
520
|
console.log(e);
|
|
521
521
|
}
|
|
522
522
|
};
|
|
523
|
-
const onFilterSelected = (option, key: number, i: number) => {
|
|
523
|
+
// const onFilterSelected = (option, key: number, i: number) => {
|
|
524
|
+
// let filters = commonService.copyObject(filtersArray);
|
|
525
|
+
// filters[key].options[i].active = !filters[key].options[i].active;
|
|
526
|
+
// filterBy(filters);
|
|
527
|
+
// setFiltersArray(filters);
|
|
528
|
+
// };
|
|
529
|
+
|
|
530
|
+
const onFilterSelected = (key: number, i: number) => {
|
|
524
531
|
let filters = commonService.copyObject(filtersArray);
|
|
525
532
|
filters[key].options[i].active = !filters[key].options[i].active;
|
|
526
533
|
filterBy(filters);
|
|
527
|
-
|
|
528
534
|
setFiltersArray(filters);
|
|
529
535
|
};
|
|
530
536
|
|
|
@@ -542,6 +548,7 @@ const FilterBarDesktop = ({
|
|
|
542
548
|
icons={icons}
|
|
543
549
|
translation={translation}
|
|
544
550
|
isTrain={isTrain}
|
|
551
|
+
hideOperator={hideOperator}
|
|
545
552
|
t={t}
|
|
546
553
|
/>
|
|
547
554
|
);
|
|
@@ -53,7 +53,7 @@ class ServiceFilter extends React.Component<
|
|
|
53
53
|
|
|
54
54
|
componentDidMount() {
|
|
55
55
|
window.addEventListener("scroll", this.handleScroll);
|
|
56
|
-
this.clearFilter();
|
|
56
|
+
// this.clearFilter();
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
componentWillUnmount() {
|
|
@@ -168,13 +168,16 @@ class ServiceFilter extends React.Component<
|
|
|
168
168
|
(option.type === "special_departure" && showSpecialDeparture) ||
|
|
169
169
|
(option.type === "train_type" && showTrainType) ||
|
|
170
170
|
(option.type === "amenities" && showAmenities);
|
|
171
|
+
console.log("🚀 ~ ServiceFilter ~ renderFilterItem ~ isOpen:", isOpen);
|
|
171
172
|
|
|
172
|
-
// Return null for train_type if not a train
|
|
173
173
|
if (option?.type === "train_type" && !this.props.isTrain) {
|
|
174
174
|
return null;
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
if (option?.type === "operator" && this.props.hideOperator) {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
|
|
178
181
|
if (
|
|
179
182
|
this.props.isTrain &&
|
|
180
183
|
!["time", "tipo", "train_type"].includes(option?.type)
|
|
@@ -182,8 +185,6 @@ class ServiceFilter extends React.Component<
|
|
|
182
185
|
return null;
|
|
183
186
|
}
|
|
184
187
|
|
|
185
|
-
// This logic is similar to the functional component's conditional rendering
|
|
186
|
-
// Only show certain filter types for trains, similar to the functional component
|
|
187
188
|
const shouldShowHeader =
|
|
188
189
|
option?.type === "time" ||
|
|
189
190
|
(option?.type === "train_type" && this.props.isTrain) ||
|
|
@@ -301,9 +302,6 @@ class ServiceFilter extends React.Component<
|
|
|
301
302
|
render() {
|
|
302
303
|
const { onFilterSelected } = this.props;
|
|
303
304
|
const { sortedFilters } = this.state;
|
|
304
|
-
|
|
305
|
-
// console.log(this.props, "sortedFilters");
|
|
306
|
-
|
|
307
305
|
return (
|
|
308
306
|
<div>
|
|
309
307
|
<div
|
|
@@ -324,7 +322,7 @@ class ServiceFilter extends React.Component<
|
|
|
324
322
|
val.options?.length
|
|
325
323
|
? this.renderFilterItem(
|
|
326
324
|
val,
|
|
327
|
-
(i) => onFilterSelected(
|
|
325
|
+
(i) => onFilterSelected(key, i),
|
|
328
326
|
key
|
|
329
327
|
)
|
|
330
328
|
: null
|