mozrest-sdk-react-dev 0.2.45 → 0.2.47
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 +30 -43
- package/package.json +1 -1
package/mozrest-sdk.es.js
CHANGED
|
@@ -102384,34 +102384,13 @@ var styles$3 = {
|
|
|
102384
102384
|
filtersContainer,
|
|
102385
102385
|
filters
|
|
102386
102386
|
};
|
|
102387
|
-
const GetBrands = async () => {
|
|
102388
|
-
const { data: data2 } = await instance$1.get(`brands`, {
|
|
102389
|
-
params: {
|
|
102390
|
-
limit: 50,
|
|
102391
|
-
offset: 0,
|
|
102392
|
-
"sortby[name]": "ASC"
|
|
102393
|
-
}
|
|
102394
|
-
});
|
|
102395
|
-
return data2;
|
|
102396
|
-
};
|
|
102397
|
-
const SelectBrands = ({ handleSearchBrand }) => {
|
|
102398
|
-
const { t: t2 } = useTranslation();
|
|
102399
|
-
const { data: data2, isLoading } = useFetch(GetBrands, "brands");
|
|
102400
|
-
return /* @__PURE__ */ React__default.createElement(NewSelect, {
|
|
102401
|
-
options: data2 && data2.data ? data2.data : [],
|
|
102402
|
-
placeholder: t2("ALL"),
|
|
102403
|
-
getOptionLabel: (option) => option.name,
|
|
102404
|
-
getOptionValue: (option) => option.id,
|
|
102405
|
-
isLoading,
|
|
102406
|
-
onChange: handleSearchBrand,
|
|
102407
|
-
isClearable: true
|
|
102408
|
-
});
|
|
102409
|
-
};
|
|
102410
102387
|
const RestaurantsSelector = ({ open, onClose: onClose2, selectedRestaurants, setSelectedRestaurants, selectedBrand, setSelectedBrand }) => {
|
|
102411
102388
|
const { t: t2 } = useTranslation();
|
|
102412
102389
|
const [searchValue, setSearchValue] = useState("");
|
|
102413
102390
|
const [currentPage, setCurrentPage] = useState(1);
|
|
102414
102391
|
const [currentRows, setCurrentRows] = useState(10);
|
|
102392
|
+
const [restaurantsToFilter, setRestaurantsToFilter] = useState([]);
|
|
102393
|
+
const [brandToFilter, setBrandToFilter] = useState(null);
|
|
102415
102394
|
const [params, setParams] = useState({
|
|
102416
102395
|
"sortby[name]": "ASC",
|
|
102417
102396
|
limit: 10,
|
|
@@ -102425,10 +102404,6 @@ const RestaurantsSelector = ({ open, onClose: onClose2, selectedRestaurants, set
|
|
|
102425
102404
|
setSearchValue(e3.target.value);
|
|
102426
102405
|
setParams({ ...params, "filters[criteria]": e3.target.value });
|
|
102427
102406
|
};
|
|
102428
|
-
const handleSearchBrand = (value2) => {
|
|
102429
|
-
setSelectedBrand(value2);
|
|
102430
|
-
setParams({ ...params, "filters[brand]": value2 ? value2.id : null });
|
|
102431
|
-
};
|
|
102432
102407
|
const handleOnChangePage = (page) => {
|
|
102433
102408
|
setCurrentPage(page);
|
|
102434
102409
|
setParams({
|
|
@@ -102447,29 +102422,39 @@ const RestaurantsSelector = ({ open, onClose: onClose2, selectedRestaurants, set
|
|
|
102447
102422
|
};
|
|
102448
102423
|
const handleOnSelectAllRestaurants = (event) => {
|
|
102449
102424
|
if (event.target && event.target.checked) {
|
|
102450
|
-
|
|
102425
|
+
setRestaurantsToFilter(data2.data);
|
|
102451
102426
|
} else {
|
|
102452
|
-
|
|
102427
|
+
setRestaurantsToFilter([]);
|
|
102453
102428
|
}
|
|
102454
102429
|
};
|
|
102430
|
+
useEffect(() => {
|
|
102431
|
+
if (selectedRestaurants.length == 0) {
|
|
102432
|
+
setRestaurantsToFilter([]);
|
|
102433
|
+
}
|
|
102434
|
+
}, [selectedRestaurants]);
|
|
102435
|
+
useEffect(() => {
|
|
102436
|
+
if (!selectedBrand) {
|
|
102437
|
+
setBrandToFilter(null);
|
|
102438
|
+
}
|
|
102439
|
+
}, [selectedBrand]);
|
|
102455
102440
|
const tableHeader = [
|
|
102456
102441
|
{
|
|
102457
102442
|
label: /* @__PURE__ */ React__default.createElement("input", {
|
|
102458
102443
|
type: "checkbox",
|
|
102459
102444
|
style: { width: 20, height: 20 },
|
|
102460
|
-
checked: data2 && data2.data &&
|
|
102445
|
+
checked: data2 && data2.data && restaurantsToFilter.length === data2.data.length ? true : false,
|
|
102461
102446
|
onChange: (event) => handleOnSelectAllRestaurants(event)
|
|
102462
102447
|
}),
|
|
102463
102448
|
id: "actions",
|
|
102464
102449
|
render: (value2, item2) => /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement("input", {
|
|
102465
102450
|
type: "checkbox",
|
|
102466
102451
|
style: { width: 20, height: 20 },
|
|
102467
|
-
checked:
|
|
102452
|
+
checked: restaurantsToFilter.find((sr) => sr.id === item2.id ? true : false),
|
|
102468
102453
|
onChange: (event) => {
|
|
102469
102454
|
if (event.target.checked) {
|
|
102470
|
-
|
|
102455
|
+
setRestaurantsToFilter([...restaurantsToFilter, item2]);
|
|
102471
102456
|
} else {
|
|
102472
|
-
|
|
102457
|
+
setRestaurantsToFilter(restaurantsToFilter.filter((sr) => sr.id !== item2.id));
|
|
102473
102458
|
}
|
|
102474
102459
|
}
|
|
102475
102460
|
}))
|
|
@@ -102519,11 +102504,17 @@ const RestaurantsSelector = ({ open, onClose: onClose2, selectedRestaurants, set
|
|
|
102519
102504
|
className: styles$3.filtersContainer
|
|
102520
102505
|
}, /* @__PURE__ */ React__default.createElement("div", {
|
|
102521
102506
|
style: { display: "flex", gap: 10, justifyContent: "center" }
|
|
102522
|
-
},
|
|
102523
|
-
onClick: () =>
|
|
102524
|
-
|
|
102525
|
-
|
|
102526
|
-
|
|
102507
|
+
}, restaurantsToFilter.length > 0 && /* @__PURE__ */ React__default.createElement(Button$3, {
|
|
102508
|
+
onClick: () => {
|
|
102509
|
+
setSelectedRestaurants(restaurantsToFilter);
|
|
102510
|
+
onClose2();
|
|
102511
|
+
}
|
|
102512
|
+
}, t2("SelectXResturant", { value: restaurantsToFilter.length })), brandToFilter && /* @__PURE__ */ React__default.createElement(Button$3, {
|
|
102513
|
+
onClick: () => {
|
|
102514
|
+
setSelectedBrand(brandToFilter);
|
|
102515
|
+
onClose2();
|
|
102516
|
+
}
|
|
102517
|
+
}, t2("SelectAllFromX", { value: brandToFilter.name }))), /* @__PURE__ */ React__default.createElement("div", {
|
|
102527
102518
|
className: styles$3.filters
|
|
102528
102519
|
}, /* @__PURE__ */ React__default.createElement("div", {
|
|
102529
102520
|
style: { minWidth: 150 }
|
|
@@ -102535,10 +102526,6 @@ const RestaurantsSelector = ({ open, onClose: onClose2, selectedRestaurants, set
|
|
|
102535
102526
|
value: searchValue,
|
|
102536
102527
|
placeholder: "Search ....",
|
|
102537
102528
|
onChange: (e3) => handleSearch(e3)
|
|
102538
|
-
})), /* @__PURE__ */ React__default.createElement("div", {
|
|
102539
|
-
style: { minWidth: 150 }
|
|
102540
|
-
}, /* @__PURE__ */ React__default.createElement(SelectBrands, {
|
|
102541
|
-
handleSearchBrand
|
|
102542
102529
|
})))), /* @__PURE__ */ React__default.createElement(CustomTable, {
|
|
102543
102530
|
header: tableHeader,
|
|
102544
102531
|
data: data2 ? data2.data : [],
|
|
@@ -102897,7 +102884,7 @@ const StatsBar = ({ params }) => {
|
|
|
102897
102884
|
const fetchBookingStat = async (payload, cancellations, prevPeriod) => {
|
|
102898
102885
|
const params2 = { ...payload };
|
|
102899
102886
|
if (cancellations) {
|
|
102900
|
-
params2["filters[status]"] = "
|
|
102887
|
+
params2["filters[status]"] = "canceled";
|
|
102901
102888
|
}
|
|
102902
102889
|
const [, response] = await handlePromise(ReservationAnalyticsService.getBookingItemTotal(params2));
|
|
102903
102890
|
if (!response)
|