@open-tender/store 1.1.170 → 1.1.172
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/cjs/app/hooks.d.ts +1 -0
- package/dist/cjs/app/store.d.ts +4 -0
- package/dist/cjs/app/store.js +2 -1
- package/dist/cjs/components/Switch.d.ts +15 -0
- package/dist/cjs/components/Switch.js +23 -0
- package/dist/cjs/components/TagsFilter.d.ts +15 -0
- package/dist/cjs/components/TagsFilter.js +47 -0
- package/dist/cjs/services/api.d.ts +2 -1
- package/dist/cjs/services/api.js +3 -0
- package/dist/cjs/slices/customer.d.ts +1 -0
- package/dist/cjs/slices/index.d.ts +1 -0
- package/dist/cjs/slices/index.js +1 -0
- package/dist/cjs/slices/kiosk.d.ts +7 -0
- package/dist/cjs/slices/menuPages.d.ts +1 -0
- package/dist/cjs/slices/order.d.ts +4 -0
- package/dist/cjs/slices/tags.d.ts +84 -0
- package/dist/cjs/slices/tags.js +81 -0
- package/dist/cjs/slices/types.d.ts +2 -1
- package/dist/cjs/slices/types.js +1 -0
- package/dist/esm/app/hooks.d.ts +1 -0
- package/dist/esm/app/store.d.ts +4 -0
- package/dist/esm/app/store.js +3 -2
- package/dist/esm/components/Switch.d.ts +15 -0
- package/dist/esm/components/Switch.js +21 -0
- package/dist/esm/components/TagsFilter.d.ts +15 -0
- package/dist/esm/components/TagsFilter.js +45 -0
- package/dist/esm/services/api.d.ts +2 -1
- package/dist/esm/services/api.js +3 -0
- package/dist/esm/slices/customer.d.ts +1 -0
- package/dist/esm/slices/index.d.ts +1 -0
- package/dist/esm/slices/index.js +1 -0
- package/dist/esm/slices/kiosk.d.ts +7 -0
- package/dist/esm/slices/menuPages.d.ts +1 -0
- package/dist/esm/slices/order.d.ts +4 -0
- package/dist/esm/slices/tags.d.ts +84 -0
- package/dist/esm/slices/tags.js +76 -0
- package/dist/esm/slices/types.d.ts +2 -1
- package/dist/esm/slices/types.js +1 -0
- package/package.json +2 -2
package/dist/cjs/app/hooks.d.ts
CHANGED
|
@@ -28,5 +28,6 @@ export declare const useAppDispatch: () => import("redux-thunk").ThunkDispatch<{
|
|
|
28
28
|
surcharges: import("..").SurchargesState;
|
|
29
29
|
taxes: import("..").TaxesState;
|
|
30
30
|
idle: import("..").IdleState;
|
|
31
|
+
tags: import("..").TagsState;
|
|
31
32
|
}, undefined, import("redux").UnknownAction> & import("redux").Dispatch<import("redux").Action>;
|
|
32
33
|
export declare const useAppSelector: TypedUseSelectorHook<RootState>;
|
package/dist/cjs/app/store.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export declare const appReducer: import("redux").Reducer<{
|
|
|
27
27
|
surcharges: import("../slices").SurchargesState;
|
|
28
28
|
taxes: import("../slices").TaxesState;
|
|
29
29
|
idle: import("../slices").IdleState;
|
|
30
|
+
tags: import("../slices").TagsState;
|
|
30
31
|
}, import("redux").UnknownAction, Partial<{
|
|
31
32
|
alerts: import("@open-tender/types").Alerts | undefined;
|
|
32
33
|
arrivals: import("../slices").ArrivalsState | undefined;
|
|
@@ -55,6 +56,7 @@ export declare const appReducer: import("redux").Reducer<{
|
|
|
55
56
|
surcharges: import("../slices").SurchargesState | undefined;
|
|
56
57
|
taxes: import("../slices").TaxesState | undefined;
|
|
57
58
|
idle: import("../slices").IdleState | undefined;
|
|
59
|
+
tags: import("../slices").TagsState | undefined;
|
|
58
60
|
}>>;
|
|
59
61
|
export type AppState = ReturnType<typeof appReducer>;
|
|
60
62
|
declare const store: import("@reduxjs/toolkit").EnhancedStore<{
|
|
@@ -85,6 +87,7 @@ declare const store: import("@reduxjs/toolkit").EnhancedStore<{
|
|
|
85
87
|
surcharges: import("../slices").SurchargesState;
|
|
86
88
|
taxes: import("../slices").TaxesState;
|
|
87
89
|
idle: import("../slices").IdleState;
|
|
90
|
+
tags: import("../slices").TagsState;
|
|
88
91
|
}, Action, import("@reduxjs/toolkit").Tuple<[import("redux").StoreEnhancer<{
|
|
89
92
|
dispatch: import("redux-thunk").ThunkDispatch<{
|
|
90
93
|
alerts: import("@open-tender/types").Alerts;
|
|
@@ -114,6 +117,7 @@ declare const store: import("@reduxjs/toolkit").EnhancedStore<{
|
|
|
114
117
|
surcharges: import("../slices").SurchargesState;
|
|
115
118
|
taxes: import("../slices").TaxesState;
|
|
116
119
|
idle: import("../slices").IdleState;
|
|
120
|
+
tags: import("../slices").TagsState;
|
|
117
121
|
}, undefined, import("redux").UnknownAction>;
|
|
118
122
|
}>, import("redux").StoreEnhancer]>>;
|
|
119
123
|
export type AppDispatch = typeof store.dispatch;
|
package/dist/cjs/app/store.js
CHANGED
|
@@ -30,7 +30,8 @@ exports.appReducer = (0, toolkit_1.combineReducers)({
|
|
|
30
30
|
sidebar: slices_1.sidebarReducer,
|
|
31
31
|
surcharges: slices_1.surchargesReducer,
|
|
32
32
|
taxes: slices_1.taxesReducer,
|
|
33
|
-
idle: slices_1.idleReducer
|
|
33
|
+
idle: slices_1.idleReducer,
|
|
34
|
+
tags: slices_1.tagsReducer
|
|
34
35
|
});
|
|
35
36
|
var rootReducer = function (state, action) {
|
|
36
37
|
if (action.type === 'clearState') {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SwitchProps } from '@open-tender/ui';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
declare const Switch: ({ id, label, on, isRequired, disabled, falseTrackColor, thumbColor, trueTrackColor, onChange, children }: {
|
|
4
|
+
id: number | string;
|
|
5
|
+
label: string;
|
|
6
|
+
on: boolean;
|
|
7
|
+
falseTrackColor?: string;
|
|
8
|
+
trueTrackColor?: string;
|
|
9
|
+
thumbColor?: string;
|
|
10
|
+
isRequired: boolean;
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
onChange: (value: boolean) => void;
|
|
13
|
+
children: (props: SwitchProps) => ReactNode;
|
|
14
|
+
}) => ReactNode;
|
|
15
|
+
export default Switch;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var hooks_1 = require("../app/hooks");
|
|
4
|
+
var slices_1 = require("../slices");
|
|
5
|
+
var Switch = function (_a) {
|
|
6
|
+
var id = _a.id, label = _a.label, on = _a.on, isRequired = _a.isRequired, disabled = _a.disabled, falseTrackColor = _a.falseTrackColor, thumbColor = _a.thumbColor, trueTrackColor = _a.trueTrackColor, onChange = _a.onChange, children = _a.children;
|
|
7
|
+
var config = (0, hooks_1.useAppSelector)(slices_1.selectKioskConfig).switch;
|
|
8
|
+
if (!config)
|
|
9
|
+
return null;
|
|
10
|
+
return children({
|
|
11
|
+
id: id,
|
|
12
|
+
config: config,
|
|
13
|
+
label: label,
|
|
14
|
+
value: on,
|
|
15
|
+
onTagSwitch: onChange,
|
|
16
|
+
isRequired: isRequired,
|
|
17
|
+
disabled: disabled,
|
|
18
|
+
falseTrackColor: falseTrackColor,
|
|
19
|
+
thumbColor: thumbColor,
|
|
20
|
+
trueTrackColor: trueTrackColor
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
exports.default = Switch;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Tags } from '@open-tender/types';
|
|
2
|
+
import { Handlers, ScreenConfig, SwitchProps } from '@open-tender/ui';
|
|
3
|
+
import React, { ReactNode } from 'react';
|
|
4
|
+
declare const TagsFilter: ({ children, SwitchView }: {
|
|
5
|
+
children: (props: {
|
|
6
|
+
config: ScreenConfig;
|
|
7
|
+
tags: Tags;
|
|
8
|
+
renderSwitch: (props: SwitchProps) => ReactNode;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
error?: string;
|
|
11
|
+
handlers: Handlers;
|
|
12
|
+
}) => ReactNode;
|
|
13
|
+
SwitchView: (props: SwitchProps) => ReactNode;
|
|
14
|
+
}) => React.ReactNode;
|
|
15
|
+
export default TagsFilter;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
+
var hooks_1 = require("../app/hooks");
|
|
6
|
+
var slices_1 = require("../slices");
|
|
7
|
+
var Switch_1 = tslib_1.__importDefault(require("./Switch"));
|
|
8
|
+
var TagsFilter = function (_a) {
|
|
9
|
+
var children = _a.children, SwitchView = _a.SwitchView;
|
|
10
|
+
var config = (0, hooks_1.useAppSelector)(slices_1.selectKioskConfig).tags;
|
|
11
|
+
var dispatch = (0, hooks_1.useAppDispatch)();
|
|
12
|
+
var _b = (0, hooks_1.useAppSelector)(slices_1.selectTags), tags = _b.entities, selectedTags = _b.selectedTags, loading = _b.loading, error = _b.error;
|
|
13
|
+
var _c = (0, react_1.useState)([]), localSelectedTags = _c[0], setLocalSelectedTags = _c[1];
|
|
14
|
+
var isLoading = loading === 'pending';
|
|
15
|
+
(0, react_1.useEffect)(function () {
|
|
16
|
+
setLocalSelectedTags(selectedTags.map(function (tag) { return tag.tag_id; }));
|
|
17
|
+
}, [selectedTags]);
|
|
18
|
+
var onTagSwitch = function (tag) {
|
|
19
|
+
setLocalSelectedTags(function (prevSelectedTags) {
|
|
20
|
+
if (prevSelectedTags.includes(tag.tag_id)) {
|
|
21
|
+
return prevSelectedTags.filter(function (id) { return id !== tag.tag_id; });
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return tslib_1.__spreadArray(tslib_1.__spreadArray([], prevSelectedTags, true), [tag.tag_id], false);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
var handleSubmit = function () {
|
|
29
|
+
var newSelectedTags = tags.filter(function (tag) {
|
|
30
|
+
return localSelectedTags.includes(tag.tag_id);
|
|
31
|
+
});
|
|
32
|
+
dispatch((0, slices_1.setSelectedTags)(newSelectedTags));
|
|
33
|
+
};
|
|
34
|
+
var handlers = { onTagSwitch: onTagSwitch, handleSubmit: handleSubmit };
|
|
35
|
+
var renderSwitch = (0, react_1.useCallback)(function (props) {
|
|
36
|
+
return (react_1.default.createElement(Switch_1.default, { key: props.id, id: props.id, children: SwitchView, label: props.label, on: props.value, onChange: props.onTagSwitch, disabled: false, isRequired: true }));
|
|
37
|
+
}, [SwitchView]);
|
|
38
|
+
return children({
|
|
39
|
+
config: config,
|
|
40
|
+
handlers: handlers,
|
|
41
|
+
isLoading: isLoading,
|
|
42
|
+
renderSwitch: renderSwitch,
|
|
43
|
+
tags: tags,
|
|
44
|
+
error: error === null || error === void 0 ? void 0 : error.detail
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
exports.default = TagsFilter;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Arrivals, CheckoutTender, CustomerEndpoints, CustomerIdentifier, CustomerIdentify, Discount, Discounts, ItemTypes, Menu, Order, Orders, OrderCreatePos, OrderTender, OrderUpdate, OrderType, RequestedAt, RevenueCenter, SelectOptions, ServiceType, TicketUpdate, TicketsUpdate, TicketStatusUpdate, EntityType, KioskConfig, Store, Settings, InternalSettings, GiftCardCredit, GiftCardBalance, Employee, Punch, Employees, CashEvent, CashSummary, ErrorAlerts, ErrorAlert, OfflineAuths, OfflineAuthsResult, MenuColors, MenuPages, Surcharges, Taxes, CheckoutTenderPos, Refund, DeviceRead, OrderCreateSendReceipt } from '@open-tender/types';
|
|
1
|
+
import { Arrivals, CheckoutTender, CustomerEndpoints, CustomerIdentifier, CustomerIdentify, Discount, Discounts, ItemTypes, Menu, Order, Orders, OrderCreatePos, OrderTender, OrderUpdate, OrderType, RequestedAt, RevenueCenter, SelectOptions, ServiceType, TicketUpdate, TicketsUpdate, TicketStatusUpdate, EntityType, KioskConfig, Store, Settings, InternalSettings, GiftCardCredit, GiftCardBalance, Employee, Punch, Employees, CashEvent, CashSummary, ErrorAlerts, ErrorAlert, OfflineAuths, OfflineAuthsResult, MenuColors, MenuPages, Surcharges, Taxes, CheckoutTenderPos, Refund, DeviceRead, OrderCreateSendReceipt, Tags } from '@open-tender/types';
|
|
2
2
|
import { OrdersParams } from '../slices';
|
|
3
3
|
export interface InitAPI {
|
|
4
4
|
apiUrl: string;
|
|
@@ -79,5 +79,6 @@ declare class PosAPI {
|
|
|
79
79
|
postAcknowledgeArrival(orderId: string): Promise<Order>;
|
|
80
80
|
postRefundValidate(orderId: string, refund: Refund): Promise<Order>;
|
|
81
81
|
postRefund(orderId: string, refund: Refund): Promise<Order>;
|
|
82
|
+
getTags(): Promise<Tags>;
|
|
82
83
|
}
|
|
83
84
|
export default PosAPI;
|
package/dist/cjs/services/api.js
CHANGED
|
@@ -372,6 +372,9 @@ var PosAPI = /** @class */ (function () {
|
|
|
372
372
|
PosAPI.prototype.postRefund = function (orderId, refund) {
|
|
373
373
|
return this.request("/orders/".concat(orderId, "/refund"), 'POST', refund);
|
|
374
374
|
};
|
|
375
|
+
PosAPI.prototype.getTags = function () {
|
|
376
|
+
return this.request("/tags");
|
|
377
|
+
};
|
|
375
378
|
return PosAPI;
|
|
376
379
|
}());
|
|
377
380
|
exports.default = PosAPI;
|
|
@@ -63,6 +63,7 @@ export declare const selectCustomerLoyalty: ((state: {
|
|
|
63
63
|
surcharges: import("./surcharges").SurchargesState;
|
|
64
64
|
taxes: import("./taxes").TaxesState;
|
|
65
65
|
idle: import("./idle").IdleState;
|
|
66
|
+
tags: import("./tags").TagsState;
|
|
66
67
|
}) => LoyaltyProgramSummary | null) & {
|
|
67
68
|
clearCache: () => void;
|
|
68
69
|
resultsCount: () => number;
|
package/dist/cjs/slices/index.js
CHANGED
|
@@ -28,3 +28,4 @@ tslib_1.__exportStar(require("./sidebar"), exports);
|
|
|
28
28
|
tslib_1.__exportStar(require("./surcharges"), exports);
|
|
29
29
|
tslib_1.__exportStar(require("./taxes"), exports);
|
|
30
30
|
tslib_1.__exportStar(require("./idle"), exports);
|
|
31
|
+
tslib_1.__exportStar(require("./tags"), exports);
|
|
@@ -70,6 +70,7 @@ export declare const selectStoreSettings: ((state: {
|
|
|
70
70
|
surcharges: import("./surcharges").SurchargesState;
|
|
71
71
|
taxes: import("./taxes").TaxesState;
|
|
72
72
|
idle: import("./idle").IdleState;
|
|
73
|
+
tags: import("./tags").TagsState;
|
|
73
74
|
}) => Store) & {
|
|
74
75
|
clearCache: () => void;
|
|
75
76
|
resultsCount: () => number;
|
|
@@ -119,6 +120,7 @@ export declare const selectKioskTerminal: ((state: {
|
|
|
119
120
|
surcharges: import("./surcharges").SurchargesState;
|
|
120
121
|
taxes: import("./taxes").TaxesState;
|
|
121
122
|
idle: import("./idle").IdleState;
|
|
123
|
+
tags: import("./tags").TagsState;
|
|
122
124
|
}) => import("@open-tender/types").PosTerminal | null) & {
|
|
123
125
|
clearCache: () => void;
|
|
124
126
|
resultsCount: () => number;
|
|
@@ -168,6 +170,7 @@ export declare const selectKioskHasPrinter: ((state: {
|
|
|
168
170
|
surcharges: import("./surcharges").SurchargesState;
|
|
169
171
|
taxes: import("./taxes").TaxesState;
|
|
170
172
|
idle: import("./idle").IdleState;
|
|
173
|
+
tags: import("./tags").TagsState;
|
|
171
174
|
}) => boolean) & {
|
|
172
175
|
clearCache: () => void;
|
|
173
176
|
resultsCount: () => number;
|
|
@@ -217,6 +220,7 @@ export declare const selectKioskHasScanner: ((state: {
|
|
|
217
220
|
surcharges: import("./surcharges").SurchargesState;
|
|
218
221
|
taxes: import("./taxes").TaxesState;
|
|
219
222
|
idle: import("./idle").IdleState;
|
|
223
|
+
tags: import("./tags").TagsState;
|
|
220
224
|
}) => boolean) & {
|
|
221
225
|
clearCache: () => void;
|
|
222
226
|
resultsCount: () => number;
|
|
@@ -266,6 +270,7 @@ export declare const selectKioskApi: ((state: {
|
|
|
266
270
|
surcharges: import("./surcharges").SurchargesState;
|
|
267
271
|
taxes: import("./taxes").TaxesState;
|
|
268
272
|
idle: import("./idle").IdleState;
|
|
273
|
+
tags: import("./tags").TagsState;
|
|
269
274
|
}) => string) & {
|
|
270
275
|
clearCache: () => void;
|
|
271
276
|
resultsCount: () => number;
|
|
@@ -315,6 +320,7 @@ export declare const selectKioskConfig: ((state: {
|
|
|
315
320
|
surcharges: import("./surcharges").SurchargesState;
|
|
316
321
|
taxes: import("./taxes").TaxesState;
|
|
317
322
|
idle: import("./idle").IdleState;
|
|
323
|
+
tags: import("./tags").TagsState;
|
|
318
324
|
}) => AppConfig) & {
|
|
319
325
|
clearCache: () => void;
|
|
320
326
|
resultsCount: () => number;
|
|
@@ -364,6 +370,7 @@ export declare const selectKioskConfigScreen: (screen: string) => ((state: {
|
|
|
364
370
|
surcharges: import("./surcharges").SurchargesState;
|
|
365
371
|
taxes: import("./taxes").TaxesState;
|
|
366
372
|
idle: import("./idle").IdleState;
|
|
373
|
+
tags: import("./tags").TagsState;
|
|
367
374
|
}) => import("@open-tender/ui").ScreenConfig | null) & {
|
|
368
375
|
clearCache: () => void;
|
|
369
376
|
resultsCount: () => number;
|
|
@@ -48,6 +48,7 @@ export declare const selectMenuPagesFiltered: ((state: {
|
|
|
48
48
|
surcharges: import("./surcharges").SurchargesState;
|
|
49
49
|
taxes: import("./taxes").TaxesState;
|
|
50
50
|
idle: import("./idle").IdleState;
|
|
51
|
+
tags: import("./tags").TagsState;
|
|
51
52
|
}) => {
|
|
52
53
|
order_type: import("@open-tender/types").FullOrderType;
|
|
53
54
|
name: string;
|
|
@@ -91,6 +91,7 @@ export declare const selectCartIds: ((state: {
|
|
|
91
91
|
surcharges: import("./surcharges").SurchargesState;
|
|
92
92
|
taxes: import("./taxes").TaxesState;
|
|
93
93
|
idle: import("./idle").IdleState;
|
|
94
|
+
tags: import("./tags").TagsState;
|
|
94
95
|
}) => number[]) & {
|
|
95
96
|
clearCache: () => void;
|
|
96
97
|
resultsCount: () => number;
|
|
@@ -140,6 +141,7 @@ export declare const selectCartQuantity: ((state: {
|
|
|
140
141
|
surcharges: import("./surcharges").SurchargesState;
|
|
141
142
|
taxes: import("./taxes").TaxesState;
|
|
142
143
|
idle: import("./idle").IdleState;
|
|
144
|
+
tags: import("./tags").TagsState;
|
|
143
145
|
}) => number) & {
|
|
144
146
|
clearCache: () => void;
|
|
145
147
|
resultsCount: () => number;
|
|
@@ -189,6 +191,7 @@ export declare const selectCartTotal: ((state: {
|
|
|
189
191
|
surcharges: import("./surcharges").SurchargesState;
|
|
190
192
|
taxes: import("./taxes").TaxesState;
|
|
191
193
|
idle: import("./idle").IdleState;
|
|
194
|
+
tags: import("./tags").TagsState;
|
|
192
195
|
}) => number) & {
|
|
193
196
|
clearCache: () => void;
|
|
194
197
|
resultsCount: () => number;
|
|
@@ -238,6 +241,7 @@ export declare const selectCartTotals: ((state: {
|
|
|
238
241
|
surcharges: import("./surcharges").SurchargesState;
|
|
239
242
|
taxes: import("./taxes").TaxesState;
|
|
240
243
|
idle: import("./idle").IdleState;
|
|
244
|
+
tags: import("./tags").TagsState;
|
|
241
245
|
}) => {
|
|
242
246
|
count: number;
|
|
243
247
|
total: number;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Tags, RequestError, RequestStatus } from '@open-tender/types';
|
|
2
|
+
import { AppState } from '../app';
|
|
3
|
+
export interface TagsState {
|
|
4
|
+
entities: Tags;
|
|
5
|
+
error: RequestError;
|
|
6
|
+
loading: RequestStatus;
|
|
7
|
+
selectedTags: Tags;
|
|
8
|
+
}
|
|
9
|
+
export declare enum TagsActionType {
|
|
10
|
+
FetchTags = "tags/fetchTags"
|
|
11
|
+
}
|
|
12
|
+
export declare const fetchTags: import("@reduxjs/toolkit").AsyncThunk<Tags, void, {
|
|
13
|
+
state: AppState;
|
|
14
|
+
rejectValue: RequestError;
|
|
15
|
+
dispatch?: import("redux").Dispatch<import("redux").UnknownAction> | undefined;
|
|
16
|
+
extra?: unknown;
|
|
17
|
+
serializedErrorType?: unknown;
|
|
18
|
+
pendingMeta?: unknown;
|
|
19
|
+
fulfilledMeta?: unknown;
|
|
20
|
+
rejectedMeta?: unknown;
|
|
21
|
+
}>;
|
|
22
|
+
export declare const resetTags: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"tags/resetTags">, setSelectedTags: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "tags/setSelectedTags">;
|
|
23
|
+
export declare const selectTags: (state: AppState) => TagsState;
|
|
24
|
+
export declare const selectSelectedTags: (state: AppState) => Tags;
|
|
25
|
+
export declare const selectSelectedTagNames: ((state: {
|
|
26
|
+
alerts: import("@open-tender/types").Alerts;
|
|
27
|
+
arrivals: import("./arrivals").ArrivalsState;
|
|
28
|
+
cartSummary: import("./cartSummary").CartSummaryState;
|
|
29
|
+
checkout: import("./checkout").CheckoutState;
|
|
30
|
+
config: import("./config").ConfigState;
|
|
31
|
+
customer: import("./customer").CustomerState;
|
|
32
|
+
customerIdentify: import("./customerIdentify").CustomerIdentifyState;
|
|
33
|
+
deals: import("./deals").DealsState;
|
|
34
|
+
discounts: import("./discounts").DiscountsState;
|
|
35
|
+
errorAlerts: import("./errorAlerts").ErrorAlertsState;
|
|
36
|
+
kds: import("./kds").KdsState;
|
|
37
|
+
kiosk: import("./kiosk").KioskState;
|
|
38
|
+
menu: import("./menu").MenuState;
|
|
39
|
+
menuPages: import("./menuPages").MenuPagesState;
|
|
40
|
+
modal: import("./modal").ModalState;
|
|
41
|
+
notifications: import("@open-tender/types").Notifications;
|
|
42
|
+
offlineAuths: import("./offlineAuths").OfflineAuthsState;
|
|
43
|
+
order: import("./order").OrderState;
|
|
44
|
+
pos: import("./pos").PosState;
|
|
45
|
+
punches: import("./punches").PunchesState;
|
|
46
|
+
refund: import("./refund").RefundState;
|
|
47
|
+
sendReceipt: import("./sendReceipt").SendReceiptState;
|
|
48
|
+
settings: import("./settings").SettingsState;
|
|
49
|
+
sidebar: import("./sidebar").SidebarState;
|
|
50
|
+
surcharges: import("./surcharges").SurchargesState;
|
|
51
|
+
taxes: import("./taxes").TaxesState;
|
|
52
|
+
idle: import("./idle").IdleState;
|
|
53
|
+
tags: TagsState;
|
|
54
|
+
}) => string[]) & {
|
|
55
|
+
clearCache: () => void;
|
|
56
|
+
resultsCount: () => number;
|
|
57
|
+
resetResultsCount: () => void;
|
|
58
|
+
} & {
|
|
59
|
+
resultFunc: (resultFuncArgs_0: {
|
|
60
|
+
tags: Tags;
|
|
61
|
+
selectedTags: Tags;
|
|
62
|
+
}) => string[];
|
|
63
|
+
memoizedResultFunc: ((resultFuncArgs_0: {
|
|
64
|
+
tags: Tags;
|
|
65
|
+
selectedTags: Tags;
|
|
66
|
+
}) => string[]) & {
|
|
67
|
+
clearCache: () => void;
|
|
68
|
+
resultsCount: () => number;
|
|
69
|
+
resetResultsCount: () => void;
|
|
70
|
+
};
|
|
71
|
+
lastResult: () => string[];
|
|
72
|
+
dependencies: [(state: AppState) => {
|
|
73
|
+
tags: Tags;
|
|
74
|
+
selectedTags: Tags;
|
|
75
|
+
}];
|
|
76
|
+
recomputations: () => number;
|
|
77
|
+
resetRecomputations: () => void;
|
|
78
|
+
dependencyRecomputations: () => number;
|
|
79
|
+
resetDependencyRecomputations: () => void;
|
|
80
|
+
} & {
|
|
81
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
82
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
83
|
+
};
|
|
84
|
+
export declare const tagsReducer: import("redux").Reducer<TagsState>;
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
var tslib_1 = require("tslib");
|
|
6
|
+
var toolkit_1 = require("@reduxjs/toolkit");
|
|
7
|
+
var types_1 = require("./types");
|
|
8
|
+
var initialState = {
|
|
9
|
+
entities: [],
|
|
10
|
+
error: null,
|
|
11
|
+
loading: 'idle',
|
|
12
|
+
selectedTags: []
|
|
13
|
+
};
|
|
14
|
+
var TagsActionType;
|
|
15
|
+
(function (TagsActionType) {
|
|
16
|
+
TagsActionType["FetchTags"] = "tags/fetchTags";
|
|
17
|
+
})(TagsActionType || (exports.TagsActionType = TagsActionType = {}));
|
|
18
|
+
exports.fetchTags = (0, toolkit_1.createAsyncThunk)(TagsActionType.FetchTags, function (_1, _a) { return tslib_1.__awaiter(void 0, [_1, _a], void 0, function (_, _b) {
|
|
19
|
+
var api, data, err_1;
|
|
20
|
+
var getState = _b.getState, rejectWithValue = _b.rejectWithValue;
|
|
21
|
+
return tslib_1.__generator(this, function (_c) {
|
|
22
|
+
switch (_c.label) {
|
|
23
|
+
case 0:
|
|
24
|
+
_c.trys.push([0, 2, , 3]);
|
|
25
|
+
api = getState().config.api;
|
|
26
|
+
return [4 /*yield*/, api.getTags()];
|
|
27
|
+
case 1:
|
|
28
|
+
data = _c.sent();
|
|
29
|
+
return [2 /*return*/, data];
|
|
30
|
+
case 2:
|
|
31
|
+
err_1 = _c.sent();
|
|
32
|
+
return [2 /*return*/, rejectWithValue(err_1)];
|
|
33
|
+
case 3: return [2 /*return*/];
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}); });
|
|
37
|
+
var tagsSlice = (0, toolkit_1.createSlice)({
|
|
38
|
+
name: types_1.ReducerType.Tags,
|
|
39
|
+
initialState: initialState,
|
|
40
|
+
reducers: {
|
|
41
|
+
resetTags: function () { return initialState; },
|
|
42
|
+
setSelectedTags: function (state, action) {
|
|
43
|
+
state.selectedTags = action.payload;
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
extraReducers: function (builder) {
|
|
47
|
+
builder
|
|
48
|
+
.addCase(exports.fetchTags.fulfilled, function (state, action) {
|
|
49
|
+
state.entities = action.payload;
|
|
50
|
+
state.loading = 'idle';
|
|
51
|
+
state.error = null;
|
|
52
|
+
})
|
|
53
|
+
.addCase(exports.fetchTags.pending, function (state) {
|
|
54
|
+
state.loading = 'pending';
|
|
55
|
+
})
|
|
56
|
+
.addCase(exports.fetchTags.rejected, function (state, action) {
|
|
57
|
+
state.error = action.payload;
|
|
58
|
+
state.loading = 'idle';
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
exports.resetTags = (_a = tagsSlice.actions, _a.resetTags), exports.setSelectedTags = _a.setSelectedTags;
|
|
63
|
+
var selectTags = function (state) { return state.tags; };
|
|
64
|
+
exports.selectTags = selectTags;
|
|
65
|
+
var selectSelectedTags = function (state) { return state.tags.selectedTags; };
|
|
66
|
+
exports.selectSelectedTags = selectSelectedTags;
|
|
67
|
+
exports.selectSelectedTagNames = (0, toolkit_1.createSelector)(function (state) {
|
|
68
|
+
var _a = state.tags, tags = _a.entities, selectedTags = _a.selectedTags;
|
|
69
|
+
return { tags: tags, selectedTags: selectedTags };
|
|
70
|
+
}, function (_a) {
|
|
71
|
+
var tags = _a.tags, selectedTags = _a.selectedTags;
|
|
72
|
+
if (!selectedTags)
|
|
73
|
+
return [];
|
|
74
|
+
var selected = selectedTags.map(function (i) {
|
|
75
|
+
var _a;
|
|
76
|
+
var tag = tags.find(function (a) { return a.tag_id === i.tag_id; });
|
|
77
|
+
return tag ? (_a = tag.name) !== null && _a !== void 0 ? _a : '' : '';
|
|
78
|
+
});
|
|
79
|
+
return selected;
|
|
80
|
+
});
|
|
81
|
+
exports.tagsReducer = tagsSlice.reducer;
|
package/dist/cjs/slices/types.js
CHANGED
package/dist/esm/app/hooks.d.ts
CHANGED
|
@@ -28,5 +28,6 @@ export declare const useAppDispatch: () => import("redux-thunk").ThunkDispatch<{
|
|
|
28
28
|
surcharges: import("..").SurchargesState;
|
|
29
29
|
taxes: import("..").TaxesState;
|
|
30
30
|
idle: import("..").IdleState;
|
|
31
|
+
tags: import("..").TagsState;
|
|
31
32
|
}, undefined, import("redux").UnknownAction> & import("redux").Dispatch<import("redux").Action>;
|
|
32
33
|
export declare const useAppSelector: TypedUseSelectorHook<RootState>;
|
package/dist/esm/app/store.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export declare const appReducer: import("redux").Reducer<{
|
|
|
27
27
|
surcharges: import("../slices").SurchargesState;
|
|
28
28
|
taxes: import("../slices").TaxesState;
|
|
29
29
|
idle: import("../slices").IdleState;
|
|
30
|
+
tags: import("../slices").TagsState;
|
|
30
31
|
}, import("redux").UnknownAction, Partial<{
|
|
31
32
|
alerts: import("@open-tender/types").Alerts | undefined;
|
|
32
33
|
arrivals: import("../slices").ArrivalsState | undefined;
|
|
@@ -55,6 +56,7 @@ export declare const appReducer: import("redux").Reducer<{
|
|
|
55
56
|
surcharges: import("../slices").SurchargesState | undefined;
|
|
56
57
|
taxes: import("../slices").TaxesState | undefined;
|
|
57
58
|
idle: import("../slices").IdleState | undefined;
|
|
59
|
+
tags: import("../slices").TagsState | undefined;
|
|
58
60
|
}>>;
|
|
59
61
|
export type AppState = ReturnType<typeof appReducer>;
|
|
60
62
|
declare const store: import("@reduxjs/toolkit").EnhancedStore<{
|
|
@@ -85,6 +87,7 @@ declare const store: import("@reduxjs/toolkit").EnhancedStore<{
|
|
|
85
87
|
surcharges: import("../slices").SurchargesState;
|
|
86
88
|
taxes: import("../slices").TaxesState;
|
|
87
89
|
idle: import("../slices").IdleState;
|
|
90
|
+
tags: import("../slices").TagsState;
|
|
88
91
|
}, Action, import("@reduxjs/toolkit").Tuple<[import("redux").StoreEnhancer<{
|
|
89
92
|
dispatch: import("redux-thunk").ThunkDispatch<{
|
|
90
93
|
alerts: import("@open-tender/types").Alerts;
|
|
@@ -114,6 +117,7 @@ declare const store: import("@reduxjs/toolkit").EnhancedStore<{
|
|
|
114
117
|
surcharges: import("../slices").SurchargesState;
|
|
115
118
|
taxes: import("../slices").TaxesState;
|
|
116
119
|
idle: import("../slices").IdleState;
|
|
120
|
+
tags: import("../slices").TagsState;
|
|
117
121
|
}, undefined, import("redux").UnknownAction>;
|
|
118
122
|
}>, import("redux").StoreEnhancer]>>;
|
|
119
123
|
export type AppDispatch = typeof store.dispatch;
|
package/dist/esm/app/store.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { combineReducers, configureStore } from '@reduxjs/toolkit';
|
|
2
|
-
import { alertsReducer, arrivalsReducer, cartSummaryReducer, checkoutReducer, configReducer, customerReducer, customerIdentifyReducer, dealsReducer, discountsReducer, errorAlertsReducer, kdsReducer, kioskReducer, menuReducer, menuPagesReducer, modalReducer, notificationsReducer, offlineAuthsReducer, orderReducer, posReducer, punchesReducer, refundReducer, sendReceiptReducer, settingsReducer, sidebarReducer, surchargesReducer, taxesReducer, idleReducer } from '../slices';
|
|
2
|
+
import { alertsReducer, arrivalsReducer, cartSummaryReducer, checkoutReducer, configReducer, customerReducer, customerIdentifyReducer, dealsReducer, discountsReducer, errorAlertsReducer, kdsReducer, kioskReducer, menuReducer, menuPagesReducer, modalReducer, notificationsReducer, offlineAuthsReducer, orderReducer, posReducer, punchesReducer, refundReducer, sendReceiptReducer, settingsReducer, sidebarReducer, surchargesReducer, taxesReducer, idleReducer, tagsReducer } from '../slices';
|
|
3
3
|
export var appReducer = combineReducers({
|
|
4
4
|
alerts: alertsReducer,
|
|
5
5
|
arrivals: arrivalsReducer,
|
|
@@ -27,7 +27,8 @@ export var appReducer = combineReducers({
|
|
|
27
27
|
sidebar: sidebarReducer,
|
|
28
28
|
surcharges: surchargesReducer,
|
|
29
29
|
taxes: taxesReducer,
|
|
30
|
-
idle: idleReducer
|
|
30
|
+
idle: idleReducer,
|
|
31
|
+
tags: tagsReducer
|
|
31
32
|
});
|
|
32
33
|
var rootReducer = function (state, action) {
|
|
33
34
|
if (action.type === 'clearState') {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SwitchProps } from '@open-tender/ui';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
declare const Switch: ({ id, label, on, isRequired, disabled, falseTrackColor, thumbColor, trueTrackColor, onChange, children }: {
|
|
4
|
+
id: number | string;
|
|
5
|
+
label: string;
|
|
6
|
+
on: boolean;
|
|
7
|
+
falseTrackColor?: string;
|
|
8
|
+
trueTrackColor?: string;
|
|
9
|
+
thumbColor?: string;
|
|
10
|
+
isRequired: boolean;
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
onChange: (value: boolean) => void;
|
|
13
|
+
children: (props: SwitchProps) => ReactNode;
|
|
14
|
+
}) => ReactNode;
|
|
15
|
+
export default Switch;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useAppSelector } from '../app/hooks';
|
|
2
|
+
import { selectKioskConfig } from '../slices';
|
|
3
|
+
var Switch = function (_a) {
|
|
4
|
+
var id = _a.id, label = _a.label, on = _a.on, isRequired = _a.isRequired, disabled = _a.disabled, falseTrackColor = _a.falseTrackColor, thumbColor = _a.thumbColor, trueTrackColor = _a.trueTrackColor, onChange = _a.onChange, children = _a.children;
|
|
5
|
+
var config = useAppSelector(selectKioskConfig).switch;
|
|
6
|
+
if (!config)
|
|
7
|
+
return null;
|
|
8
|
+
return children({
|
|
9
|
+
id: id,
|
|
10
|
+
config: config,
|
|
11
|
+
label: label,
|
|
12
|
+
value: on,
|
|
13
|
+
onTagSwitch: onChange,
|
|
14
|
+
isRequired: isRequired,
|
|
15
|
+
disabled: disabled,
|
|
16
|
+
falseTrackColor: falseTrackColor,
|
|
17
|
+
thumbColor: thumbColor,
|
|
18
|
+
trueTrackColor: trueTrackColor
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
export default Switch;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Tags } from '@open-tender/types';
|
|
2
|
+
import { Handlers, ScreenConfig, SwitchProps } from '@open-tender/ui';
|
|
3
|
+
import React, { ReactNode } from 'react';
|
|
4
|
+
declare const TagsFilter: ({ children, SwitchView }: {
|
|
5
|
+
children: (props: {
|
|
6
|
+
config: ScreenConfig;
|
|
7
|
+
tags: Tags;
|
|
8
|
+
renderSwitch: (props: SwitchProps) => ReactNode;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
error?: string;
|
|
11
|
+
handlers: Handlers;
|
|
12
|
+
}) => ReactNode;
|
|
13
|
+
SwitchView: (props: SwitchProps) => ReactNode;
|
|
14
|
+
}) => React.ReactNode;
|
|
15
|
+
export default TagsFilter;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { __spreadArray } from "tslib";
|
|
2
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
3
|
+
import { useAppDispatch, useAppSelector } from '../app/hooks';
|
|
4
|
+
import { selectKioskConfig, selectTags, setSelectedTags } from '../slices';
|
|
5
|
+
import { default as SwitchContainer } from './Switch';
|
|
6
|
+
var TagsFilter = function (_a) {
|
|
7
|
+
var children = _a.children, SwitchView = _a.SwitchView;
|
|
8
|
+
var config = useAppSelector(selectKioskConfig).tags;
|
|
9
|
+
var dispatch = useAppDispatch();
|
|
10
|
+
var _b = useAppSelector(selectTags), tags = _b.entities, selectedTags = _b.selectedTags, loading = _b.loading, error = _b.error;
|
|
11
|
+
var _c = useState([]), localSelectedTags = _c[0], setLocalSelectedTags = _c[1];
|
|
12
|
+
var isLoading = loading === 'pending';
|
|
13
|
+
useEffect(function () {
|
|
14
|
+
setLocalSelectedTags(selectedTags.map(function (tag) { return tag.tag_id; }));
|
|
15
|
+
}, [selectedTags]);
|
|
16
|
+
var onTagSwitch = function (tag) {
|
|
17
|
+
setLocalSelectedTags(function (prevSelectedTags) {
|
|
18
|
+
if (prevSelectedTags.includes(tag.tag_id)) {
|
|
19
|
+
return prevSelectedTags.filter(function (id) { return id !== tag.tag_id; });
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return __spreadArray(__spreadArray([], prevSelectedTags, true), [tag.tag_id], false);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var handleSubmit = function () {
|
|
27
|
+
var newSelectedTags = tags.filter(function (tag) {
|
|
28
|
+
return localSelectedTags.includes(tag.tag_id);
|
|
29
|
+
});
|
|
30
|
+
dispatch(setSelectedTags(newSelectedTags));
|
|
31
|
+
};
|
|
32
|
+
var handlers = { onTagSwitch: onTagSwitch, handleSubmit: handleSubmit };
|
|
33
|
+
var renderSwitch = useCallback(function (props) {
|
|
34
|
+
return (React.createElement(SwitchContainer, { key: props.id, id: props.id, children: SwitchView, label: props.label, on: props.value, onChange: props.onTagSwitch, disabled: false, isRequired: true }));
|
|
35
|
+
}, [SwitchView]);
|
|
36
|
+
return children({
|
|
37
|
+
config: config,
|
|
38
|
+
handlers: handlers,
|
|
39
|
+
isLoading: isLoading,
|
|
40
|
+
renderSwitch: renderSwitch,
|
|
41
|
+
tags: tags,
|
|
42
|
+
error: error === null || error === void 0 ? void 0 : error.detail
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
export default TagsFilter;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Arrivals, CheckoutTender, CustomerEndpoints, CustomerIdentifier, CustomerIdentify, Discount, Discounts, ItemTypes, Menu, Order, Orders, OrderCreatePos, OrderTender, OrderUpdate, OrderType, RequestedAt, RevenueCenter, SelectOptions, ServiceType, TicketUpdate, TicketsUpdate, TicketStatusUpdate, EntityType, KioskConfig, Store, Settings, InternalSettings, GiftCardCredit, GiftCardBalance, Employee, Punch, Employees, CashEvent, CashSummary, ErrorAlerts, ErrorAlert, OfflineAuths, OfflineAuthsResult, MenuColors, MenuPages, Surcharges, Taxes, CheckoutTenderPos, Refund, DeviceRead, OrderCreateSendReceipt } from '@open-tender/types';
|
|
1
|
+
import { Arrivals, CheckoutTender, CustomerEndpoints, CustomerIdentifier, CustomerIdentify, Discount, Discounts, ItemTypes, Menu, Order, Orders, OrderCreatePos, OrderTender, OrderUpdate, OrderType, RequestedAt, RevenueCenter, SelectOptions, ServiceType, TicketUpdate, TicketsUpdate, TicketStatusUpdate, EntityType, KioskConfig, Store, Settings, InternalSettings, GiftCardCredit, GiftCardBalance, Employee, Punch, Employees, CashEvent, CashSummary, ErrorAlerts, ErrorAlert, OfflineAuths, OfflineAuthsResult, MenuColors, MenuPages, Surcharges, Taxes, CheckoutTenderPos, Refund, DeviceRead, OrderCreateSendReceipt, Tags } from '@open-tender/types';
|
|
2
2
|
import { OrdersParams } from '../slices';
|
|
3
3
|
export interface InitAPI {
|
|
4
4
|
apiUrl: string;
|
|
@@ -79,5 +79,6 @@ declare class PosAPI {
|
|
|
79
79
|
postAcknowledgeArrival(orderId: string): Promise<Order>;
|
|
80
80
|
postRefundValidate(orderId: string, refund: Refund): Promise<Order>;
|
|
81
81
|
postRefund(orderId: string, refund: Refund): Promise<Order>;
|
|
82
|
+
getTags(): Promise<Tags>;
|
|
82
83
|
}
|
|
83
84
|
export default PosAPI;
|
package/dist/esm/services/api.js
CHANGED
|
@@ -370,6 +370,9 @@ var PosAPI = /** @class */ (function () {
|
|
|
370
370
|
PosAPI.prototype.postRefund = function (orderId, refund) {
|
|
371
371
|
return this.request("/orders/".concat(orderId, "/refund"), 'POST', refund);
|
|
372
372
|
};
|
|
373
|
+
PosAPI.prototype.getTags = function () {
|
|
374
|
+
return this.request("/tags");
|
|
375
|
+
};
|
|
373
376
|
return PosAPI;
|
|
374
377
|
}());
|
|
375
378
|
export default PosAPI;
|
|
@@ -63,6 +63,7 @@ export declare const selectCustomerLoyalty: ((state: {
|
|
|
63
63
|
surcharges: import("./surcharges").SurchargesState;
|
|
64
64
|
taxes: import("./taxes").TaxesState;
|
|
65
65
|
idle: import("./idle").IdleState;
|
|
66
|
+
tags: import("./tags").TagsState;
|
|
66
67
|
}) => LoyaltyProgramSummary | null) & {
|
|
67
68
|
clearCache: () => void;
|
|
68
69
|
resultsCount: () => number;
|
package/dist/esm/slices/index.js
CHANGED
|
@@ -70,6 +70,7 @@ export declare const selectStoreSettings: ((state: {
|
|
|
70
70
|
surcharges: import("./surcharges").SurchargesState;
|
|
71
71
|
taxes: import("./taxes").TaxesState;
|
|
72
72
|
idle: import("./idle").IdleState;
|
|
73
|
+
tags: import("./tags").TagsState;
|
|
73
74
|
}) => Store) & {
|
|
74
75
|
clearCache: () => void;
|
|
75
76
|
resultsCount: () => number;
|
|
@@ -119,6 +120,7 @@ export declare const selectKioskTerminal: ((state: {
|
|
|
119
120
|
surcharges: import("./surcharges").SurchargesState;
|
|
120
121
|
taxes: import("./taxes").TaxesState;
|
|
121
122
|
idle: import("./idle").IdleState;
|
|
123
|
+
tags: import("./tags").TagsState;
|
|
122
124
|
}) => import("@open-tender/types").PosTerminal | null) & {
|
|
123
125
|
clearCache: () => void;
|
|
124
126
|
resultsCount: () => number;
|
|
@@ -168,6 +170,7 @@ export declare const selectKioskHasPrinter: ((state: {
|
|
|
168
170
|
surcharges: import("./surcharges").SurchargesState;
|
|
169
171
|
taxes: import("./taxes").TaxesState;
|
|
170
172
|
idle: import("./idle").IdleState;
|
|
173
|
+
tags: import("./tags").TagsState;
|
|
171
174
|
}) => boolean) & {
|
|
172
175
|
clearCache: () => void;
|
|
173
176
|
resultsCount: () => number;
|
|
@@ -217,6 +220,7 @@ export declare const selectKioskHasScanner: ((state: {
|
|
|
217
220
|
surcharges: import("./surcharges").SurchargesState;
|
|
218
221
|
taxes: import("./taxes").TaxesState;
|
|
219
222
|
idle: import("./idle").IdleState;
|
|
223
|
+
tags: import("./tags").TagsState;
|
|
220
224
|
}) => boolean) & {
|
|
221
225
|
clearCache: () => void;
|
|
222
226
|
resultsCount: () => number;
|
|
@@ -266,6 +270,7 @@ export declare const selectKioskApi: ((state: {
|
|
|
266
270
|
surcharges: import("./surcharges").SurchargesState;
|
|
267
271
|
taxes: import("./taxes").TaxesState;
|
|
268
272
|
idle: import("./idle").IdleState;
|
|
273
|
+
tags: import("./tags").TagsState;
|
|
269
274
|
}) => string) & {
|
|
270
275
|
clearCache: () => void;
|
|
271
276
|
resultsCount: () => number;
|
|
@@ -315,6 +320,7 @@ export declare const selectKioskConfig: ((state: {
|
|
|
315
320
|
surcharges: import("./surcharges").SurchargesState;
|
|
316
321
|
taxes: import("./taxes").TaxesState;
|
|
317
322
|
idle: import("./idle").IdleState;
|
|
323
|
+
tags: import("./tags").TagsState;
|
|
318
324
|
}) => AppConfig) & {
|
|
319
325
|
clearCache: () => void;
|
|
320
326
|
resultsCount: () => number;
|
|
@@ -364,6 +370,7 @@ export declare const selectKioskConfigScreen: (screen: string) => ((state: {
|
|
|
364
370
|
surcharges: import("./surcharges").SurchargesState;
|
|
365
371
|
taxes: import("./taxes").TaxesState;
|
|
366
372
|
idle: import("./idle").IdleState;
|
|
373
|
+
tags: import("./tags").TagsState;
|
|
367
374
|
}) => import("@open-tender/ui").ScreenConfig | null) & {
|
|
368
375
|
clearCache: () => void;
|
|
369
376
|
resultsCount: () => number;
|
|
@@ -48,6 +48,7 @@ export declare const selectMenuPagesFiltered: ((state: {
|
|
|
48
48
|
surcharges: import("./surcharges").SurchargesState;
|
|
49
49
|
taxes: import("./taxes").TaxesState;
|
|
50
50
|
idle: import("./idle").IdleState;
|
|
51
|
+
tags: import("./tags").TagsState;
|
|
51
52
|
}) => {
|
|
52
53
|
order_type: import("@open-tender/types").FullOrderType;
|
|
53
54
|
name: string;
|
|
@@ -91,6 +91,7 @@ export declare const selectCartIds: ((state: {
|
|
|
91
91
|
surcharges: import("./surcharges").SurchargesState;
|
|
92
92
|
taxes: import("./taxes").TaxesState;
|
|
93
93
|
idle: import("./idle").IdleState;
|
|
94
|
+
tags: import("./tags").TagsState;
|
|
94
95
|
}) => number[]) & {
|
|
95
96
|
clearCache: () => void;
|
|
96
97
|
resultsCount: () => number;
|
|
@@ -140,6 +141,7 @@ export declare const selectCartQuantity: ((state: {
|
|
|
140
141
|
surcharges: import("./surcharges").SurchargesState;
|
|
141
142
|
taxes: import("./taxes").TaxesState;
|
|
142
143
|
idle: import("./idle").IdleState;
|
|
144
|
+
tags: import("./tags").TagsState;
|
|
143
145
|
}) => number) & {
|
|
144
146
|
clearCache: () => void;
|
|
145
147
|
resultsCount: () => number;
|
|
@@ -189,6 +191,7 @@ export declare const selectCartTotal: ((state: {
|
|
|
189
191
|
surcharges: import("./surcharges").SurchargesState;
|
|
190
192
|
taxes: import("./taxes").TaxesState;
|
|
191
193
|
idle: import("./idle").IdleState;
|
|
194
|
+
tags: import("./tags").TagsState;
|
|
192
195
|
}) => number) & {
|
|
193
196
|
clearCache: () => void;
|
|
194
197
|
resultsCount: () => number;
|
|
@@ -238,6 +241,7 @@ export declare const selectCartTotals: ((state: {
|
|
|
238
241
|
surcharges: import("./surcharges").SurchargesState;
|
|
239
242
|
taxes: import("./taxes").TaxesState;
|
|
240
243
|
idle: import("./idle").IdleState;
|
|
244
|
+
tags: import("./tags").TagsState;
|
|
241
245
|
}) => {
|
|
242
246
|
count: number;
|
|
243
247
|
total: number;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Tags, RequestError, RequestStatus } from '@open-tender/types';
|
|
2
|
+
import { AppState } from '../app';
|
|
3
|
+
export interface TagsState {
|
|
4
|
+
entities: Tags;
|
|
5
|
+
error: RequestError;
|
|
6
|
+
loading: RequestStatus;
|
|
7
|
+
selectedTags: Tags;
|
|
8
|
+
}
|
|
9
|
+
export declare enum TagsActionType {
|
|
10
|
+
FetchTags = "tags/fetchTags"
|
|
11
|
+
}
|
|
12
|
+
export declare const fetchTags: import("@reduxjs/toolkit").AsyncThunk<Tags, void, {
|
|
13
|
+
state: AppState;
|
|
14
|
+
rejectValue: RequestError;
|
|
15
|
+
dispatch?: import("redux").Dispatch<import("redux").UnknownAction> | undefined;
|
|
16
|
+
extra?: unknown;
|
|
17
|
+
serializedErrorType?: unknown;
|
|
18
|
+
pendingMeta?: unknown;
|
|
19
|
+
fulfilledMeta?: unknown;
|
|
20
|
+
rejectedMeta?: unknown;
|
|
21
|
+
}>;
|
|
22
|
+
export declare const resetTags: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"tags/resetTags">, setSelectedTags: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "tags/setSelectedTags">;
|
|
23
|
+
export declare const selectTags: (state: AppState) => TagsState;
|
|
24
|
+
export declare const selectSelectedTags: (state: AppState) => Tags;
|
|
25
|
+
export declare const selectSelectedTagNames: ((state: {
|
|
26
|
+
alerts: import("@open-tender/types").Alerts;
|
|
27
|
+
arrivals: import("./arrivals").ArrivalsState;
|
|
28
|
+
cartSummary: import("./cartSummary").CartSummaryState;
|
|
29
|
+
checkout: import("./checkout").CheckoutState;
|
|
30
|
+
config: import("./config").ConfigState;
|
|
31
|
+
customer: import("./customer").CustomerState;
|
|
32
|
+
customerIdentify: import("./customerIdentify").CustomerIdentifyState;
|
|
33
|
+
deals: import("./deals").DealsState;
|
|
34
|
+
discounts: import("./discounts").DiscountsState;
|
|
35
|
+
errorAlerts: import("./errorAlerts").ErrorAlertsState;
|
|
36
|
+
kds: import("./kds").KdsState;
|
|
37
|
+
kiosk: import("./kiosk").KioskState;
|
|
38
|
+
menu: import("./menu").MenuState;
|
|
39
|
+
menuPages: import("./menuPages").MenuPagesState;
|
|
40
|
+
modal: import("./modal").ModalState;
|
|
41
|
+
notifications: import("@open-tender/types").Notifications;
|
|
42
|
+
offlineAuths: import("./offlineAuths").OfflineAuthsState;
|
|
43
|
+
order: import("./order").OrderState;
|
|
44
|
+
pos: import("./pos").PosState;
|
|
45
|
+
punches: import("./punches").PunchesState;
|
|
46
|
+
refund: import("./refund").RefundState;
|
|
47
|
+
sendReceipt: import("./sendReceipt").SendReceiptState;
|
|
48
|
+
settings: import("./settings").SettingsState;
|
|
49
|
+
sidebar: import("./sidebar").SidebarState;
|
|
50
|
+
surcharges: import("./surcharges").SurchargesState;
|
|
51
|
+
taxes: import("./taxes").TaxesState;
|
|
52
|
+
idle: import("./idle").IdleState;
|
|
53
|
+
tags: TagsState;
|
|
54
|
+
}) => string[]) & {
|
|
55
|
+
clearCache: () => void;
|
|
56
|
+
resultsCount: () => number;
|
|
57
|
+
resetResultsCount: () => void;
|
|
58
|
+
} & {
|
|
59
|
+
resultFunc: (resultFuncArgs_0: {
|
|
60
|
+
tags: Tags;
|
|
61
|
+
selectedTags: Tags;
|
|
62
|
+
}) => string[];
|
|
63
|
+
memoizedResultFunc: ((resultFuncArgs_0: {
|
|
64
|
+
tags: Tags;
|
|
65
|
+
selectedTags: Tags;
|
|
66
|
+
}) => string[]) & {
|
|
67
|
+
clearCache: () => void;
|
|
68
|
+
resultsCount: () => number;
|
|
69
|
+
resetResultsCount: () => void;
|
|
70
|
+
};
|
|
71
|
+
lastResult: () => string[];
|
|
72
|
+
dependencies: [(state: AppState) => {
|
|
73
|
+
tags: Tags;
|
|
74
|
+
selectedTags: Tags;
|
|
75
|
+
}];
|
|
76
|
+
recomputations: () => number;
|
|
77
|
+
resetRecomputations: () => void;
|
|
78
|
+
dependencyRecomputations: () => number;
|
|
79
|
+
resetDependencyRecomputations: () => void;
|
|
80
|
+
} & {
|
|
81
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
82
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
83
|
+
};
|
|
84
|
+
export declare const tagsReducer: import("redux").Reducer<TagsState>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { __awaiter, __generator } from "tslib";
|
|
3
|
+
import { createAsyncThunk, createSelector, createSlice } from '@reduxjs/toolkit';
|
|
4
|
+
import { ReducerType } from './types';
|
|
5
|
+
var initialState = {
|
|
6
|
+
entities: [],
|
|
7
|
+
error: null,
|
|
8
|
+
loading: 'idle',
|
|
9
|
+
selectedTags: []
|
|
10
|
+
};
|
|
11
|
+
export var TagsActionType;
|
|
12
|
+
(function (TagsActionType) {
|
|
13
|
+
TagsActionType["FetchTags"] = "tags/fetchTags";
|
|
14
|
+
})(TagsActionType || (TagsActionType = {}));
|
|
15
|
+
export var fetchTags = createAsyncThunk(TagsActionType.FetchTags, function (_1, _a) { return __awaiter(void 0, [_1, _a], void 0, function (_, _b) {
|
|
16
|
+
var api, data, err_1;
|
|
17
|
+
var getState = _b.getState, rejectWithValue = _b.rejectWithValue;
|
|
18
|
+
return __generator(this, function (_c) {
|
|
19
|
+
switch (_c.label) {
|
|
20
|
+
case 0:
|
|
21
|
+
_c.trys.push([0, 2, , 3]);
|
|
22
|
+
api = getState().config.api;
|
|
23
|
+
return [4 /*yield*/, api.getTags()];
|
|
24
|
+
case 1:
|
|
25
|
+
data = _c.sent();
|
|
26
|
+
return [2 /*return*/, data];
|
|
27
|
+
case 2:
|
|
28
|
+
err_1 = _c.sent();
|
|
29
|
+
return [2 /*return*/, rejectWithValue(err_1)];
|
|
30
|
+
case 3: return [2 /*return*/];
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}); });
|
|
34
|
+
var tagsSlice = createSlice({
|
|
35
|
+
name: ReducerType.Tags,
|
|
36
|
+
initialState: initialState,
|
|
37
|
+
reducers: {
|
|
38
|
+
resetTags: function () { return initialState; },
|
|
39
|
+
setSelectedTags: function (state, action) {
|
|
40
|
+
state.selectedTags = action.payload;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
extraReducers: function (builder) {
|
|
44
|
+
builder
|
|
45
|
+
.addCase(fetchTags.fulfilled, function (state, action) {
|
|
46
|
+
state.entities = action.payload;
|
|
47
|
+
state.loading = 'idle';
|
|
48
|
+
state.error = null;
|
|
49
|
+
})
|
|
50
|
+
.addCase(fetchTags.pending, function (state) {
|
|
51
|
+
state.loading = 'pending';
|
|
52
|
+
})
|
|
53
|
+
.addCase(fetchTags.rejected, function (state, action) {
|
|
54
|
+
state.error = action.payload;
|
|
55
|
+
state.loading = 'idle';
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
export var resetTags = (_a = tagsSlice.actions, _a.resetTags), setSelectedTags = _a.setSelectedTags;
|
|
60
|
+
export var selectTags = function (state) { return state.tags; };
|
|
61
|
+
export var selectSelectedTags = function (state) { return state.tags.selectedTags; };
|
|
62
|
+
export var selectSelectedTagNames = createSelector(function (state) {
|
|
63
|
+
var _a = state.tags, tags = _a.entities, selectedTags = _a.selectedTags;
|
|
64
|
+
return { tags: tags, selectedTags: selectedTags };
|
|
65
|
+
}, function (_a) {
|
|
66
|
+
var tags = _a.tags, selectedTags = _a.selectedTags;
|
|
67
|
+
if (!selectedTags)
|
|
68
|
+
return [];
|
|
69
|
+
var selected = selectedTags.map(function (i) {
|
|
70
|
+
var _a;
|
|
71
|
+
var tag = tags.find(function (a) { return a.tag_id === i.tag_id; });
|
|
72
|
+
return tag ? (_a = tag.name) !== null && _a !== void 0 ? _a : '' : '';
|
|
73
|
+
});
|
|
74
|
+
return selected;
|
|
75
|
+
});
|
|
76
|
+
export var tagsReducer = tagsSlice.reducer;
|
package/dist/esm/slices/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/store",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.172",
|
|
4
4
|
"description": "A library of hooks, reducers, utility functions, and types for use with Open Tender applications that utilize our in-store POS API",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"@emotion/react": "^11.11.1",
|
|
64
64
|
"@open-tender/types": "^0.4.77",
|
|
65
|
-
"@open-tender/ui": "^0.4.
|
|
65
|
+
"@open-tender/ui": "^0.4.7",
|
|
66
66
|
"@open-tender/utils": "^0.4.52",
|
|
67
67
|
"@reduxjs/toolkit": "^2.0.1",
|
|
68
68
|
"date-fns": "2.30.0",
|