@open-tender/store 1.1.181 → 1.1.183
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/CategoryNavItem.d.ts +3 -1
- package/dist/cjs/components/CategoryNavItem.js +7 -2
- package/dist/cjs/components/OrderCard.d.ts +2 -2
- package/dist/cjs/components/OrderCard.js +4 -6
- package/dist/cjs/components/OrderDetails.d.ts +1 -2
- package/dist/cjs/components/OrderDetails.js +2 -18
- package/dist/cjs/components/SignInPhone.js +0 -1
- package/dist/cjs/components/Switch.d.ts +15 -0
- package/dist/cjs/components/Switch.js +23 -0
- package/dist/cjs/components/TagsButton.d.ts +6 -0
- package/dist/cjs/components/TagsButton.js +18 -0
- package/dist/cjs/components/TagsFilter.d.ts +7 -0
- package/dist/cjs/components/TagsFilter.js +52 -0
- package/dist/cjs/components/index.d.ts +4 -1
- package/dist/cjs/components/index.js +7 -1
- package/dist/cjs/hooks/useOrderValidate.js +4 -4
- 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 +86 -0
- package/dist/cjs/slices/tags.js +87 -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/CategoryNavItem.d.ts +3 -1
- package/dist/esm/components/CategoryNavItem.js +7 -2
- package/dist/esm/components/OrderCard.d.ts +2 -2
- package/dist/esm/components/OrderCard.js +5 -7
- package/dist/esm/components/OrderDetails.d.ts +1 -2
- package/dist/esm/components/OrderDetails.js +4 -20
- package/dist/esm/components/SignInPhone.js +0 -1
- package/dist/esm/components/Switch.d.ts +15 -0
- package/dist/esm/components/Switch.js +21 -0
- package/dist/esm/components/TagsButton.d.ts +6 -0
- package/dist/esm/components/TagsButton.js +16 -0
- package/dist/esm/components/TagsFilter.d.ts +7 -0
- package/dist/esm/components/TagsFilter.js +50 -0
- package/dist/esm/components/index.d.ts +4 -1
- package/dist/esm/components/index.js +4 -1
- package/dist/esm/hooks/useOrderValidate.js +4 -4
- 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 +86 -0
- package/dist/esm/slices/tags.js +81 -0
- package/dist/esm/slices/types.d.ts +2 -1
- package/dist/esm/slices/types.js +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.tagsReducer = exports.selectSelectedTagNames = exports.selectShowTagsModal = exports.selectSelectedTags = exports.selectTags = exports.toggleTagsModal = 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
|
+
showTagsModal: false
|
|
14
|
+
};
|
|
15
|
+
var TagsActionType;
|
|
16
|
+
(function (TagsActionType) {
|
|
17
|
+
TagsActionType["FetchTags"] = "tags/fetchTags";
|
|
18
|
+
})(TagsActionType || (exports.TagsActionType = TagsActionType = {}));
|
|
19
|
+
exports.fetchTags = (0, toolkit_1.createAsyncThunk)(TagsActionType.FetchTags, function (_1, _a) { return tslib_1.__awaiter(void 0, [_1, _a], void 0, function (_, _b) {
|
|
20
|
+
var api, data, err_1;
|
|
21
|
+
var getState = _b.getState, rejectWithValue = _b.rejectWithValue;
|
|
22
|
+
return tslib_1.__generator(this, function (_c) {
|
|
23
|
+
switch (_c.label) {
|
|
24
|
+
case 0:
|
|
25
|
+
_c.trys.push([0, 2, , 3]);
|
|
26
|
+
api = getState().config.api;
|
|
27
|
+
return [4 /*yield*/, api.getTags()];
|
|
28
|
+
case 1:
|
|
29
|
+
data = _c.sent();
|
|
30
|
+
return [2 /*return*/, data];
|
|
31
|
+
case 2:
|
|
32
|
+
err_1 = _c.sent();
|
|
33
|
+
return [2 /*return*/, rejectWithValue(err_1)];
|
|
34
|
+
case 3: return [2 /*return*/];
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}); });
|
|
38
|
+
var tagsSlice = (0, toolkit_1.createSlice)({
|
|
39
|
+
name: types_1.ReducerType.Tags,
|
|
40
|
+
initialState: initialState,
|
|
41
|
+
reducers: {
|
|
42
|
+
resetTags: function () { return initialState; },
|
|
43
|
+
setSelectedTags: function (state, action) {
|
|
44
|
+
state.selectedTags = action.payload;
|
|
45
|
+
},
|
|
46
|
+
toggleTagsModal: function (state, action) {
|
|
47
|
+
state.showTagsModal = action.payload;
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
extraReducers: function (builder) {
|
|
51
|
+
builder
|
|
52
|
+
.addCase(exports.fetchTags.fulfilled, function (state, action) {
|
|
53
|
+
state.entities = action.payload;
|
|
54
|
+
state.loading = 'idle';
|
|
55
|
+
state.error = null;
|
|
56
|
+
})
|
|
57
|
+
.addCase(exports.fetchTags.pending, function (state) {
|
|
58
|
+
state.loading = 'pending';
|
|
59
|
+
})
|
|
60
|
+
.addCase(exports.fetchTags.rejected, function (state, action) {
|
|
61
|
+
state.error = action.payload;
|
|
62
|
+
state.loading = 'idle';
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
exports.resetTags = (_a = tagsSlice.actions, _a.resetTags), exports.setSelectedTags = _a.setSelectedTags, exports.toggleTagsModal = _a.toggleTagsModal;
|
|
67
|
+
var selectTags = function (state) { return state.tags; };
|
|
68
|
+
exports.selectTags = selectTags;
|
|
69
|
+
var selectSelectedTags = function (state) { return state.tags.selectedTags; };
|
|
70
|
+
exports.selectSelectedTags = selectSelectedTags;
|
|
71
|
+
var selectShowTagsModal = function (state) { return state.tags.showTagsModal; };
|
|
72
|
+
exports.selectShowTagsModal = selectShowTagsModal;
|
|
73
|
+
exports.selectSelectedTagNames = (0, toolkit_1.createSelector)(function (state) {
|
|
74
|
+
var _a = state.tags, tags = _a.entities, selectedTags = _a.selectedTags;
|
|
75
|
+
return { tags: tags, selectedTags: selectedTags };
|
|
76
|
+
}, function (_a) {
|
|
77
|
+
var tags = _a.tags, selectedTags = _a.selectedTags;
|
|
78
|
+
if (!selectedTags)
|
|
79
|
+
return [];
|
|
80
|
+
var selected = selectedTags.map(function (i) {
|
|
81
|
+
var _a;
|
|
82
|
+
var tag = tags.find(function (a) { return a.tag_id === i.tag_id; });
|
|
83
|
+
return tag ? (_a = tag.name) !== null && _a !== void 0 ? _a : '' : '';
|
|
84
|
+
});
|
|
85
|
+
return selected;
|
|
86
|
+
});
|
|
87
|
+
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') {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { MenuCategory } from '@open-tender/types';
|
|
2
2
|
import { CategoryNavItemProps } from '@open-tender/ui';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
-
declare const CategoryNavItem: ({ category, children, navigate }: {
|
|
4
|
+
declare const CategoryNavItem: ({ index, category, children, navigate, scrollToIndex }: {
|
|
5
|
+
index?: number;
|
|
5
6
|
category: MenuCategory;
|
|
6
7
|
navigate: (route: string) => void;
|
|
7
8
|
children: (props: CategoryNavItemProps) => ReactNode;
|
|
9
|
+
scrollToIndex?: (index: number) => void;
|
|
8
10
|
}) => ReactNode;
|
|
9
11
|
export default CategoryNavItem;
|
|
@@ -2,7 +2,7 @@ import { makeImageUrl } from '@open-tender/ui';
|
|
|
2
2
|
import { useAppDispatch, useAppSelector } from '../app/hooks';
|
|
3
3
|
import { selectCurrentCategory, selectKioskApi, selectKioskConfig, setCurrentCategory } from '../slices';
|
|
4
4
|
var CategoryNavItem = function (_a) {
|
|
5
|
-
var category = _a.category, children = _a.children, navigate = _a.navigate;
|
|
5
|
+
var index = _a.index, category = _a.category, children = _a.children, navigate = _a.navigate, scrollToIndex = _a.scrollToIndex;
|
|
6
6
|
var dispatch = useAppDispatch();
|
|
7
7
|
var apiUrl = useAppSelector(selectKioskApi);
|
|
8
8
|
var current = useAppSelector(selectCurrentCategory);
|
|
@@ -13,7 +13,12 @@ var CategoryNavItem = function (_a) {
|
|
|
13
13
|
var imageUrl = makeImageUrl(category);
|
|
14
14
|
var browse = function () {
|
|
15
15
|
dispatch(setCurrentCategory(category));
|
|
16
|
-
|
|
16
|
+
if (scrollToIndex && index) {
|
|
17
|
+
scrollToIndex(index);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
navigate('/menu/category');
|
|
21
|
+
}
|
|
17
22
|
};
|
|
18
23
|
var handlers = { browse: browse };
|
|
19
24
|
if (!config)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Order } from '@open-tender/types';
|
|
2
2
|
import { ErrorMessageProps, OrderCardProps } from '@open-tender/ui';
|
|
3
3
|
import React, { ReactNode } from 'react';
|
|
4
|
-
declare const OrderCard: ({ order,
|
|
4
|
+
declare const OrderCard: ({ order, navigate, children, ErrorMessageView }: {
|
|
5
5
|
order: Order;
|
|
6
|
-
|
|
6
|
+
navigate: (route: string) => void;
|
|
7
7
|
children: (props: OrderCardProps) => ReactNode;
|
|
8
8
|
ErrorMessageView: (props: ErrorMessageProps) => ReactNode;
|
|
9
9
|
}) => React.ReactNode;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
3
2
|
import { useAppDispatch, useAppSelector } from '../app/hooks';
|
|
4
3
|
import { useOrder } from '../hooks';
|
|
5
|
-
import { selectKioskConfig, selectOrder, reorder as reorderPastOrder, openModal, selectKioskApi
|
|
4
|
+
import { selectKioskConfig, selectOrder, reorder as reorderPastOrder, openModal, selectKioskApi } from '../slices';
|
|
6
5
|
import { default as ErrorMessageContainer } from './ErrorMessage';
|
|
7
6
|
var OrderCard = function (_a) {
|
|
8
|
-
var order = _a.order,
|
|
7
|
+
var order = _a.order, navigate = _a.navigate, children = _a.children, ErrorMessageView = _a.ErrorMessageView;
|
|
9
8
|
var dispatch = useAppDispatch();
|
|
10
9
|
var apiUrl = useAppSelector(selectKioskApi);
|
|
11
10
|
var _b = useState(null), errMsg = _b[0], setErrMsg = _b[1];
|
|
@@ -15,7 +14,7 @@ var OrderCard = function (_a) {
|
|
|
15
14
|
var isLoading = loading === 'pending';
|
|
16
15
|
var _e = useOrder(order), itemImages = _e.itemImages, itemNames = _e.itemNames, orderNo = _e.orderNo, title = _e.title, subtitle = _e.subtitle;
|
|
17
16
|
var view = function () {
|
|
18
|
-
dispatch(openModal({ type: 'ORDER_DETAILS', args: { order: order
|
|
17
|
+
dispatch(openModal({ type: 'ORDER_DETAILS', args: { order: order } }));
|
|
19
18
|
};
|
|
20
19
|
var reorder = function () {
|
|
21
20
|
setErrMsg(null);
|
|
@@ -30,11 +29,10 @@ var OrderCard = function (_a) {
|
|
|
30
29
|
setErrMsg(error.detail);
|
|
31
30
|
}
|
|
32
31
|
else {
|
|
33
|
-
|
|
34
|
-
goToCheckout();
|
|
32
|
+
navigate('/checkout/details');
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
|
-
}, [
|
|
35
|
+
}, [isLoading, isReordering, error, navigate]);
|
|
38
36
|
var renderErrorMessage = useCallback(function (errMsg) { return (React.createElement(ErrorMessageContainer, { content: errMsg, children: ErrorMessageView })); }, [ErrorMessageView]);
|
|
39
37
|
if (!config)
|
|
40
38
|
return null;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Order } from '@open-tender/types';
|
|
2
2
|
import { CheckTotalsProps, OrderDetailsItemProps, OrderDetailsProps } from '@open-tender/ui';
|
|
3
3
|
import React, { ReactNode } from 'react';
|
|
4
|
-
declare const OrderDetails: ({ order, close,
|
|
4
|
+
declare const OrderDetails: ({ order, close, children, CheckTotalsView, OrderDetailsItemView }: {
|
|
5
5
|
order: Order;
|
|
6
6
|
close: () => void;
|
|
7
|
-
goToCheckout: () => void;
|
|
8
7
|
children: (props: OrderDetailsProps) => ReactNode;
|
|
9
8
|
CheckTotalsView: (props: CheckTotalsProps) => ReactNode;
|
|
10
9
|
OrderDetailsItemView: (props: OrderDetailsItemProps) => ReactNode;
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
import React, { useCallback,
|
|
2
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
1
|
+
import React, { useCallback, useState } from 'react';
|
|
3
2
|
import { useAppDispatch, useAppSelector } from '../app/hooks';
|
|
4
3
|
import { useOrder } from '../hooks';
|
|
5
|
-
import { selectKioskConfig, reorder as reorderPastOrder, selectKioskApi
|
|
4
|
+
import { selectKioskConfig, reorder as reorderPastOrder, selectKioskApi } from '../slices';
|
|
6
5
|
import { default as CheckTotalsContainer } from './CheckTotals';
|
|
7
6
|
import { default as OrderDetailsItemContainer } from './OrderDetailsItem';
|
|
8
7
|
var OrderDetails = function (_a) {
|
|
9
|
-
var order = _a.order, close = _a.close,
|
|
8
|
+
var order = _a.order, close = _a.close, children = _a.children, CheckTotalsView = _a.CheckTotalsView, OrderDetailsItemView = _a.OrderDetailsItemView;
|
|
10
9
|
var dispatch = useAppDispatch();
|
|
11
10
|
var apiUrl = useAppSelector(selectKioskApi);
|
|
12
11
|
var _b = useState(null), errMsg = _b[0], setErrMsg = _b[1];
|
|
13
12
|
var _c = useState(false), isReordering = _c[0], setIsReordering = _c[1];
|
|
14
13
|
var _d = useOrder(order), subtitle = _d.title, title = _d.orderNo, requestedAt = _d.requestedAt;
|
|
15
|
-
var _e = useAppSelector(
|
|
16
|
-
var isLoading = loading === 'pending';
|
|
17
|
-
var _f = useAppSelector(selectKioskConfig), config = _f.orderDetails, modalContentConfig = _f.modalContent;
|
|
14
|
+
var _e = useAppSelector(selectKioskConfig), config = _e.orderDetails, modalContentConfig = _e.modalContent;
|
|
18
15
|
var reorder = function () {
|
|
19
16
|
setErrMsg(null);
|
|
20
17
|
setIsReordering(true);
|
|
@@ -22,19 +19,6 @@ var OrderDetails = function (_a) {
|
|
|
22
19
|
};
|
|
23
20
|
var renderCheckTotals = useCallback(function () { return React.createElement(CheckTotalsContainer, { check: order, children: CheckTotalsView }); }, [order, CheckTotalsView]);
|
|
24
21
|
var renderOrderDetailsItem = useCallback(function (orderItem) { return (React.createElement(OrderDetailsItemContainer, { key: orderItem.id, orderItem: orderItem, children: OrderDetailsItemView })); }, [OrderDetailsItemView]);
|
|
25
|
-
useEffect(function () {
|
|
26
|
-
if (isReordering && !isLoading) {
|
|
27
|
-
setIsReordering(false);
|
|
28
|
-
if (error) {
|
|
29
|
-
setErrMsg(error.detail);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
dispatch(setOrderId(uuidv4()));
|
|
33
|
-
goToCheckout();
|
|
34
|
-
close();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}, [dispatch, isLoading, isReordering, error, goToCheckout, close]);
|
|
38
22
|
if (!config)
|
|
39
23
|
return null;
|
|
40
24
|
return children({
|
|
@@ -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,16 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { useAppDispatch, useAppSelector } from '../app/hooks';
|
|
3
|
+
import { selectKioskConfig, selectSelectedTags, selectShowTagsModal, toggleTagsModal } from '../slices';
|
|
4
|
+
var TagsButton = function (_a) {
|
|
5
|
+
var children = _a.children;
|
|
6
|
+
var config = useAppSelector(selectKioskConfig).tagsButton;
|
|
7
|
+
var isTagsModalShown = useAppSelector(selectShowTagsModal);
|
|
8
|
+
var selectedTags = useAppSelector(selectSelectedTags);
|
|
9
|
+
var dispatch = useAppDispatch();
|
|
10
|
+
var onClick = useCallback(function () {
|
|
11
|
+
dispatch(toggleTagsModal(!isTagsModalShown));
|
|
12
|
+
}, [dispatch, isTagsModalShown]);
|
|
13
|
+
var handlers = { onClick: onClick };
|
|
14
|
+
return children({ config: config, handlers: handlers, isSelected: selectedTags.length > 0 });
|
|
15
|
+
};
|
|
16
|
+
export default TagsButton;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SwitchProps, TagsFilterProps } from '@open-tender/ui';
|
|
2
|
+
import React, { ReactNode } from 'react';
|
|
3
|
+
declare const TagsFilter: ({ children, SwitchView }: {
|
|
4
|
+
children: (props: TagsFilterProps) => ReactNode;
|
|
5
|
+
SwitchView: (props: SwitchProps) => ReactNode;
|
|
6
|
+
}) => React.ReactNode;
|
|
7
|
+
export default TagsFilter;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { __spreadArray } from "tslib";
|
|
2
|
+
import { capitalize } from '@open-tender/utils';
|
|
3
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
4
|
+
import { useAppDispatch, useAppSelector } from '../app/hooks';
|
|
5
|
+
import { selectKioskConfig, selectTags, setSelectedTags, toggleTagsModal } from '../slices';
|
|
6
|
+
import { default as SwitchContainer } from './Switch';
|
|
7
|
+
var TagsFilter = function (_a) {
|
|
8
|
+
var children = _a.children, SwitchView = _a.SwitchView;
|
|
9
|
+
var config = useAppSelector(selectKioskConfig).tags;
|
|
10
|
+
var dispatch = useAppDispatch();
|
|
11
|
+
var _b = useAppSelector(selectTags), tags = _b.entities, selectedTags = _b.selectedTags, loading = _b.loading, error = _b.error, showTagsModal = _b.showTagsModal;
|
|
12
|
+
var _c = useState([]), localSelectedTags = _c[0], setLocalSelectedTags = _c[1];
|
|
13
|
+
var isLoading = loading === 'pending';
|
|
14
|
+
useEffect(function () {
|
|
15
|
+
setLocalSelectedTags(selectedTags.map(function (tag) { return tag.tag_id; }));
|
|
16
|
+
}, [selectedTags]);
|
|
17
|
+
var onTagSwitch = function (tag) {
|
|
18
|
+
setLocalSelectedTags(function (prevSelectedTags) {
|
|
19
|
+
if (prevSelectedTags.includes(tag.tag_id)) {
|
|
20
|
+
return prevSelectedTags.filter(function (id) { return id !== tag.tag_id; });
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return __spreadArray(__spreadArray([], prevSelectedTags, true), [tag.tag_id], false);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
var handleSubmit = function () {
|
|
28
|
+
var newSelectedTags = tags.filter(function (tag) {
|
|
29
|
+
return localSelectedTags.includes(tag.tag_id);
|
|
30
|
+
});
|
|
31
|
+
dispatch(setSelectedTags(newSelectedTags));
|
|
32
|
+
toggleTagsFilterModal();
|
|
33
|
+
};
|
|
34
|
+
var toggleTagsFilterModal = function () {
|
|
35
|
+
dispatch(toggleTagsModal(!showTagsModal));
|
|
36
|
+
};
|
|
37
|
+
var handlers = { onTagSwitch: onTagSwitch, handleSubmit: handleSubmit, toggleTagsFilterModal: toggleTagsFilterModal };
|
|
38
|
+
var renderSwitch = useCallback(function (tag) {
|
|
39
|
+
return (React.createElement(SwitchContainer, { key: tag.tag_id, id: tag.tag_id, children: SwitchView, label: capitalize(tag.name), on: localSelectedTags.includes(tag.tag_id), onChange: function () { return onTagSwitch(tag); }, disabled: false, isRequired: true }));
|
|
40
|
+
}, [SwitchView, localSelectedTags]);
|
|
41
|
+
return children({
|
|
42
|
+
config: config,
|
|
43
|
+
handlers: handlers,
|
|
44
|
+
isLoading: isLoading,
|
|
45
|
+
renderSwitch: renderSwitch,
|
|
46
|
+
tags: tags,
|
|
47
|
+
error: error === null || error === void 0 ? void 0 : error.detail
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
export default TagsFilter;
|
|
@@ -63,8 +63,11 @@ import SignInPhone from './SignInPhone';
|
|
|
63
63
|
import SignInQr from './SignInQr';
|
|
64
64
|
import SignUp from './SignUp';
|
|
65
65
|
import SuccessMessage from './SuccessMessage';
|
|
66
|
+
import Switch from './Switch';
|
|
66
67
|
import Tag from './Tag';
|
|
68
|
+
import TagsButton from './TagsButton';
|
|
69
|
+
import TagsFilter from './TagsFilter';
|
|
67
70
|
import TextArea from './TextArea';
|
|
68
71
|
import UpsellItem from './UpsellItem';
|
|
69
72
|
import Upsells from './Upsells';
|
|
70
|
-
export { AccountLoyalty, AccountSection, Allergen, Applied, ButtonLink, CancelButton, Card, Cart, CartButton, CartItem, CartUpsellItem, CartUpsells, CategoryItem, CategoryNav, CategoryNavItem, CategoryNavOther, Checkout, CheckoutCart, CheckoutContent, CheckoutFooter, CheckoutHeader, CheckoutPromoCode, CheckoutTotals, CheckTotals, Discount, ErrorMessage, FavsButton, Header, Ingredients, Input, InputButton, ItemGroup, ItemGroups, ItemOption, ItemOptionSelected, ItemSize, ItemSelections, Keypad, Loader, MadeForName, MadeForNotes, MenuCategory, MenuOther, ModalContent, ModalHeader, NutritionalInfo, Option, OrderCard, OrderDetails, OrderDetailsItem, PointsReward, PointsRewards, PromoCode, Quantity, Reward, Rewards, SignIn, SignInButton, SignInCheckout, SignInOptionsModal, SignInPhone, SignInQr, SignUp, SuccessMessage, Tag, TextArea, UpsellItem, Upsells, IdleModal };
|
|
73
|
+
export { AccountLoyalty, AccountSection, Allergen, Applied, ButtonLink, CancelButton, Card, Cart, CartButton, CartItem, CartUpsellItem, CartUpsells, CategoryItem, CategoryNav, CategoryNavItem, CategoryNavOther, Checkout, CheckoutCart, CheckoutContent, CheckoutFooter, CheckoutHeader, CheckoutPromoCode, CheckoutTotals, CheckTotals, Discount, ErrorMessage, FavsButton, Header, Ingredients, Input, InputButton, ItemGroup, ItemGroups, ItemOption, ItemOptionSelected, ItemSize, ItemSelections, Keypad, Loader, MadeForName, MadeForNotes, MenuCategory, MenuOther, ModalContent, ModalHeader, NutritionalInfo, Option, OrderCard, OrderDetails, OrderDetailsItem, PointsReward, PointsRewards, PromoCode, Quantity, Reward, Rewards, SignIn, SignInButton, SignInCheckout, SignInOptionsModal, SignInPhone, SignInQr, SignUp, SuccessMessage, Tag, TextArea, UpsellItem, Upsells, IdleModal, TagsFilter, Switch, TagsButton };
|
|
@@ -63,8 +63,11 @@ import SignInPhone from './SignInPhone';
|
|
|
63
63
|
import SignInQr from './SignInQr';
|
|
64
64
|
import SignUp from './SignUp';
|
|
65
65
|
import SuccessMessage from './SuccessMessage';
|
|
66
|
+
import Switch from './Switch';
|
|
66
67
|
import Tag from './Tag';
|
|
68
|
+
import TagsButton from './TagsButton';
|
|
69
|
+
import TagsFilter from './TagsFilter';
|
|
67
70
|
import TextArea from './TextArea';
|
|
68
71
|
import UpsellItem from './UpsellItem';
|
|
69
72
|
import Upsells from './Upsells';
|
|
70
|
-
export { AccountLoyalty, AccountSection, Allergen, Applied, ButtonLink, CancelButton, Card, Cart, CartButton, CartItem, CartUpsellItem, CartUpsells, CategoryItem, CategoryNav, CategoryNavItem, CategoryNavOther, Checkout, CheckoutCart, CheckoutContent, CheckoutFooter, CheckoutHeader, CheckoutPromoCode, CheckoutTotals, CheckTotals, Discount, ErrorMessage, FavsButton, Header, Ingredients, Input, InputButton, ItemGroup, ItemGroups, ItemOption, ItemOptionSelected, ItemSize, ItemSelections, Keypad, Loader, MadeForName, MadeForNotes, MenuCategory, MenuOther, ModalContent, ModalHeader, NutritionalInfo, Option, OrderCard, OrderDetails, OrderDetailsItem, PointsReward, PointsRewards, PromoCode, Quantity, Reward, Rewards, SignIn, SignInButton, SignInCheckout, SignInOptionsModal, SignInPhone, SignInQr, SignUp, SuccessMessage, Tag, TextArea, UpsellItem, Upsells, IdleModal };
|
|
73
|
+
export { AccountLoyalty, AccountSection, Allergen, Applied, ButtonLink, CancelButton, Card, Cart, CartButton, CartItem, CartUpsellItem, CartUpsells, CategoryItem, CategoryNav, CategoryNavItem, CategoryNavOther, Checkout, CheckoutCart, CheckoutContent, CheckoutFooter, CheckoutHeader, CheckoutPromoCode, CheckoutTotals, CheckTotals, Discount, ErrorMessage, FavsButton, Header, Ingredients, Input, InputButton, ItemGroup, ItemGroups, ItemOption, ItemOptionSelected, ItemSize, ItemSelections, Keypad, Loader, MadeForName, MadeForNotes, MenuCategory, MenuOther, ModalContent, ModalHeader, NutritionalInfo, Option, OrderCard, OrderDetails, OrderDetailsItem, PointsReward, PointsRewards, PromoCode, Quantity, Reward, Rewards, SignIn, SignInButton, SignInCheckout, SignInOptionsModal, SignInPhone, SignInQr, SignUp, SuccessMessage, Tag, TextArea, UpsellItem, Upsells, IdleModal, TagsFilter, Switch, TagsButton };
|
|
@@ -9,12 +9,12 @@ var useOrderValidate = function () {
|
|
|
9
9
|
var checkout = useAppSelector(selectPosCheckout);
|
|
10
10
|
var order = useAppSelector(selectOrder);
|
|
11
11
|
var preparedOrder = prepareOrder(order, checkout);
|
|
12
|
-
var
|
|
13
|
-
var prevOrderCheckout = usePrevious(
|
|
12
|
+
var ordeCheckout = __rest(preparedOrder || {}, []);
|
|
13
|
+
var prevOrderCheckout = usePrevious(ordeCheckout);
|
|
14
14
|
useEffect(function () {
|
|
15
|
-
if (preparedOrder && !isEqual(prevOrderCheckout,
|
|
15
|
+
if (preparedOrder && !isEqual(prevOrderCheckout, ordeCheckout)) {
|
|
16
16
|
dispatch(validatePosOrder());
|
|
17
17
|
}
|
|
18
|
-
}, [dispatch, preparedOrder, prevOrderCheckout,
|
|
18
|
+
}, [dispatch, preparedOrder, prevOrderCheckout, ordeCheckout]);
|
|
19
19
|
};
|
|
20
20
|
export default useOrderValidate;
|
|
@@ -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;
|