mozrest-sdk-react-dev 0.2.45 → 0.2.46
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/mozrest-sdk.es.js +31 -13
- package/package.json +1 -1
package/mozrest-sdk.es.js
CHANGED
|
@@ -102398,7 +102398,7 @@ const SelectBrands = ({ handleSearchBrand }) => {
|
|
|
102398
102398
|
const { t: t2 } = useTranslation();
|
|
102399
102399
|
const { data: data2, isLoading } = useFetch(GetBrands, "brands");
|
|
102400
102400
|
return /* @__PURE__ */ React__default.createElement(NewSelect, {
|
|
102401
|
-
options: data2 && data2.data ? data2.data : [],
|
|
102401
|
+
options: data2 && data2.data ? data2.data : data2.length && data2.length > 0 ? data2 : [],
|
|
102402
102402
|
placeholder: t2("ALL"),
|
|
102403
102403
|
getOptionLabel: (option) => option.name,
|
|
102404
102404
|
getOptionValue: (option) => option.id,
|
|
@@ -102412,6 +102412,8 @@ const RestaurantsSelector = ({ open, onClose: onClose2, selectedRestaurants, set
|
|
|
102412
102412
|
const [searchValue, setSearchValue] = useState("");
|
|
102413
102413
|
const [currentPage, setCurrentPage] = useState(1);
|
|
102414
102414
|
const [currentRows, setCurrentRows] = useState(10);
|
|
102415
|
+
const [restaurantsToFilter, setRestaurantsToFilter] = useState([]);
|
|
102416
|
+
const [brandToFilter, setBrandToFilter] = useState(null);
|
|
102415
102417
|
const [params, setParams] = useState({
|
|
102416
102418
|
"sortby[name]": "ASC",
|
|
102417
102419
|
limit: 10,
|
|
@@ -102426,7 +102428,7 @@ const RestaurantsSelector = ({ open, onClose: onClose2, selectedRestaurants, set
|
|
|
102426
102428
|
setParams({ ...params, "filters[criteria]": e3.target.value });
|
|
102427
102429
|
};
|
|
102428
102430
|
const handleSearchBrand = (value2) => {
|
|
102429
|
-
|
|
102431
|
+
setBrandToFilter(value2);
|
|
102430
102432
|
setParams({ ...params, "filters[brand]": value2 ? value2.id : null });
|
|
102431
102433
|
};
|
|
102432
102434
|
const handleOnChangePage = (page) => {
|
|
@@ -102447,29 +102449,39 @@ const RestaurantsSelector = ({ open, onClose: onClose2, selectedRestaurants, set
|
|
|
102447
102449
|
};
|
|
102448
102450
|
const handleOnSelectAllRestaurants = (event) => {
|
|
102449
102451
|
if (event.target && event.target.checked) {
|
|
102450
|
-
|
|
102452
|
+
setRestaurantsToFilter(data2.data);
|
|
102451
102453
|
} else {
|
|
102452
|
-
|
|
102454
|
+
setRestaurantsToFilter([]);
|
|
102453
102455
|
}
|
|
102454
102456
|
};
|
|
102457
|
+
useEffect(() => {
|
|
102458
|
+
if (selectedRestaurants.length == 0) {
|
|
102459
|
+
setRestaurantsToFilter([]);
|
|
102460
|
+
}
|
|
102461
|
+
}, [selectedRestaurants]);
|
|
102462
|
+
useEffect(() => {
|
|
102463
|
+
if (!selectedBrand) {
|
|
102464
|
+
setBrandToFilter(null);
|
|
102465
|
+
}
|
|
102466
|
+
}, [selectedBrand]);
|
|
102455
102467
|
const tableHeader = [
|
|
102456
102468
|
{
|
|
102457
102469
|
label: /* @__PURE__ */ React__default.createElement("input", {
|
|
102458
102470
|
type: "checkbox",
|
|
102459
102471
|
style: { width: 20, height: 20 },
|
|
102460
|
-
checked: data2 && data2.data &&
|
|
102472
|
+
checked: data2 && data2.data && restaurantsToFilter.length === data2.data.length ? true : false,
|
|
102461
102473
|
onChange: (event) => handleOnSelectAllRestaurants(event)
|
|
102462
102474
|
}),
|
|
102463
102475
|
id: "actions",
|
|
102464
102476
|
render: (value2, item2) => /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement("input", {
|
|
102465
102477
|
type: "checkbox",
|
|
102466
102478
|
style: { width: 20, height: 20 },
|
|
102467
|
-
checked:
|
|
102479
|
+
checked: restaurantsToFilter.find((sr) => sr.id === item2.id ? true : false),
|
|
102468
102480
|
onChange: (event) => {
|
|
102469
102481
|
if (event.target.checked) {
|
|
102470
|
-
|
|
102482
|
+
setRestaurantsToFilter([...restaurantsToFilter, item2]);
|
|
102471
102483
|
} else {
|
|
102472
|
-
|
|
102484
|
+
setRestaurantsToFilter(restaurantsToFilter.filter((sr) => sr.id !== item2.id));
|
|
102473
102485
|
}
|
|
102474
102486
|
}
|
|
102475
102487
|
}))
|
|
@@ -102519,11 +102531,17 @@ const RestaurantsSelector = ({ open, onClose: onClose2, selectedRestaurants, set
|
|
|
102519
102531
|
className: styles$3.filtersContainer
|
|
102520
102532
|
}, /* @__PURE__ */ React__default.createElement("div", {
|
|
102521
102533
|
style: { display: "flex", gap: 10, justifyContent: "center" }
|
|
102522
|
-
},
|
|
102523
|
-
onClick: () =>
|
|
102524
|
-
|
|
102525
|
-
|
|
102526
|
-
|
|
102534
|
+
}, restaurantsToFilter.length > 0 && /* @__PURE__ */ React__default.createElement(Button$3, {
|
|
102535
|
+
onClick: () => {
|
|
102536
|
+
setSelectedRestaurants(restaurantsToFilter);
|
|
102537
|
+
onClose2();
|
|
102538
|
+
}
|
|
102539
|
+
}, t2("SelectXResturant", { value: restaurantsToFilter.length })), brandToFilter && /* @__PURE__ */ React__default.createElement(Button$3, {
|
|
102540
|
+
onClick: () => {
|
|
102541
|
+
setSelectedBrand(brandToFilter);
|
|
102542
|
+
onClose2();
|
|
102543
|
+
}
|
|
102544
|
+
}, t2("SelectAllFromX", { value: brandToFilter.name }))), /* @__PURE__ */ React__default.createElement("div", {
|
|
102527
102545
|
className: styles$3.filters
|
|
102528
102546
|
}, /* @__PURE__ */ React__default.createElement("div", {
|
|
102529
102547
|
style: { minWidth: 150 }
|