@orderingstack/front-hooks 3.0.0 → 3.1.0

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/index.es.js CHANGED
@@ -3042,6 +3042,17 @@ axios$1.isAxiosError = isAxiosError;
3042
3042
  axios$2.exports = axios$1;
3043
3043
  axios$2.exports.default = axios$1;
3044
3044
  var axios = axios$2.exports;
3045
+ const getUrlFromLocalizedVenueMedia = (localizedVenueMedia, locale) => {
3046
+ var _a, _b, _c;
3047
+ if (localizedVenueMedia && ((_a = localizedVenueMedia == null ? void 0 : localizedVenueMedia.url) == null ? void 0 : _a.length) > 0) {
3048
+ return ((_b = localizedVenueMedia.url.find((item) => item.locale === locale)) == null ? void 0 : _b.value) || ((_c = localizedVenueMedia.url.find((item) => item.locale === "*")) == null ? void 0 : _c.value) || null;
3049
+ }
3050
+ return null;
3051
+ };
3052
+ const getLocalizedVenueMediaFromArray = (localizedVenueMedia, venue) => {
3053
+ var _a, _b;
3054
+ return ((_a = localizedVenueMedia == null ? void 0 : localizedVenueMedia.find) == null ? void 0 : _a.call(localizedVenueMedia, (item) => item.venue === venue)) || ((_b = localizedVenueMedia == null ? void 0 : localizedVenueMedia.find) == null ? void 0 : _b.call(localizedVenueMedia, (item) => item.venue === "*"));
3055
+ };
3045
3056
  function useCms(id, intervalSeconds = 600, withLocalStorage = true, baseUrl, tenant) {
3046
3057
  var _a, _b;
3047
3058
  if (!baseUrl || !tenant) {
@@ -3129,6 +3140,30 @@ function useLocalizedVenueMedia(id, venue, locale, intervalSeconds = 300, withLo
3129
3140
  }
3130
3141
  return { url: localizedValue, fallbackUrl, isError };
3131
3142
  }
3143
+ function useKioskMediaCms({
3144
+ kioskMediaId,
3145
+ kioskMediaType,
3146
+ intervalSeconds = 600,
3147
+ withLocalStorage = true,
3148
+ baseUrl,
3149
+ tenant,
3150
+ venue,
3151
+ locale
3152
+ }) {
3153
+ var _a;
3154
+ const { value, isError, isLoading } = useCms(kioskMediaId, intervalSeconds, withLocalStorage, baseUrl, tenant);
3155
+ const kioskMediaFoundType = (value == null ? void 0 : value[kioskMediaType]) || [];
3156
+ const kioskMediaFoundTypeVenue = getLocalizedVenueMediaFromArray(kioskMediaFoundType, venue);
3157
+ const localizedValue = getUrlFromLocalizedVenueMedia(kioskMediaFoundTypeVenue, locale);
3158
+ const fallbackUrl = !localizedValue && kioskMediaFoundTypeVenue && ((_a = kioskMediaFoundTypeVenue == null ? void 0 : kioskMediaFoundTypeVenue.url) == null ? void 0 : _a.length) > 0 ? kioskMediaFoundTypeVenue.url[0].value : null;
3159
+ return {
3160
+ url: localizedValue,
3161
+ fallbackUrl,
3162
+ mediaType: kioskMediaFoundTypeVenue == null ? void 0 : kioskMediaFoundTypeVenue.mediaType,
3163
+ isError,
3164
+ isLoading
3165
+ };
3166
+ }
3132
3167
  function useOnClickOutside(ref, handler) {
3133
3168
  useEffect(() => {
3134
3169
  const listener = (event) => {
@@ -3166,5 +3201,5 @@ function useKioskChannelsAvailability(channelConstrainst) {
3166
3201
  useInterval(checkOpen, 6e4);
3167
3202
  return { dineInOpen, takeAwayOpen };
3168
3203
  }
3169
- export { getGroupedBucketLines, groupOrderLines, useAvailability, useCms, useDisplayPrice, useGroupOrderLines, useInterval, useKioskChannelsAvailability, useLocalizedVenueMedia, useOnClickOutside, useVenueCms };
3204
+ export { getGroupedBucketLines, groupOrderLines, useAvailability, useCms, useDisplayPrice, useGroupOrderLines, useInterval, useKioskChannelsAvailability, useKioskMediaCms, useLocalizedVenueMedia, useOnClickOutside, useVenueCms };
3170
3205
  //# sourceMappingURL=index.es.js.map