@open-tender/cloud 0.1.39 → 0.1.41

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.
@@ -55,5 +55,6 @@ export declare const useAppDispatch: () => import("redux-thunk").ThunkDispatch<i
55
55
  posts: import("..").PostsSlice;
56
56
  sidebarModal: import("..").SidebarModalState;
57
57
  sidebar: import("..").SidebarState;
58
+ tags: import("..").TagsState;
58
59
  }>, undefined, import("redux").AnyAction> & import("redux").Dispatch<import("redux").Action<any>>;
59
60
  export declare const useAppSelector: TypedUseSelectorHook<RootState>;
@@ -54,6 +54,7 @@ export declare const appReducer: import("redux").Reducer<import("redux").Combine
54
54
  posts: import("../slices").PostsSlice;
55
55
  sidebarModal: import("../slices").SidebarModalState;
56
56
  sidebar: import("../slices").SidebarState;
57
+ tags: import("../slices").TagsState;
57
58
  }>, import("redux").AnyAction>;
58
59
  export type AppState = ReturnType<typeof appReducer>;
59
60
  declare const store: import("@reduxjs/toolkit/dist/configureStore").ToolkitStore<import("redux").EmptyObject & {
@@ -111,6 +112,7 @@ declare const store: import("@reduxjs/toolkit/dist/configureStore").ToolkitStore
111
112
  posts: import("../slices").PostsSlice;
112
113
  sidebarModal: import("../slices").SidebarModalState;
113
114
  sidebar: import("../slices").SidebarState;
115
+ tags: import("../slices").TagsState;
114
116
  }, Action<any>, import("@reduxjs/toolkit").MiddlewareArray<[import("@reduxjs/toolkit").ThunkMiddleware<import("redux").CombinedState<{
115
117
  alerts: import("@open-tender/types").Alerts;
116
118
  notifications: import("@open-tender/types").Notifications;
@@ -166,6 +168,7 @@ declare const store: import("@reduxjs/toolkit/dist/configureStore").ToolkitStore
166
168
  posts: import("../slices").PostsSlice;
167
169
  sidebarModal: import("../slices").SidebarModalState;
168
170
  sidebar: import("../slices").SidebarState;
171
+ tags: import("../slices").TagsState;
169
172
  }>, import("redux").AnyAction, undefined>]>>;
170
173
  export type AppDispatch = typeof store.dispatch;
171
174
  export type RootState = ReturnType<typeof store.getState>;
@@ -40,7 +40,8 @@ exports.appReducer = (0, toolkit_1.combineReducers)({
40
40
  [types_1.ReducerType.Nav]: slices_1.navReducer,
41
41
  [types_1.ReducerType.Posts]: slices_1.postsReducer,
42
42
  [types_1.ReducerType.SidebarModal]: slices_1.sidebarModalReducer,
43
- [types_1.ReducerType.Sidebar]: slices_1.sidebarReducer
43
+ [types_1.ReducerType.Sidebar]: slices_1.sidebarReducer,
44
+ [types_1.ReducerType.Tags]: slices_1.tagsReducer
44
45
  });
45
46
  const rootReducer = (state, action) => {
46
47
  if (action.type === 'clearState') {
@@ -61,6 +61,7 @@ declare class OpenTenderAPI {
61
61
  getLocations(revenue_center_type: RevenueCenterType, is_outpost: boolean, lat: number, lng: number, requestedAt: string): Promise<unknown>;
62
62
  getLocation(revenue_center_id: number): Promise<unknown>;
63
63
  getValidTimes(revenueCenterType: RevenueCenterType): Promise<unknown>;
64
+ getTags(): Promise<unknown>;
64
65
  getAllergens(): Promise<unknown>;
65
66
  getMenu(revenueCenterId: number, serviceType: ServiceType, requestedAt: string): Promise<unknown>;
66
67
  getMenuItems(revenueCenterId: number, serviceType: ServiceType): Promise<unknown>;
@@ -336,6 +336,9 @@ class OpenTenderAPI {
336
336
  const params = `revenue_center_type=${revenueCenterType}`;
337
337
  return this.request(`/valid-times?${params}`);
338
338
  }
339
+ getTags() {
340
+ return this.request(`/tags?with_related=true`);
341
+ }
339
342
  getAllergens() {
340
343
  return this.request(`/allergens?with_related=true`);
341
344
  }
@@ -1,15 +1,20 @@
1
1
  import { AppState } from '../app';
2
- import { Allergens, RequestError, RequestStatus } from '@open-tender/types';
2
+ import { Allergens, AllergenLookupEnhanced, RequestError, RequestStatus } from '@open-tender/types';
3
3
  export interface AllergensState {
4
4
  entities: Allergens;
5
5
  error: RequestError;
6
6
  loading: RequestStatus;
7
7
  selectedAllergens: Allergens | null;
8
+ lookup: AllergenLookupEnhanced;
8
9
  }
9
10
  export declare enum AllergensActionType {
10
11
  FetchAllergens = "allergens/fetchAllergens"
11
12
  }
12
- export declare const fetchAllergens: import("@reduxjs/toolkit").AsyncThunk<Allergens, void, {
13
+ export interface AllergensPayload {
14
+ data: Allergens;
15
+ lookup: AllergenLookupEnhanced;
16
+ }
17
+ export declare const fetchAllergens: import("@reduxjs/toolkit").AsyncThunk<AllergensPayload, void, {
13
18
  state: AppState;
14
19
  rejectValue: RequestError;
15
20
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
@@ -21,5 +26,69 @@ export declare const fetchAllergens: import("@reduxjs/toolkit").AsyncThunk<Aller
21
26
  }>;
22
27
  export declare const resetAllergens: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"allergens/resetAllergens">, setSelectedAllergens: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "allergens/setSelectedAllergens">;
23
28
  export declare const selectAllergens: (state: AppState) => AllergensState;
24
- export declare const selectSelectedAllergenNames: (state: AppState) => string[];
29
+ export declare const selectSelectedAllergens: (state: AppState) => Allergens | null;
30
+ export declare const selectSelectedAllergenNames: ((state: import("redux").EmptyObject & {
31
+ alerts: import("@open-tender/types").Alerts;
32
+ notifications: import("@open-tender/types").Notifications;
33
+ allergens: AllergensState;
34
+ announcements: import("./announcements").AnnouncementsState;
35
+ customer: import("redux").CombinedState<{
36
+ account: import("./customer").AccountState;
37
+ allergens: import("./customer").CustomerAllergensState;
38
+ addresses: import("./customer").CustomerAddressesState;
39
+ communicationPreferences: import("./customer").CustomerCommunicationPrefsState;
40
+ creditCards: import("./customer").CustomerCreditCardsState;
41
+ favorites: import("./customer").CustomerFavoritesState;
42
+ fcmToken: import("./customer").CustomerFcmTokenState;
43
+ giftCards: import("./customer").CustomerGiftCardsState;
44
+ orders: import("./customer").CustomerOrdersState;
45
+ order: import("./customer").CustomerOrderState;
46
+ loyalty: import("./customer").CustomerLoyaltyState;
47
+ groupOrders: import("./customer").CustomerGroupOrdersState;
48
+ houseAccounts: import("./customer").CustomerHouseAccountsState;
49
+ rewards: import("./customer").CustomerRewardsState;
50
+ qrcode: import("./customer").CustomerQRCodeState;
51
+ thanx: import("./customer").CustomerThanxState;
52
+ levelup: import("./customer").CustomerLevelUpState;
53
+ }>;
54
+ signUp: import("./signUp").SignUpState;
55
+ revenueCenters: import("./revenueCenters").RevenueCentersState;
56
+ completedOrders: import("./completedOrders").CompletedOrdersState;
57
+ checkout: import("./checkout").CheckoutState;
58
+ order: import("./order").OrderState;
59
+ orderFulfillment: import("./orderFulfillment").OrderFulfillmentState;
60
+ orderRating: import("./orderRating").OrderRatingState;
61
+ deals: import("./deals").DealState;
62
+ confirmation: import("./confirmation").ConfirmationState;
63
+ donations: import("./donations").DonationState;
64
+ guest: import("./guest").GuestState;
65
+ verifyAccount: import("./verifyAccount").VerifyAccountState;
66
+ menu: import("./menu").MenuState;
67
+ resetPassword: import("./resetPassword").ResetPasswordState;
68
+ validTimes: import("./validTimes").ValidTimesState;
69
+ menuItems: import("./menuItems").MenuItemsState;
70
+ menuDisplay: import("./menuDisplay").MenuDisplayState;
71
+ giftCards: import("./giftCards").GiftCardsState;
72
+ groupOrder: import("./groupOrder").GroupOrderState;
73
+ levelup: import("./levelup").LevelupState;
74
+ config: import("./config").ConfigState;
75
+ geolocation: import("./geolocation").GeoLocationState;
76
+ loader: import("./loader").LoaderState;
77
+ qr: import("./qr").QrState;
78
+ misc: import("./misc").MiscState;
79
+ modal: import("@open-tender/types").Modal;
80
+ navSite: import("./navSite").NavSiteState;
81
+ nav: import("./nav").NavState;
82
+ posts: import("./posts").PostsSlice;
83
+ sidebarModal: import("./sidebarModal").SidebarModalState;
84
+ sidebar: import("./sidebar").SidebarState;
85
+ tags: import("./tags").TagsState;
86
+ }) => string[]) & import("reselect").OutputSelectorFields<(args_0: {
87
+ allergens: Allergens;
88
+ selectedAllergens: Allergens | null;
89
+ }) => string[], {
90
+ clearCache: () => void;
91
+ }> & {
92
+ clearCache: () => void;
93
+ };
25
94
  export declare const allergensReducer: import("redux").Reducer<AllergensState, import("redux").AnyAction>;
@@ -1,15 +1,25 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.allergensReducer = exports.selectSelectedAllergenNames = exports.selectAllergens = exports.setSelectedAllergens = exports.resetAllergens = exports.fetchAllergens = exports.AllergensActionType = void 0;
4
+ exports.allergensReducer = exports.selectSelectedAllergenNames = exports.selectSelectedAllergens = exports.selectAllergens = exports.setSelectedAllergens = exports.resetAllergens = exports.fetchAllergens = exports.AllergensActionType = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  const toolkit_1 = require("@reduxjs/toolkit");
7
7
  const types_1 = require("./types");
8
+ const utils_1 = require("@open-tender/utils");
9
+ const makeAllergenLookup = (data) => {
10
+ return data.reduce((obj, i) => {
11
+ const imageMap = (0, utils_1.makeImageMap)(i.images);
12
+ const imageUrl = imageMap.SMALL_IMAGE || imageMap.APP_IMAGE || imageMap.LARGE_IMAGE || '';
13
+ const tag = Object.assign(Object.assign({}, i), { imageUrl });
14
+ return Object.assign(Object.assign({}, obj), { [i.name]: tag });
15
+ }, {});
16
+ };
8
17
  const initialState = {
9
18
  entities: [],
10
19
  error: null,
11
20
  loading: 'idle',
12
- selectedAllergens: null
21
+ selectedAllergens: null,
22
+ lookup: {}
13
23
  };
14
24
  var AllergensActionType;
15
25
  (function (AllergensActionType) {
@@ -19,7 +29,8 @@ exports.fetchAllergens = (0, toolkit_1.createAsyncThunk)(AllergensActionType.Fet
19
29
  try {
20
30
  const api = getState().config.api;
21
31
  const { data } = yield api.getAllergens();
22
- return data;
32
+ const lookup = makeAllergenLookup(data);
33
+ return { data, lookup };
23
34
  }
24
35
  catch (err) {
25
36
  return rejectWithValue(err);
@@ -37,7 +48,8 @@ const allergensSlice = (0, toolkit_1.createSlice)({
37
48
  extraReducers: builder => {
38
49
  builder
39
50
  .addCase(exports.fetchAllergens.fulfilled, (state, action) => {
40
- state.entities = action.payload;
51
+ state.entities = action.payload.data;
52
+ state.lookup = action.payload.lookup;
41
53
  state.loading = 'idle';
42
54
  state.error = null;
43
55
  })
@@ -53,16 +65,29 @@ const allergensSlice = (0, toolkit_1.createSlice)({
53
65
  _a = allergensSlice.actions, exports.resetAllergens = _a.resetAllergens, exports.setSelectedAllergens = _a.setSelectedAllergens;
54
66
  const selectAllergens = (state) => state.allergens;
55
67
  exports.selectAllergens = selectAllergens;
56
- const selectSelectedAllergenNames = (state) => {
68
+ const selectSelectedAllergens = (state) => state.allergens.selectedAllergens;
69
+ exports.selectSelectedAllergens = selectSelectedAllergens;
70
+ // export const selectSelectedAllergenNames = (state: AppState) => {
71
+ // const { entities: allergens, selectedAllergens } = state.allergens
72
+ // if (!allergens.length || !selectedAllergens || !selectedAllergens.length) {
73
+ // return []
74
+ // }
75
+ // return selectedAllergens.map(i => {
76
+ // const allergen = allergens.find(a => a.allergen_id === i.allergen_id)
77
+ // return allergen ? allergen.name ?? '' : ''
78
+ // })
79
+ // }
80
+ exports.selectSelectedAllergenNames = (0, toolkit_1.createSelector)((state) => {
57
81
  const { entities: allergens, selectedAllergens } = state.allergens;
58
- if (!allergens.length || !selectedAllergens || !selectedAllergens.length) {
82
+ return { allergens, selectedAllergens };
83
+ }, ({ allergens, selectedAllergens }) => {
84
+ if (!selectedAllergens)
59
85
  return [];
60
- }
61
- return selectedAllergens.map(i => {
86
+ const selected = selectedAllergens.map(i => {
62
87
  var _a;
63
88
  const allergen = allergens.find(a => a.allergen_id === i.allergen_id);
64
89
  return allergen ? (_a = allergen.name) !== null && _a !== void 0 ? _a : '' : '';
65
90
  });
66
- };
67
- exports.selectSelectedAllergenNames = selectSelectedAllergenNames;
91
+ return selected;
92
+ });
68
93
  exports.allergensReducer = allergensSlice.reducer;
@@ -23,8 +23,7 @@ exports.fetchDeals = (0, toolkit_1.createAsyncThunk)(DealActionType.FetchDeals,
23
23
  try {
24
24
  const { profile } = getState().customer.account;
25
25
  const { customer_id = null } = profile || {};
26
- const deals = yield api.getDeals(customer_id);
27
- return deals;
26
+ return yield api.getDeals(customer_id);
28
27
  }
29
28
  catch (err) {
30
29
  return rejectWithValue(err);
@@ -32,5 +32,6 @@ export * from './revenueCenters';
32
32
  export * from './sidebar';
33
33
  export * from './sidebarModal';
34
34
  export * from './signUp';
35
+ export * from './tags';
35
36
  export * from './validTimes';
36
37
  export * from './verifyAccount';
@@ -35,5 +35,6 @@ tslib_1.__exportStar(require("./revenueCenters"), exports);
35
35
  tslib_1.__exportStar(require("./sidebar"), exports);
36
36
  tslib_1.__exportStar(require("./sidebarModal"), exports);
37
37
  tslib_1.__exportStar(require("./signUp"), exports);
38
+ tslib_1.__exportStar(require("./tags"), exports);
38
39
  tslib_1.__exportStar(require("./validTimes"), exports);
39
40
  tslib_1.__exportStar(require("./verifyAccount"), exports);
@@ -0,0 +1,94 @@
1
+ import { AppState } from '../app';
2
+ import { TagLookupEnhanced, Tags, RequestError, RequestStatus } from '@open-tender/types';
3
+ export interface TagsState {
4
+ entities: Tags;
5
+ error: RequestError;
6
+ loading: RequestStatus;
7
+ selectedTags: Tags | null;
8
+ lookup: TagLookupEnhanced | null;
9
+ }
10
+ export declare enum TagsActionType {
11
+ FetchTags = "tags/fetchTags"
12
+ }
13
+ export interface TagsPayload {
14
+ data: Tags;
15
+ lookup: TagLookupEnhanced;
16
+ }
17
+ export declare const fetchTags: import("@reduxjs/toolkit").AsyncThunk<TagsPayload, void, {
18
+ state: AppState;
19
+ rejectValue: RequestError;
20
+ dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
21
+ extra?: unknown;
22
+ serializedErrorType?: unknown;
23
+ pendingMeta?: unknown;
24
+ fulfilledMeta?: unknown;
25
+ rejectedMeta?: unknown;
26
+ }>;
27
+ export declare const resetTags: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"tags/resetTags">, setSelectedTags: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "tags/setSelectedTags">;
28
+ export declare const selectTags: (state: AppState) => TagsState;
29
+ export declare const selectSelectedTags: (state: AppState) => Tags | null;
30
+ export declare const selectSelectedTagNames: ((state: import("redux").EmptyObject & {
31
+ alerts: import("@open-tender/types").Alerts;
32
+ notifications: import("@open-tender/types").Notifications;
33
+ allergens: import("./allergens").AllergensState;
34
+ announcements: import("./announcements").AnnouncementsState;
35
+ customer: import("redux").CombinedState<{
36
+ account: import("./customer").AccountState;
37
+ allergens: import("./customer").CustomerAllergensState;
38
+ addresses: import("./customer").CustomerAddressesState;
39
+ communicationPreferences: import("./customer").CustomerCommunicationPrefsState;
40
+ creditCards: import("./customer").CustomerCreditCardsState;
41
+ favorites: import("./customer").CustomerFavoritesState;
42
+ fcmToken: import("./customer").CustomerFcmTokenState;
43
+ giftCards: import("./customer").CustomerGiftCardsState;
44
+ orders: import("./customer").CustomerOrdersState;
45
+ order: import("./customer").CustomerOrderState;
46
+ loyalty: import("./customer").CustomerLoyaltyState;
47
+ groupOrders: import("./customer").CustomerGroupOrdersState;
48
+ houseAccounts: import("./customer").CustomerHouseAccountsState;
49
+ rewards: import("./customer").CustomerRewardsState;
50
+ qrcode: import("./customer").CustomerQRCodeState;
51
+ thanx: import("./customer").CustomerThanxState;
52
+ levelup: import("./customer").CustomerLevelUpState;
53
+ }>;
54
+ signUp: import("./signUp").SignUpState;
55
+ revenueCenters: import("./revenueCenters").RevenueCentersState;
56
+ completedOrders: import("./completedOrders").CompletedOrdersState;
57
+ checkout: import("./checkout").CheckoutState;
58
+ order: import("./order").OrderState;
59
+ orderFulfillment: import("./orderFulfillment").OrderFulfillmentState;
60
+ orderRating: import("./orderRating").OrderRatingState;
61
+ deals: import("./deals").DealState;
62
+ confirmation: import("./confirmation").ConfirmationState;
63
+ donations: import("./donations").DonationState;
64
+ guest: import("./guest").GuestState;
65
+ verifyAccount: import("./verifyAccount").VerifyAccountState;
66
+ menu: import("./menu").MenuState;
67
+ resetPassword: import("./resetPassword").ResetPasswordState;
68
+ validTimes: import("./validTimes").ValidTimesState;
69
+ menuItems: import("./menuItems").MenuItemsState;
70
+ menuDisplay: import("./menuDisplay").MenuDisplayState;
71
+ giftCards: import("./giftCards").GiftCardsState;
72
+ groupOrder: import("./groupOrder").GroupOrderState;
73
+ levelup: import("./levelup").LevelupState;
74
+ config: import("./config").ConfigState;
75
+ geolocation: import("./geolocation").GeoLocationState;
76
+ loader: import("./loader").LoaderState;
77
+ qr: import("./qr").QrState;
78
+ misc: import("./misc").MiscState;
79
+ modal: import("@open-tender/types").Modal;
80
+ navSite: import("./navSite").NavSiteState;
81
+ nav: import("./nav").NavState;
82
+ posts: import("./posts").PostsSlice;
83
+ sidebarModal: import("./sidebarModal").SidebarModalState;
84
+ sidebar: import("./sidebar").SidebarState;
85
+ tags: TagsState;
86
+ }) => string[]) & import("reselect").OutputSelectorFields<(args_0: {
87
+ tags: Tags;
88
+ selectedTags: Tags | null;
89
+ }) => string[], {
90
+ clearCache: () => void;
91
+ }> & {
92
+ clearCache: () => void;
93
+ };
94
+ export declare const tagsReducer: import("redux").Reducer<TagsState, import("redux").AnyAction>;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.tagsReducer = exports.selectSelectedTagNames = exports.selectSelectedTags = exports.selectTags = exports.setSelectedTags = exports.resetTags = exports.fetchTags = exports.TagsActionType = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const toolkit_1 = require("@reduxjs/toolkit");
7
+ const types_1 = require("./types");
8
+ const utils_1 = require("@open-tender/utils");
9
+ const makeTagLookup = (data) => {
10
+ return data.reduce((obj, i) => {
11
+ const imageMap = (0, utils_1.makeImageMap)(i.images);
12
+ const imageUrl = imageMap.SMALL_IMAGE || imageMap.APP_IMAGE || imageMap.LARGE_IMAGE || '';
13
+ const tag = Object.assign(Object.assign({}, i), { imageUrl });
14
+ return Object.assign(Object.assign({}, obj), { [i.name]: tag });
15
+ }, {});
16
+ };
17
+ const initialState = {
18
+ entities: [],
19
+ error: null,
20
+ loading: 'idle',
21
+ selectedTags: null,
22
+ lookup: {}
23
+ };
24
+ var TagsActionType;
25
+ (function (TagsActionType) {
26
+ TagsActionType["FetchTags"] = "tags/fetchTags";
27
+ })(TagsActionType = exports.TagsActionType || (exports.TagsActionType = {}));
28
+ exports.fetchTags = (0, toolkit_1.createAsyncThunk)(TagsActionType.FetchTags, (_, { getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
29
+ try {
30
+ const api = getState().config.api;
31
+ const { data } = yield api.getTags();
32
+ const lookup = makeTagLookup(data);
33
+ return { data, lookup };
34
+ }
35
+ catch (err) {
36
+ return rejectWithValue(err);
37
+ }
38
+ }));
39
+ const tagsSlice = (0, toolkit_1.createSlice)({
40
+ name: types_1.ReducerType.Tags,
41
+ initialState,
42
+ reducers: {
43
+ resetTags: () => initialState,
44
+ setSelectedTags: (state, action) => {
45
+ state.selectedTags = action.payload;
46
+ }
47
+ },
48
+ extraReducers: builder => {
49
+ builder
50
+ .addCase(exports.fetchTags.fulfilled, (state, action) => {
51
+ state.entities = action.payload.data;
52
+ state.lookup = action.payload.lookup;
53
+ state.loading = 'idle';
54
+ state.error = null;
55
+ })
56
+ .addCase(exports.fetchTags.pending, state => {
57
+ state.loading = 'pending';
58
+ })
59
+ .addCase(exports.fetchTags.rejected, (state, action) => {
60
+ state.error = action.payload;
61
+ state.loading = 'idle';
62
+ });
63
+ }
64
+ });
65
+ _a = tagsSlice.actions, exports.resetTags = _a.resetTags, exports.setSelectedTags = _a.setSelectedTags;
66
+ const selectTags = (state) => state.tags;
67
+ exports.selectTags = selectTags;
68
+ const selectSelectedTags = (state) => state.tags.selectedTags;
69
+ exports.selectSelectedTags = selectSelectedTags;
70
+ exports.selectSelectedTagNames = (0, toolkit_1.createSelector)((state) => {
71
+ const { entities: tags, selectedTags } = state.tags;
72
+ return { tags, selectedTags };
73
+ }, ({ tags, selectedTags }) => {
74
+ if (!selectedTags)
75
+ return [];
76
+ const selected = selectedTags.map(i => {
77
+ var _a;
78
+ const allergen = tags.find(a => a.allergen_id === i.allergen_id);
79
+ return allergen ? (_a = allergen.name) !== null && _a !== void 0 ? _a : '' : '';
80
+ });
81
+ return selected;
82
+ });
83
+ exports.tagsReducer = tagsSlice.reducer;
@@ -1,53 +1,54 @@
1
1
  export declare enum ReducerType {
2
+ Account = "account",
2
3
  Alerts = "alerts",
3
- Notifications = "notifications",
4
4
  Allergens = "allergens",
5
5
  Announcements = "announcements",
6
- Settings = "settings",
7
- Customer = "customer",
8
- SignUp = "signUp",
9
- Account = "account",
10
- CustomerAllergens = "allergens",
11
- CustomerAddresses = "addresses",
6
+ Checkout = "checkout",
12
7
  CommunicationPrefs = "communicationPreferences",
8
+ Config = "config",
9
+ Confirmation = "confirmation",
10
+ CompletedOrders = "completedOrders",
13
11
  CreditCards = "creditCards",
12
+ Customer = "customer",
13
+ CustomerAddresses = "addresses",
14
+ CustomerAllergens = "allergens",
15
+ Deals = "deals",
16
+ Donations = "donations",
14
17
  Favorites = "favorites",
15
18
  FcmToken = "fcmToken",
19
+ Geolocation = "geolocation",
16
20
  GiftCards = "giftCards",
21
+ GroupOrder = "groupOrder",
17
22
  GroupOrders = "groupOrders",
23
+ Guest = "guest",
18
24
  HouseAccounts = "houseAccounts",
19
25
  Levelup = "levelup",
26
+ Loader = "loader",
20
27
  Loyalty = "loyalty",
21
- Order = "order",
22
- Orders = "orders",
23
- QRCode = "qrcode",
24
- Rewards = "rewards",
25
- Thanx = "thanx",
26
- RevenueCenters = "revenueCenters",
27
- CompletedOrders = "completedOrders",
28
- Checkout = "checkout",
29
- OrderFulfillment = "orderFulfillment",
30
- OrderRating = "orderRating",
31
- Deals = "deals",
32
- Confirmation = "confirmation",
33
- Donations = "donations",
34
- Guest = "guest",
35
- VerifyAccount = "verifyAccount",
36
28
  Menu = "menu",
37
- ResetPassword = "resetPassword",
38
- ValidTimes = "validTimes",
39
- MenuItems = "menuItems",
40
29
  MenuDisplay = "menuDisplay",
41
- GroupOrder = "groupOrder",
42
- Config = "config",
43
- Geolocation = "geolocation",
44
- Loader = "loader",
30
+ MenuItems = "menuItems",
45
31
  Misc = "misc",
46
- Qr = "qr",
47
32
  Modal = "modal",
48
- NavSite = "navSite",
49
33
  Nav = "nav",
34
+ NavSite = "navSite",
35
+ Notifications = "notifications",
36
+ Order = "order",
37
+ OrderFulfillment = "orderFulfillment",
38
+ OrderRating = "orderRating",
39
+ Orders = "orders",
50
40
  Posts = "posts",
41
+ Qr = "qr",
42
+ QRCode = "qrcode",
43
+ ResetPassword = "resetPassword",
44
+ RevenueCenters = "revenueCenters",
45
+ Rewards = "rewards",
46
+ Settings = "settings",
47
+ Sidebar = "sidebar",
51
48
  SidebarModal = "sidebarModal",
52
- Sidebar = "sidebar"
49
+ SignUp = "signUp",
50
+ Tags = "tags",
51
+ Thanx = "thanx",
52
+ ValidTimes = "validTimes",
53
+ VerifyAccount = "verifyAccount"
53
54
  }
@@ -3,55 +3,56 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ReducerType = void 0;
4
4
  var ReducerType;
5
5
  (function (ReducerType) {
6
+ ReducerType["Account"] = "account";
6
7
  ReducerType["Alerts"] = "alerts";
7
- ReducerType["Notifications"] = "notifications";
8
8
  ReducerType["Allergens"] = "allergens";
9
9
  ReducerType["Announcements"] = "announcements";
10
- ReducerType["Settings"] = "settings";
11
- ReducerType["Customer"] = "customer";
12
- ReducerType["SignUp"] = "signUp";
13
- ReducerType["Account"] = "account";
14
- ReducerType["CustomerAllergens"] = "allergens";
15
- ReducerType["CustomerAddresses"] = "addresses";
10
+ ReducerType["Checkout"] = "checkout";
16
11
  ReducerType["CommunicationPrefs"] = "communicationPreferences";
12
+ ReducerType["Config"] = "config";
13
+ ReducerType["Confirmation"] = "confirmation";
14
+ ReducerType["CompletedOrders"] = "completedOrders";
17
15
  ReducerType["CreditCards"] = "creditCards";
16
+ ReducerType["Customer"] = "customer";
17
+ ReducerType["CustomerAddresses"] = "addresses";
18
+ ReducerType["CustomerAllergens"] = "allergens";
19
+ ReducerType["Deals"] = "deals";
20
+ ReducerType["Donations"] = "donations";
18
21
  ReducerType["Favorites"] = "favorites";
19
22
  ReducerType["FcmToken"] = "fcmToken";
23
+ ReducerType["Geolocation"] = "geolocation";
20
24
  ReducerType["GiftCards"] = "giftCards";
25
+ ReducerType["GroupOrder"] = "groupOrder";
21
26
  ReducerType["GroupOrders"] = "groupOrders";
27
+ ReducerType["Guest"] = "guest";
22
28
  ReducerType["HouseAccounts"] = "houseAccounts";
23
29
  ReducerType["Levelup"] = "levelup";
30
+ ReducerType["Loader"] = "loader";
24
31
  ReducerType["Loyalty"] = "loyalty";
25
- ReducerType["Order"] = "order";
26
- ReducerType["Orders"] = "orders";
27
- ReducerType["QRCode"] = "qrcode";
28
- ReducerType["Rewards"] = "rewards";
29
- ReducerType["Thanx"] = "thanx";
30
- ReducerType["RevenueCenters"] = "revenueCenters";
31
- ReducerType["CompletedOrders"] = "completedOrders";
32
- ReducerType["Checkout"] = "checkout";
33
- ReducerType["OrderFulfillment"] = "orderFulfillment";
34
- ReducerType["OrderRating"] = "orderRating";
35
- ReducerType["Deals"] = "deals";
36
- ReducerType["Confirmation"] = "confirmation";
37
- ReducerType["Donations"] = "donations";
38
- ReducerType["Guest"] = "guest";
39
- ReducerType["VerifyAccount"] = "verifyAccount";
40
32
  ReducerType["Menu"] = "menu";
41
- ReducerType["ResetPassword"] = "resetPassword";
42
- ReducerType["ValidTimes"] = "validTimes";
43
- ReducerType["MenuItems"] = "menuItems";
44
33
  ReducerType["MenuDisplay"] = "menuDisplay";
45
- ReducerType["GroupOrder"] = "groupOrder";
46
- ReducerType["Config"] = "config";
47
- ReducerType["Geolocation"] = "geolocation";
48
- ReducerType["Loader"] = "loader";
34
+ ReducerType["MenuItems"] = "menuItems";
49
35
  ReducerType["Misc"] = "misc";
50
- ReducerType["Qr"] = "qr";
51
36
  ReducerType["Modal"] = "modal";
52
- ReducerType["NavSite"] = "navSite";
53
37
  ReducerType["Nav"] = "nav";
38
+ ReducerType["NavSite"] = "navSite";
39
+ ReducerType["Notifications"] = "notifications";
40
+ ReducerType["Order"] = "order";
41
+ ReducerType["OrderFulfillment"] = "orderFulfillment";
42
+ ReducerType["OrderRating"] = "orderRating";
43
+ ReducerType["Orders"] = "orders";
54
44
  ReducerType["Posts"] = "posts";
55
- ReducerType["SidebarModal"] = "sidebarModal";
45
+ ReducerType["Qr"] = "qr";
46
+ ReducerType["QRCode"] = "qrcode";
47
+ ReducerType["ResetPassword"] = "resetPassword";
48
+ ReducerType["RevenueCenters"] = "revenueCenters";
49
+ ReducerType["Rewards"] = "rewards";
50
+ ReducerType["Settings"] = "settings";
56
51
  ReducerType["Sidebar"] = "sidebar";
52
+ ReducerType["SidebarModal"] = "sidebarModal";
53
+ ReducerType["SignUp"] = "signUp";
54
+ ReducerType["Tags"] = "tags";
55
+ ReducerType["Thanx"] = "thanx";
56
+ ReducerType["ValidTimes"] = "validTimes";
57
+ ReducerType["VerifyAccount"] = "verifyAccount";
57
58
  })(ReducerType = exports.ReducerType || (exports.ReducerType = {}));
@@ -55,5 +55,6 @@ export declare const useAppDispatch: () => import("redux-thunk").ThunkDispatch<i
55
55
  posts: import("..").PostsSlice;
56
56
  sidebarModal: import("..").SidebarModalState;
57
57
  sidebar: import("..").SidebarState;
58
+ tags: import("..").TagsState;
58
59
  }>, undefined, import("redux").AnyAction> & import("redux").Dispatch<import("redux").Action<any>>;
59
60
  export declare const useAppSelector: TypedUseSelectorHook<RootState>;
@@ -54,6 +54,7 @@ export declare const appReducer: import("redux").Reducer<import("redux").Combine
54
54
  posts: import("../slices").PostsSlice;
55
55
  sidebarModal: import("../slices").SidebarModalState;
56
56
  sidebar: import("../slices").SidebarState;
57
+ tags: import("../slices").TagsState;
57
58
  }>, import("redux").AnyAction>;
58
59
  export type AppState = ReturnType<typeof appReducer>;
59
60
  declare const store: import("@reduxjs/toolkit/dist/configureStore").ToolkitStore<import("redux").EmptyObject & {
@@ -111,6 +112,7 @@ declare const store: import("@reduxjs/toolkit/dist/configureStore").ToolkitStore
111
112
  posts: import("../slices").PostsSlice;
112
113
  sidebarModal: import("../slices").SidebarModalState;
113
114
  sidebar: import("../slices").SidebarState;
115
+ tags: import("../slices").TagsState;
114
116
  }, Action<any>, import("@reduxjs/toolkit").MiddlewareArray<[import("@reduxjs/toolkit").ThunkMiddleware<import("redux").CombinedState<{
115
117
  alerts: import("@open-tender/types").Alerts;
116
118
  notifications: import("@open-tender/types").Notifications;
@@ -166,6 +168,7 @@ declare const store: import("@reduxjs/toolkit/dist/configureStore").ToolkitStore
166
168
  posts: import("../slices").PostsSlice;
167
169
  sidebarModal: import("../slices").SidebarModalState;
168
170
  sidebar: import("../slices").SidebarState;
171
+ tags: import("../slices").TagsState;
169
172
  }>, import("redux").AnyAction, undefined>]>>;
170
173
  export type AppDispatch = typeof store.dispatch;
171
174
  export type RootState = ReturnType<typeof store.getState>;
@@ -1,5 +1,5 @@
1
1
  import { combineReducers, configureStore } from '@reduxjs/toolkit';
2
- import { alertsReducer, notificationsReducer, allergensReducer, announcementsReducer, customerReducer, signUpReducer, revenueCentersReducer, checkoutReducer, completedOrdersReducer, orderReducer, orderFulfillmentReducer, orderRatingReducer, dealsReducer, confirmationReducer, donationsReducer, guestReducer, verifyAccountReducer, menuReducer, resetPasswordReducer, validTimesReducer, menuItemsReducer, menuDisplayReducer, giftCardsReducer, groupOrderReducer, levelupReducer, configReducer, geolocationReducer, loaderReducer, qrReducer, miscReducer, modalReducer, navSiteReducer, navReducer, postsReducer, sidebarModalReducer, sidebarReducer } from '../slices';
2
+ import { alertsReducer, notificationsReducer, allergensReducer, announcementsReducer, customerReducer, signUpReducer, revenueCentersReducer, checkoutReducer, completedOrdersReducer, orderReducer, orderFulfillmentReducer, orderRatingReducer, dealsReducer, confirmationReducer, donationsReducer, guestReducer, verifyAccountReducer, menuReducer, resetPasswordReducer, validTimesReducer, menuItemsReducer, menuDisplayReducer, giftCardsReducer, groupOrderReducer, levelupReducer, configReducer, geolocationReducer, loaderReducer, qrReducer, miscReducer, modalReducer, navSiteReducer, navReducer, postsReducer, sidebarModalReducer, sidebarReducer, tagsReducer } from '../slices';
3
3
  import { ReducerType } from '../slices/types';
4
4
  export const appReducer = combineReducers({
5
5
  [ReducerType.Alerts]: alertsReducer,
@@ -37,7 +37,8 @@ export const appReducer = combineReducers({
37
37
  [ReducerType.Nav]: navReducer,
38
38
  [ReducerType.Posts]: postsReducer,
39
39
  [ReducerType.SidebarModal]: sidebarModalReducer,
40
- [ReducerType.Sidebar]: sidebarReducer
40
+ [ReducerType.Sidebar]: sidebarReducer,
41
+ [ReducerType.Tags]: tagsReducer
41
42
  });
42
43
  const rootReducer = (state, action) => {
43
44
  if (action.type === 'clearState') {
@@ -61,6 +61,7 @@ declare class OpenTenderAPI {
61
61
  getLocations(revenue_center_type: RevenueCenterType, is_outpost: boolean, lat: number, lng: number, requestedAt: string): Promise<unknown>;
62
62
  getLocation(revenue_center_id: number): Promise<unknown>;
63
63
  getValidTimes(revenueCenterType: RevenueCenterType): Promise<unknown>;
64
+ getTags(): Promise<unknown>;
64
65
  getAllergens(): Promise<unknown>;
65
66
  getMenu(revenueCenterId: number, serviceType: ServiceType, requestedAt: string): Promise<unknown>;
66
67
  getMenuItems(revenueCenterId: number, serviceType: ServiceType): Promise<unknown>;
@@ -334,6 +334,9 @@ class OpenTenderAPI {
334
334
  const params = `revenue_center_type=${revenueCenterType}`;
335
335
  return this.request(`/valid-times?${params}`);
336
336
  }
337
+ getTags() {
338
+ return this.request(`/tags?with_related=true`);
339
+ }
337
340
  getAllergens() {
338
341
  return this.request(`/allergens?with_related=true`);
339
342
  }
@@ -1,15 +1,20 @@
1
1
  import { AppState } from '../app';
2
- import { Allergens, RequestError, RequestStatus } from '@open-tender/types';
2
+ import { Allergens, AllergenLookupEnhanced, RequestError, RequestStatus } from '@open-tender/types';
3
3
  export interface AllergensState {
4
4
  entities: Allergens;
5
5
  error: RequestError;
6
6
  loading: RequestStatus;
7
7
  selectedAllergens: Allergens | null;
8
+ lookup: AllergenLookupEnhanced;
8
9
  }
9
10
  export declare enum AllergensActionType {
10
11
  FetchAllergens = "allergens/fetchAllergens"
11
12
  }
12
- export declare const fetchAllergens: import("@reduxjs/toolkit").AsyncThunk<Allergens, void, {
13
+ export interface AllergensPayload {
14
+ data: Allergens;
15
+ lookup: AllergenLookupEnhanced;
16
+ }
17
+ export declare const fetchAllergens: import("@reduxjs/toolkit").AsyncThunk<AllergensPayload, void, {
13
18
  state: AppState;
14
19
  rejectValue: RequestError;
15
20
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
@@ -21,5 +26,69 @@ export declare const fetchAllergens: import("@reduxjs/toolkit").AsyncThunk<Aller
21
26
  }>;
22
27
  export declare const resetAllergens: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"allergens/resetAllergens">, setSelectedAllergens: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "allergens/setSelectedAllergens">;
23
28
  export declare const selectAllergens: (state: AppState) => AllergensState;
24
- export declare const selectSelectedAllergenNames: (state: AppState) => string[];
29
+ export declare const selectSelectedAllergens: (state: AppState) => Allergens | null;
30
+ export declare const selectSelectedAllergenNames: ((state: import("redux").EmptyObject & {
31
+ alerts: import("@open-tender/types").Alerts;
32
+ notifications: import("@open-tender/types").Notifications;
33
+ allergens: AllergensState;
34
+ announcements: import("./announcements").AnnouncementsState;
35
+ customer: import("redux").CombinedState<{
36
+ account: import("./customer").AccountState;
37
+ allergens: import("./customer").CustomerAllergensState;
38
+ addresses: import("./customer").CustomerAddressesState;
39
+ communicationPreferences: import("./customer").CustomerCommunicationPrefsState;
40
+ creditCards: import("./customer").CustomerCreditCardsState;
41
+ favorites: import("./customer").CustomerFavoritesState;
42
+ fcmToken: import("./customer").CustomerFcmTokenState;
43
+ giftCards: import("./customer").CustomerGiftCardsState;
44
+ orders: import("./customer").CustomerOrdersState;
45
+ order: import("./customer").CustomerOrderState;
46
+ loyalty: import("./customer").CustomerLoyaltyState;
47
+ groupOrders: import("./customer").CustomerGroupOrdersState;
48
+ houseAccounts: import("./customer").CustomerHouseAccountsState;
49
+ rewards: import("./customer").CustomerRewardsState;
50
+ qrcode: import("./customer").CustomerQRCodeState;
51
+ thanx: import("./customer").CustomerThanxState;
52
+ levelup: import("./customer").CustomerLevelUpState;
53
+ }>;
54
+ signUp: import("./signUp").SignUpState;
55
+ revenueCenters: import("./revenueCenters").RevenueCentersState;
56
+ completedOrders: import("./completedOrders").CompletedOrdersState;
57
+ checkout: import("./checkout").CheckoutState;
58
+ order: import("./order").OrderState;
59
+ orderFulfillment: import("./orderFulfillment").OrderFulfillmentState;
60
+ orderRating: import("./orderRating").OrderRatingState;
61
+ deals: import("./deals").DealState;
62
+ confirmation: import("./confirmation").ConfirmationState;
63
+ donations: import("./donations").DonationState;
64
+ guest: import("./guest").GuestState;
65
+ verifyAccount: import("./verifyAccount").VerifyAccountState;
66
+ menu: import("./menu").MenuState;
67
+ resetPassword: import("./resetPassword").ResetPasswordState;
68
+ validTimes: import("./validTimes").ValidTimesState;
69
+ menuItems: import("./menuItems").MenuItemsState;
70
+ menuDisplay: import("./menuDisplay").MenuDisplayState;
71
+ giftCards: import("./giftCards").GiftCardsState;
72
+ groupOrder: import("./groupOrder").GroupOrderState;
73
+ levelup: import("./levelup").LevelupState;
74
+ config: import("./config").ConfigState;
75
+ geolocation: import("./geolocation").GeoLocationState;
76
+ loader: import("./loader").LoaderState;
77
+ qr: import("./qr").QrState;
78
+ misc: import("./misc").MiscState;
79
+ modal: import("@open-tender/types").Modal;
80
+ navSite: import("./navSite").NavSiteState;
81
+ nav: import("./nav").NavState;
82
+ posts: import("./posts").PostsSlice;
83
+ sidebarModal: import("./sidebarModal").SidebarModalState;
84
+ sidebar: import("./sidebar").SidebarState;
85
+ tags: import("./tags").TagsState;
86
+ }) => string[]) & import("reselect").OutputSelectorFields<(args_0: {
87
+ allergens: Allergens;
88
+ selectedAllergens: Allergens | null;
89
+ }) => string[], {
90
+ clearCache: () => void;
91
+ }> & {
92
+ clearCache: () => void;
93
+ };
25
94
  export declare const allergensReducer: import("redux").Reducer<AllergensState, import("redux").AnyAction>;
@@ -1,11 +1,21 @@
1
1
  import { __awaiter } from "tslib";
2
- import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
2
+ import { createAsyncThunk, createSelector, createSlice } from '@reduxjs/toolkit';
3
3
  import { ReducerType } from './types';
4
+ import { makeImageMap } from '@open-tender/utils';
5
+ const makeAllergenLookup = (data) => {
6
+ return data.reduce((obj, i) => {
7
+ const imageMap = makeImageMap(i.images);
8
+ const imageUrl = imageMap.SMALL_IMAGE || imageMap.APP_IMAGE || imageMap.LARGE_IMAGE || '';
9
+ const tag = Object.assign(Object.assign({}, i), { imageUrl });
10
+ return Object.assign(Object.assign({}, obj), { [i.name]: tag });
11
+ }, {});
12
+ };
4
13
  const initialState = {
5
14
  entities: [],
6
15
  error: null,
7
16
  loading: 'idle',
8
- selectedAllergens: null
17
+ selectedAllergens: null,
18
+ lookup: {}
9
19
  };
10
20
  export var AllergensActionType;
11
21
  (function (AllergensActionType) {
@@ -15,7 +25,8 @@ export const fetchAllergens = createAsyncThunk(AllergensActionType.FetchAllergen
15
25
  try {
16
26
  const api = getState().config.api;
17
27
  const { data } = yield api.getAllergens();
18
- return data;
28
+ const lookup = makeAllergenLookup(data);
29
+ return { data, lookup };
19
30
  }
20
31
  catch (err) {
21
32
  return rejectWithValue(err);
@@ -33,7 +44,8 @@ const allergensSlice = createSlice({
33
44
  extraReducers: builder => {
34
45
  builder
35
46
  .addCase(fetchAllergens.fulfilled, (state, action) => {
36
- state.entities = action.payload;
47
+ state.entities = action.payload.data;
48
+ state.lookup = action.payload.lookup;
37
49
  state.loading = 'idle';
38
50
  state.error = null;
39
51
  })
@@ -48,15 +60,28 @@ const allergensSlice = createSlice({
48
60
  });
49
61
  export const { resetAllergens, setSelectedAllergens } = allergensSlice.actions;
50
62
  export const selectAllergens = (state) => state.allergens;
51
- export const selectSelectedAllergenNames = (state) => {
63
+ export const selectSelectedAllergens = (state) => state.allergens.selectedAllergens;
64
+ // export const selectSelectedAllergenNames = (state: AppState) => {
65
+ // const { entities: allergens, selectedAllergens } = state.allergens
66
+ // if (!allergens.length || !selectedAllergens || !selectedAllergens.length) {
67
+ // return []
68
+ // }
69
+ // return selectedAllergens.map(i => {
70
+ // const allergen = allergens.find(a => a.allergen_id === i.allergen_id)
71
+ // return allergen ? allergen.name ?? '' : ''
72
+ // })
73
+ // }
74
+ export const selectSelectedAllergenNames = createSelector((state) => {
52
75
  const { entities: allergens, selectedAllergens } = state.allergens;
53
- if (!allergens.length || !selectedAllergens || !selectedAllergens.length) {
76
+ return { allergens, selectedAllergens };
77
+ }, ({ allergens, selectedAllergens }) => {
78
+ if (!selectedAllergens)
54
79
  return [];
55
- }
56
- return selectedAllergens.map(i => {
80
+ const selected = selectedAllergens.map(i => {
57
81
  var _a;
58
82
  const allergen = allergens.find(a => a.allergen_id === i.allergen_id);
59
83
  return allergen ? (_a = allergen.name) !== null && _a !== void 0 ? _a : '' : '';
60
84
  });
61
- };
85
+ return selected;
86
+ });
62
87
  export const allergensReducer = allergensSlice.reducer;
@@ -19,8 +19,7 @@ export const fetchDeals = createAsyncThunk(DealActionType.FetchDeals, (_, { getS
19
19
  try {
20
20
  const { profile } = getState().customer.account;
21
21
  const { customer_id = null } = profile || {};
22
- const deals = yield api.getDeals(customer_id);
23
- return deals;
22
+ return yield api.getDeals(customer_id);
24
23
  }
25
24
  catch (err) {
26
25
  return rejectWithValue(err);
@@ -32,5 +32,6 @@ export * from './revenueCenters';
32
32
  export * from './sidebar';
33
33
  export * from './sidebarModal';
34
34
  export * from './signUp';
35
+ export * from './tags';
35
36
  export * from './validTimes';
36
37
  export * from './verifyAccount';
@@ -32,5 +32,6 @@ export * from './revenueCenters';
32
32
  export * from './sidebar';
33
33
  export * from './sidebarModal';
34
34
  export * from './signUp';
35
+ export * from './tags';
35
36
  export * from './validTimes';
36
37
  export * from './verifyAccount';
@@ -0,0 +1,94 @@
1
+ import { AppState } from '../app';
2
+ import { TagLookupEnhanced, Tags, RequestError, RequestStatus } from '@open-tender/types';
3
+ export interface TagsState {
4
+ entities: Tags;
5
+ error: RequestError;
6
+ loading: RequestStatus;
7
+ selectedTags: Tags | null;
8
+ lookup: TagLookupEnhanced | null;
9
+ }
10
+ export declare enum TagsActionType {
11
+ FetchTags = "tags/fetchTags"
12
+ }
13
+ export interface TagsPayload {
14
+ data: Tags;
15
+ lookup: TagLookupEnhanced;
16
+ }
17
+ export declare const fetchTags: import("@reduxjs/toolkit").AsyncThunk<TagsPayload, void, {
18
+ state: AppState;
19
+ rejectValue: RequestError;
20
+ dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
21
+ extra?: unknown;
22
+ serializedErrorType?: unknown;
23
+ pendingMeta?: unknown;
24
+ fulfilledMeta?: unknown;
25
+ rejectedMeta?: unknown;
26
+ }>;
27
+ export declare const resetTags: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"tags/resetTags">, setSelectedTags: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "tags/setSelectedTags">;
28
+ export declare const selectTags: (state: AppState) => TagsState;
29
+ export declare const selectSelectedTags: (state: AppState) => Tags | null;
30
+ export declare const selectSelectedTagNames: ((state: import("redux").EmptyObject & {
31
+ alerts: import("@open-tender/types").Alerts;
32
+ notifications: import("@open-tender/types").Notifications;
33
+ allergens: import("./allergens").AllergensState;
34
+ announcements: import("./announcements").AnnouncementsState;
35
+ customer: import("redux").CombinedState<{
36
+ account: import("./customer").AccountState;
37
+ allergens: import("./customer").CustomerAllergensState;
38
+ addresses: import("./customer").CustomerAddressesState;
39
+ communicationPreferences: import("./customer").CustomerCommunicationPrefsState;
40
+ creditCards: import("./customer").CustomerCreditCardsState;
41
+ favorites: import("./customer").CustomerFavoritesState;
42
+ fcmToken: import("./customer").CustomerFcmTokenState;
43
+ giftCards: import("./customer").CustomerGiftCardsState;
44
+ orders: import("./customer").CustomerOrdersState;
45
+ order: import("./customer").CustomerOrderState;
46
+ loyalty: import("./customer").CustomerLoyaltyState;
47
+ groupOrders: import("./customer").CustomerGroupOrdersState;
48
+ houseAccounts: import("./customer").CustomerHouseAccountsState;
49
+ rewards: import("./customer").CustomerRewardsState;
50
+ qrcode: import("./customer").CustomerQRCodeState;
51
+ thanx: import("./customer").CustomerThanxState;
52
+ levelup: import("./customer").CustomerLevelUpState;
53
+ }>;
54
+ signUp: import("./signUp").SignUpState;
55
+ revenueCenters: import("./revenueCenters").RevenueCentersState;
56
+ completedOrders: import("./completedOrders").CompletedOrdersState;
57
+ checkout: import("./checkout").CheckoutState;
58
+ order: import("./order").OrderState;
59
+ orderFulfillment: import("./orderFulfillment").OrderFulfillmentState;
60
+ orderRating: import("./orderRating").OrderRatingState;
61
+ deals: import("./deals").DealState;
62
+ confirmation: import("./confirmation").ConfirmationState;
63
+ donations: import("./donations").DonationState;
64
+ guest: import("./guest").GuestState;
65
+ verifyAccount: import("./verifyAccount").VerifyAccountState;
66
+ menu: import("./menu").MenuState;
67
+ resetPassword: import("./resetPassword").ResetPasswordState;
68
+ validTimes: import("./validTimes").ValidTimesState;
69
+ menuItems: import("./menuItems").MenuItemsState;
70
+ menuDisplay: import("./menuDisplay").MenuDisplayState;
71
+ giftCards: import("./giftCards").GiftCardsState;
72
+ groupOrder: import("./groupOrder").GroupOrderState;
73
+ levelup: import("./levelup").LevelupState;
74
+ config: import("./config").ConfigState;
75
+ geolocation: import("./geolocation").GeoLocationState;
76
+ loader: import("./loader").LoaderState;
77
+ qr: import("./qr").QrState;
78
+ misc: import("./misc").MiscState;
79
+ modal: import("@open-tender/types").Modal;
80
+ navSite: import("./navSite").NavSiteState;
81
+ nav: import("./nav").NavState;
82
+ posts: import("./posts").PostsSlice;
83
+ sidebarModal: import("./sidebarModal").SidebarModalState;
84
+ sidebar: import("./sidebar").SidebarState;
85
+ tags: TagsState;
86
+ }) => string[]) & import("reselect").OutputSelectorFields<(args_0: {
87
+ tags: Tags;
88
+ selectedTags: Tags | null;
89
+ }) => string[], {
90
+ clearCache: () => void;
91
+ }> & {
92
+ clearCache: () => void;
93
+ };
94
+ export declare const tagsReducer: import("redux").Reducer<TagsState, import("redux").AnyAction>;
@@ -0,0 +1,77 @@
1
+ import { __awaiter } from "tslib";
2
+ import { createAsyncThunk, createSelector, createSlice } from '@reduxjs/toolkit';
3
+ import { ReducerType } from './types';
4
+ import { makeImageMap } from '@open-tender/utils';
5
+ const makeTagLookup = (data) => {
6
+ return data.reduce((obj, i) => {
7
+ const imageMap = makeImageMap(i.images);
8
+ const imageUrl = imageMap.SMALL_IMAGE || imageMap.APP_IMAGE || imageMap.LARGE_IMAGE || '';
9
+ const tag = Object.assign(Object.assign({}, i), { imageUrl });
10
+ return Object.assign(Object.assign({}, obj), { [i.name]: tag });
11
+ }, {});
12
+ };
13
+ const initialState = {
14
+ entities: [],
15
+ error: null,
16
+ loading: 'idle',
17
+ selectedTags: null,
18
+ lookup: {}
19
+ };
20
+ export var TagsActionType;
21
+ (function (TagsActionType) {
22
+ TagsActionType["FetchTags"] = "tags/fetchTags";
23
+ })(TagsActionType || (TagsActionType = {}));
24
+ export const fetchTags = createAsyncThunk(TagsActionType.FetchTags, (_, { getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
25
+ try {
26
+ const api = getState().config.api;
27
+ const { data } = yield api.getTags();
28
+ const lookup = makeTagLookup(data);
29
+ return { data, lookup };
30
+ }
31
+ catch (err) {
32
+ return rejectWithValue(err);
33
+ }
34
+ }));
35
+ const tagsSlice = createSlice({
36
+ name: ReducerType.Tags,
37
+ initialState,
38
+ reducers: {
39
+ resetTags: () => initialState,
40
+ setSelectedTags: (state, action) => {
41
+ state.selectedTags = action.payload;
42
+ }
43
+ },
44
+ extraReducers: builder => {
45
+ builder
46
+ .addCase(fetchTags.fulfilled, (state, action) => {
47
+ state.entities = action.payload.data;
48
+ state.lookup = action.payload.lookup;
49
+ state.loading = 'idle';
50
+ state.error = null;
51
+ })
52
+ .addCase(fetchTags.pending, state => {
53
+ state.loading = 'pending';
54
+ })
55
+ .addCase(fetchTags.rejected, (state, action) => {
56
+ state.error = action.payload;
57
+ state.loading = 'idle';
58
+ });
59
+ }
60
+ });
61
+ export const { resetTags, setSelectedTags } = tagsSlice.actions;
62
+ export const selectTags = (state) => state.tags;
63
+ export const selectSelectedTags = (state) => state.tags.selectedTags;
64
+ export const selectSelectedTagNames = createSelector((state) => {
65
+ const { entities: tags, selectedTags } = state.tags;
66
+ return { tags, selectedTags };
67
+ }, ({ tags, selectedTags }) => {
68
+ if (!selectedTags)
69
+ return [];
70
+ const selected = selectedTags.map(i => {
71
+ var _a;
72
+ const allergen = tags.find(a => a.allergen_id === i.allergen_id);
73
+ return allergen ? (_a = allergen.name) !== null && _a !== void 0 ? _a : '' : '';
74
+ });
75
+ return selected;
76
+ });
77
+ export const tagsReducer = tagsSlice.reducer;
@@ -1,53 +1,54 @@
1
1
  export declare enum ReducerType {
2
+ Account = "account",
2
3
  Alerts = "alerts",
3
- Notifications = "notifications",
4
4
  Allergens = "allergens",
5
5
  Announcements = "announcements",
6
- Settings = "settings",
7
- Customer = "customer",
8
- SignUp = "signUp",
9
- Account = "account",
10
- CustomerAllergens = "allergens",
11
- CustomerAddresses = "addresses",
6
+ Checkout = "checkout",
12
7
  CommunicationPrefs = "communicationPreferences",
8
+ Config = "config",
9
+ Confirmation = "confirmation",
10
+ CompletedOrders = "completedOrders",
13
11
  CreditCards = "creditCards",
12
+ Customer = "customer",
13
+ CustomerAddresses = "addresses",
14
+ CustomerAllergens = "allergens",
15
+ Deals = "deals",
16
+ Donations = "donations",
14
17
  Favorites = "favorites",
15
18
  FcmToken = "fcmToken",
19
+ Geolocation = "geolocation",
16
20
  GiftCards = "giftCards",
21
+ GroupOrder = "groupOrder",
17
22
  GroupOrders = "groupOrders",
23
+ Guest = "guest",
18
24
  HouseAccounts = "houseAccounts",
19
25
  Levelup = "levelup",
26
+ Loader = "loader",
20
27
  Loyalty = "loyalty",
21
- Order = "order",
22
- Orders = "orders",
23
- QRCode = "qrcode",
24
- Rewards = "rewards",
25
- Thanx = "thanx",
26
- RevenueCenters = "revenueCenters",
27
- CompletedOrders = "completedOrders",
28
- Checkout = "checkout",
29
- OrderFulfillment = "orderFulfillment",
30
- OrderRating = "orderRating",
31
- Deals = "deals",
32
- Confirmation = "confirmation",
33
- Donations = "donations",
34
- Guest = "guest",
35
- VerifyAccount = "verifyAccount",
36
28
  Menu = "menu",
37
- ResetPassword = "resetPassword",
38
- ValidTimes = "validTimes",
39
- MenuItems = "menuItems",
40
29
  MenuDisplay = "menuDisplay",
41
- GroupOrder = "groupOrder",
42
- Config = "config",
43
- Geolocation = "geolocation",
44
- Loader = "loader",
30
+ MenuItems = "menuItems",
45
31
  Misc = "misc",
46
- Qr = "qr",
47
32
  Modal = "modal",
48
- NavSite = "navSite",
49
33
  Nav = "nav",
34
+ NavSite = "navSite",
35
+ Notifications = "notifications",
36
+ Order = "order",
37
+ OrderFulfillment = "orderFulfillment",
38
+ OrderRating = "orderRating",
39
+ Orders = "orders",
50
40
  Posts = "posts",
41
+ Qr = "qr",
42
+ QRCode = "qrcode",
43
+ ResetPassword = "resetPassword",
44
+ RevenueCenters = "revenueCenters",
45
+ Rewards = "rewards",
46
+ Settings = "settings",
47
+ Sidebar = "sidebar",
51
48
  SidebarModal = "sidebarModal",
52
- Sidebar = "sidebar"
49
+ SignUp = "signUp",
50
+ Tags = "tags",
51
+ Thanx = "thanx",
52
+ ValidTimes = "validTimes",
53
+ VerifyAccount = "verifyAccount"
53
54
  }
@@ -1,54 +1,55 @@
1
1
  export var ReducerType;
2
2
  (function (ReducerType) {
3
+ ReducerType["Account"] = "account";
3
4
  ReducerType["Alerts"] = "alerts";
4
- ReducerType["Notifications"] = "notifications";
5
5
  ReducerType["Allergens"] = "allergens";
6
6
  ReducerType["Announcements"] = "announcements";
7
- ReducerType["Settings"] = "settings";
8
- ReducerType["Customer"] = "customer";
9
- ReducerType["SignUp"] = "signUp";
10
- ReducerType["Account"] = "account";
11
- ReducerType["CustomerAllergens"] = "allergens";
12
- ReducerType["CustomerAddresses"] = "addresses";
7
+ ReducerType["Checkout"] = "checkout";
13
8
  ReducerType["CommunicationPrefs"] = "communicationPreferences";
9
+ ReducerType["Config"] = "config";
10
+ ReducerType["Confirmation"] = "confirmation";
11
+ ReducerType["CompletedOrders"] = "completedOrders";
14
12
  ReducerType["CreditCards"] = "creditCards";
13
+ ReducerType["Customer"] = "customer";
14
+ ReducerType["CustomerAddresses"] = "addresses";
15
+ ReducerType["CustomerAllergens"] = "allergens";
16
+ ReducerType["Deals"] = "deals";
17
+ ReducerType["Donations"] = "donations";
15
18
  ReducerType["Favorites"] = "favorites";
16
19
  ReducerType["FcmToken"] = "fcmToken";
20
+ ReducerType["Geolocation"] = "geolocation";
17
21
  ReducerType["GiftCards"] = "giftCards";
22
+ ReducerType["GroupOrder"] = "groupOrder";
18
23
  ReducerType["GroupOrders"] = "groupOrders";
24
+ ReducerType["Guest"] = "guest";
19
25
  ReducerType["HouseAccounts"] = "houseAccounts";
20
26
  ReducerType["Levelup"] = "levelup";
27
+ ReducerType["Loader"] = "loader";
21
28
  ReducerType["Loyalty"] = "loyalty";
22
- ReducerType["Order"] = "order";
23
- ReducerType["Orders"] = "orders";
24
- ReducerType["QRCode"] = "qrcode";
25
- ReducerType["Rewards"] = "rewards";
26
- ReducerType["Thanx"] = "thanx";
27
- ReducerType["RevenueCenters"] = "revenueCenters";
28
- ReducerType["CompletedOrders"] = "completedOrders";
29
- ReducerType["Checkout"] = "checkout";
30
- ReducerType["OrderFulfillment"] = "orderFulfillment";
31
- ReducerType["OrderRating"] = "orderRating";
32
- ReducerType["Deals"] = "deals";
33
- ReducerType["Confirmation"] = "confirmation";
34
- ReducerType["Donations"] = "donations";
35
- ReducerType["Guest"] = "guest";
36
- ReducerType["VerifyAccount"] = "verifyAccount";
37
29
  ReducerType["Menu"] = "menu";
38
- ReducerType["ResetPassword"] = "resetPassword";
39
- ReducerType["ValidTimes"] = "validTimes";
40
- ReducerType["MenuItems"] = "menuItems";
41
30
  ReducerType["MenuDisplay"] = "menuDisplay";
42
- ReducerType["GroupOrder"] = "groupOrder";
43
- ReducerType["Config"] = "config";
44
- ReducerType["Geolocation"] = "geolocation";
45
- ReducerType["Loader"] = "loader";
31
+ ReducerType["MenuItems"] = "menuItems";
46
32
  ReducerType["Misc"] = "misc";
47
- ReducerType["Qr"] = "qr";
48
33
  ReducerType["Modal"] = "modal";
49
- ReducerType["NavSite"] = "navSite";
50
34
  ReducerType["Nav"] = "nav";
35
+ ReducerType["NavSite"] = "navSite";
36
+ ReducerType["Notifications"] = "notifications";
37
+ ReducerType["Order"] = "order";
38
+ ReducerType["OrderFulfillment"] = "orderFulfillment";
39
+ ReducerType["OrderRating"] = "orderRating";
40
+ ReducerType["Orders"] = "orders";
51
41
  ReducerType["Posts"] = "posts";
52
- ReducerType["SidebarModal"] = "sidebarModal";
42
+ ReducerType["Qr"] = "qr";
43
+ ReducerType["QRCode"] = "qrcode";
44
+ ReducerType["ResetPassword"] = "resetPassword";
45
+ ReducerType["RevenueCenters"] = "revenueCenters";
46
+ ReducerType["Rewards"] = "rewards";
47
+ ReducerType["Settings"] = "settings";
53
48
  ReducerType["Sidebar"] = "sidebar";
49
+ ReducerType["SidebarModal"] = "sidebarModal";
50
+ ReducerType["SignUp"] = "signUp";
51
+ ReducerType["Tags"] = "tags";
52
+ ReducerType["Thanx"] = "thanx";
53
+ ReducerType["ValidTimes"] = "validTimes";
54
+ ReducerType["VerifyAccount"] = "verifyAccount";
54
55
  })(ReducerType || (ReducerType = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/cloud",
3
- "version": "0.1.39",
3
+ "version": "0.1.41",
4
4
  "description": "A library of hooks, reducers, utility functions, and types for use with Open Tender applications that utilize our cloud-based Order API.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -49,8 +49,8 @@
49
49
  "typescript": "^4.8.2"
50
50
  },
51
51
  "peerDependencies": {
52
- "@open-tender/types": "^0.2.23",
53
- "@open-tender/utils": "^0.1.90",
52
+ "@open-tender/types": "^0.2.38",
53
+ "@open-tender/utils": "^0.1.95",
54
54
  "@reduxjs/toolkit": "^1.8.5",
55
55
  "react": "^18.2.0"
56
56
  },