@open-tender/store 1.1.176 → 1.1.178

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.
Files changed (55) hide show
  1. package/dist/cjs/app/hooks.d.ts +0 -1
  2. package/dist/cjs/app/store.d.ts +0 -4
  3. package/dist/cjs/app/store.js +1 -2
  4. package/dist/cjs/components/OrderCard.d.ts +2 -2
  5. package/dist/cjs/components/OrderCard.js +5 -3
  6. package/dist/cjs/components/SignInPhone.js +1 -0
  7. package/dist/cjs/components/index.d.ts +1 -4
  8. package/dist/cjs/components/index.js +1 -7
  9. package/dist/cjs/hooks/useOrderValidate.js +4 -4
  10. package/dist/cjs/services/api.d.ts +1 -2
  11. package/dist/cjs/services/api.js +0 -3
  12. package/dist/cjs/slices/customer.d.ts +0 -1
  13. package/dist/cjs/slices/index.d.ts +0 -1
  14. package/dist/cjs/slices/index.js +0 -1
  15. package/dist/cjs/slices/kiosk.d.ts +0 -7
  16. package/dist/cjs/slices/menuPages.d.ts +0 -1
  17. package/dist/cjs/slices/order.d.ts +0 -4
  18. package/dist/cjs/slices/types.d.ts +1 -2
  19. package/dist/cjs/slices/types.js +0 -1
  20. package/dist/esm/app/hooks.d.ts +0 -1
  21. package/dist/esm/app/store.d.ts +0 -4
  22. package/dist/esm/app/store.js +2 -3
  23. package/dist/esm/components/OrderCard.d.ts +2 -2
  24. package/dist/esm/components/OrderCard.js +6 -4
  25. package/dist/esm/components/SignInPhone.js +1 -0
  26. package/dist/esm/components/index.d.ts +1 -4
  27. package/dist/esm/components/index.js +1 -4
  28. package/dist/esm/hooks/useOrderValidate.js +4 -4
  29. package/dist/esm/services/api.d.ts +1 -2
  30. package/dist/esm/services/api.js +0 -3
  31. package/dist/esm/slices/customer.d.ts +0 -1
  32. package/dist/esm/slices/index.d.ts +0 -1
  33. package/dist/esm/slices/index.js +0 -1
  34. package/dist/esm/slices/kiosk.d.ts +0 -7
  35. package/dist/esm/slices/menuPages.d.ts +0 -1
  36. package/dist/esm/slices/order.d.ts +0 -4
  37. package/dist/esm/slices/types.d.ts +1 -2
  38. package/dist/esm/slices/types.js +0 -1
  39. package/package.json +1 -1
  40. package/dist/cjs/components/Switch.d.ts +0 -15
  41. package/dist/cjs/components/Switch.js +0 -23
  42. package/dist/cjs/components/TagsButton.d.ts +0 -6
  43. package/dist/cjs/components/TagsButton.js +0 -18
  44. package/dist/cjs/components/TagsFilter.d.ts +0 -7
  45. package/dist/cjs/components/TagsFilter.js +0 -52
  46. package/dist/cjs/slices/tags.d.ts +0 -86
  47. package/dist/cjs/slices/tags.js +0 -87
  48. package/dist/esm/components/Switch.d.ts +0 -15
  49. package/dist/esm/components/Switch.js +0 -21
  50. package/dist/esm/components/TagsButton.d.ts +0 -6
  51. package/dist/esm/components/TagsButton.js +0 -16
  52. package/dist/esm/components/TagsFilter.d.ts +0 -7
  53. package/dist/esm/components/TagsFilter.js +0 -50
  54. package/dist/esm/slices/tags.d.ts +0 -86
  55. package/dist/esm/slices/tags.js +0 -81
@@ -27,6 +27,5 @@ export declare enum ReducerType {
27
27
  Sidebar = "sidebar",
28
28
  Surcharges = "surcharges",
29
29
  Taxes = "taxes",
30
- Idle = "idle",
31
- Tags = "tags"
30
+ Idle = "idle"
32
31
  }
@@ -29,5 +29,4 @@ export var ReducerType;
29
29
  ReducerType["Surcharges"] = "surcharges";
30
30
  ReducerType["Taxes"] = "taxes";
31
31
  ReducerType["Idle"] = "idle";
32
- ReducerType["Tags"] = "tags";
33
32
  })(ReducerType || (ReducerType = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/store",
3
- "version": "1.1.176",
3
+ "version": "1.1.178",
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",
@@ -1,15 +0,0 @@
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;
@@ -1,23 +0,0 @@
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;
@@ -1,6 +0,0 @@
1
- import { TagsButtonProps } from '@open-tender/ui';
2
- import { ReactNode } from 'react';
3
- declare const TagsButton: ({ children }: {
4
- children: (props: TagsButtonProps) => ReactNode;
5
- }) => ReactNode;
6
- export default TagsButton;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var react_1 = require("react");
4
- var hooks_1 = require("../app/hooks");
5
- var slices_1 = require("../slices");
6
- var TagsButton = function (_a) {
7
- var children = _a.children;
8
- var config = (0, hooks_1.useAppSelector)(slices_1.selectKioskConfig).tag;
9
- var isTagsModalShown = (0, hooks_1.useAppSelector)(slices_1.selectShowTagsModal);
10
- var selectedTags = (0, hooks_1.useAppSelector)(slices_1.selectSelectedTags);
11
- var dispatch = (0, hooks_1.useAppDispatch)();
12
- var onClick = (0, react_1.useCallback)(function () {
13
- dispatch((0, slices_1.toggleTagsModal)(!isTagsModalShown));
14
- }, [dispatch, isTagsModalShown]);
15
- var handlers = { onClick: onClick };
16
- return children({ config: config, handlers: handlers, isSelected: selectedTags.length > 0 });
17
- };
18
- exports.default = TagsButton;
@@ -1,7 +0,0 @@
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;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var utils_1 = require("@open-tender/utils");
5
- var react_1 = tslib_1.__importStar(require("react"));
6
- var hooks_1 = require("../app/hooks");
7
- var slices_1 = require("../slices");
8
- var Switch_1 = tslib_1.__importDefault(require("./Switch"));
9
- var TagsFilter = function (_a) {
10
- var children = _a.children, SwitchView = _a.SwitchView;
11
- var config = (0, hooks_1.useAppSelector)(slices_1.selectKioskConfig).tags;
12
- var dispatch = (0, hooks_1.useAppDispatch)();
13
- var _b = (0, hooks_1.useAppSelector)(slices_1.selectTags), tags = _b.entities, selectedTags = _b.selectedTags, loading = _b.loading, error = _b.error, showTagsModal = _b.showTagsModal;
14
- var _c = (0, react_1.useState)([]), localSelectedTags = _c[0], setLocalSelectedTags = _c[1];
15
- var isLoading = loading === 'pending';
16
- (0, react_1.useEffect)(function () {
17
- setLocalSelectedTags(selectedTags.map(function (tag) { return tag.tag_id; }));
18
- }, [selectedTags]);
19
- var onTagSwitch = function (tag) {
20
- setLocalSelectedTags(function (prevSelectedTags) {
21
- if (prevSelectedTags.includes(tag.tag_id)) {
22
- return prevSelectedTags.filter(function (id) { return id !== tag.tag_id; });
23
- }
24
- else {
25
- return tslib_1.__spreadArray(tslib_1.__spreadArray([], prevSelectedTags, true), [tag.tag_id], false);
26
- }
27
- });
28
- };
29
- var handleSubmit = function () {
30
- var newSelectedTags = tags.filter(function (tag) {
31
- return localSelectedTags.includes(tag.tag_id);
32
- });
33
- dispatch((0, slices_1.setSelectedTags)(newSelectedTags));
34
- toggleTagsFilterModal();
35
- };
36
- var toggleTagsFilterModal = function () {
37
- dispatch((0, slices_1.toggleTagsModal)(!showTagsModal));
38
- };
39
- var handlers = { onTagSwitch: onTagSwitch, handleSubmit: handleSubmit, toggleTagsFilterModal: toggleTagsFilterModal };
40
- var renderSwitch = (0, react_1.useCallback)(function (tag) {
41
- return (react_1.default.createElement(Switch_1.default, { key: tag.tag_id, id: tag.tag_id, children: SwitchView, label: (0, utils_1.capitalize)(tag.name), on: localSelectedTags.includes(tag.tag_id), onChange: function () { return onTagSwitch(tag); }, disabled: false, isRequired: true }));
42
- }, [SwitchView, localSelectedTags]);
43
- return children({
44
- config: config,
45
- handlers: handlers,
46
- isLoading: isLoading,
47
- renderSwitch: renderSwitch,
48
- tags: tags,
49
- error: error === null || error === void 0 ? void 0 : error.detail
50
- });
51
- };
52
- exports.default = TagsFilter;
@@ -1,86 +0,0 @@
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
- showTagsModal: boolean;
9
- }
10
- export declare enum TagsActionType {
11
- FetchTags = "tags/fetchTags"
12
- }
13
- export declare const fetchTags: import("@reduxjs/toolkit").AsyncThunk<Tags, void, {
14
- state: AppState;
15
- rejectValue: RequestError;
16
- dispatch?: import("redux").Dispatch<import("redux").UnknownAction> | undefined;
17
- extra?: unknown;
18
- serializedErrorType?: unknown;
19
- pendingMeta?: unknown;
20
- fulfilledMeta?: unknown;
21
- rejectedMeta?: unknown;
22
- }>;
23
- export declare const resetTags: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"tags/resetTags">, setSelectedTags: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "tags/setSelectedTags">, toggleTagsModal: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "tags/toggleTagsModal">;
24
- export declare const selectTags: (state: AppState) => TagsState;
25
- export declare const selectSelectedTags: (state: AppState) => Tags;
26
- export declare const selectShowTagsModal: (state: AppState) => boolean;
27
- export declare const selectSelectedTagNames: ((state: {
28
- alerts: import("@open-tender/types").Alerts;
29
- arrivals: import("./arrivals").ArrivalsState;
30
- cartSummary: import("./cartSummary").CartSummaryState;
31
- checkout: import("./checkout").CheckoutState;
32
- config: import("./config").ConfigState;
33
- customer: import("./customer").CustomerState;
34
- customerIdentify: import("./customerIdentify").CustomerIdentifyState;
35
- deals: import("./deals").DealsState;
36
- discounts: import("./discounts").DiscountsState;
37
- errorAlerts: import("./errorAlerts").ErrorAlertsState;
38
- kds: import("./kds").KdsState;
39
- kiosk: import("./kiosk").KioskState;
40
- menu: import("./menu").MenuState;
41
- menuPages: import("./menuPages").MenuPagesState;
42
- modal: import("./modal").ModalState;
43
- notifications: import("@open-tender/types").Notifications;
44
- offlineAuths: import("./offlineAuths").OfflineAuthsState;
45
- order: import("./order").OrderState;
46
- pos: import("./pos").PosState;
47
- punches: import("./punches").PunchesState;
48
- refund: import("./refund").RefundState;
49
- sendReceipt: import("./sendReceipt").SendReceiptState;
50
- settings: import("./settings").SettingsState;
51
- sidebar: import("./sidebar").SidebarState;
52
- surcharges: import("./surcharges").SurchargesState;
53
- taxes: import("./taxes").TaxesState;
54
- idle: import("./idle").IdleState;
55
- tags: TagsState;
56
- }) => string[]) & {
57
- clearCache: () => void;
58
- resultsCount: () => number;
59
- resetResultsCount: () => void;
60
- } & {
61
- resultFunc: (resultFuncArgs_0: {
62
- tags: Tags;
63
- selectedTags: Tags;
64
- }) => string[];
65
- memoizedResultFunc: ((resultFuncArgs_0: {
66
- tags: Tags;
67
- selectedTags: Tags;
68
- }) => string[]) & {
69
- clearCache: () => void;
70
- resultsCount: () => number;
71
- resetResultsCount: () => void;
72
- };
73
- lastResult: () => string[];
74
- dependencies: [(state: AppState) => {
75
- tags: Tags;
76
- selectedTags: Tags;
77
- }];
78
- recomputations: () => number;
79
- resetRecomputations: () => void;
80
- dependencyRecomputations: () => number;
81
- resetDependencyRecomputations: () => void;
82
- } & {
83
- argsMemoize: typeof import("reselect").weakMapMemoize;
84
- memoize: typeof import("reselect").weakMapMemoize;
85
- };
86
- export declare const tagsReducer: import("redux").Reducer<TagsState>;
@@ -1,87 +0,0 @@
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;
@@ -1,15 +0,0 @@
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;
@@ -1,21 +0,0 @@
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;
@@ -1,6 +0,0 @@
1
- import { TagsButtonProps } from '@open-tender/ui';
2
- import { ReactNode } from 'react';
3
- declare const TagsButton: ({ children }: {
4
- children: (props: TagsButtonProps) => ReactNode;
5
- }) => ReactNode;
6
- export default TagsButton;
@@ -1,16 +0,0 @@
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).tag;
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;
@@ -1,7 +0,0 @@
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;
@@ -1,50 +0,0 @@
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;
@@ -1,86 +0,0 @@
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
- showTagsModal: boolean;
9
- }
10
- export declare enum TagsActionType {
11
- FetchTags = "tags/fetchTags"
12
- }
13
- export declare const fetchTags: import("@reduxjs/toolkit").AsyncThunk<Tags, void, {
14
- state: AppState;
15
- rejectValue: RequestError;
16
- dispatch?: import("redux").Dispatch<import("redux").UnknownAction> | undefined;
17
- extra?: unknown;
18
- serializedErrorType?: unknown;
19
- pendingMeta?: unknown;
20
- fulfilledMeta?: unknown;
21
- rejectedMeta?: unknown;
22
- }>;
23
- export declare const resetTags: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"tags/resetTags">, setSelectedTags: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "tags/setSelectedTags">, toggleTagsModal: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "tags/toggleTagsModal">;
24
- export declare const selectTags: (state: AppState) => TagsState;
25
- export declare const selectSelectedTags: (state: AppState) => Tags;
26
- export declare const selectShowTagsModal: (state: AppState) => boolean;
27
- export declare const selectSelectedTagNames: ((state: {
28
- alerts: import("@open-tender/types").Alerts;
29
- arrivals: import("./arrivals").ArrivalsState;
30
- cartSummary: import("./cartSummary").CartSummaryState;
31
- checkout: import("./checkout").CheckoutState;
32
- config: import("./config").ConfigState;
33
- customer: import("./customer").CustomerState;
34
- customerIdentify: import("./customerIdentify").CustomerIdentifyState;
35
- deals: import("./deals").DealsState;
36
- discounts: import("./discounts").DiscountsState;
37
- errorAlerts: import("./errorAlerts").ErrorAlertsState;
38
- kds: import("./kds").KdsState;
39
- kiosk: import("./kiosk").KioskState;
40
- menu: import("./menu").MenuState;
41
- menuPages: import("./menuPages").MenuPagesState;
42
- modal: import("./modal").ModalState;
43
- notifications: import("@open-tender/types").Notifications;
44
- offlineAuths: import("./offlineAuths").OfflineAuthsState;
45
- order: import("./order").OrderState;
46
- pos: import("./pos").PosState;
47
- punches: import("./punches").PunchesState;
48
- refund: import("./refund").RefundState;
49
- sendReceipt: import("./sendReceipt").SendReceiptState;
50
- settings: import("./settings").SettingsState;
51
- sidebar: import("./sidebar").SidebarState;
52
- surcharges: import("./surcharges").SurchargesState;
53
- taxes: import("./taxes").TaxesState;
54
- idle: import("./idle").IdleState;
55
- tags: TagsState;
56
- }) => string[]) & {
57
- clearCache: () => void;
58
- resultsCount: () => number;
59
- resetResultsCount: () => void;
60
- } & {
61
- resultFunc: (resultFuncArgs_0: {
62
- tags: Tags;
63
- selectedTags: Tags;
64
- }) => string[];
65
- memoizedResultFunc: ((resultFuncArgs_0: {
66
- tags: Tags;
67
- selectedTags: Tags;
68
- }) => string[]) & {
69
- clearCache: () => void;
70
- resultsCount: () => number;
71
- resetResultsCount: () => void;
72
- };
73
- lastResult: () => string[];
74
- dependencies: [(state: AppState) => {
75
- tags: Tags;
76
- selectedTags: Tags;
77
- }];
78
- recomputations: () => number;
79
- resetRecomputations: () => void;
80
- dependencyRecomputations: () => number;
81
- resetDependencyRecomputations: () => void;
82
- } & {
83
- argsMemoize: typeof import("reselect").weakMapMemoize;
84
- memoize: typeof import("reselect").weakMapMemoize;
85
- };
86
- export declare const tagsReducer: import("redux").Reducer<TagsState>;
@@ -1,81 +0,0 @@
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
- showTagsModal: false
11
- };
12
- export var TagsActionType;
13
- (function (TagsActionType) {
14
- TagsActionType["FetchTags"] = "tags/fetchTags";
15
- })(TagsActionType || (TagsActionType = {}));
16
- export var fetchTags = createAsyncThunk(TagsActionType.FetchTags, function (_1, _a) { return __awaiter(void 0, [_1, _a], void 0, function (_, _b) {
17
- var api, data, err_1;
18
- var getState = _b.getState, rejectWithValue = _b.rejectWithValue;
19
- return __generator(this, function (_c) {
20
- switch (_c.label) {
21
- case 0:
22
- _c.trys.push([0, 2, , 3]);
23
- api = getState().config.api;
24
- return [4 /*yield*/, api.getTags()];
25
- case 1:
26
- data = _c.sent();
27
- return [2 /*return*/, data];
28
- case 2:
29
- err_1 = _c.sent();
30
- return [2 /*return*/, rejectWithValue(err_1)];
31
- case 3: return [2 /*return*/];
32
- }
33
- });
34
- }); });
35
- var tagsSlice = createSlice({
36
- name: ReducerType.Tags,
37
- initialState: initialState,
38
- reducers: {
39
- resetTags: function () { return initialState; },
40
- setSelectedTags: function (state, action) {
41
- state.selectedTags = action.payload;
42
- },
43
- toggleTagsModal: function (state, action) {
44
- state.showTagsModal = action.payload;
45
- }
46
- },
47
- extraReducers: function (builder) {
48
- builder
49
- .addCase(fetchTags.fulfilled, function (state, action) {
50
- state.entities = action.payload;
51
- state.loading = 'idle';
52
- state.error = null;
53
- })
54
- .addCase(fetchTags.pending, function (state) {
55
- state.loading = 'pending';
56
- })
57
- .addCase(fetchTags.rejected, function (state, action) {
58
- state.error = action.payload;
59
- state.loading = 'idle';
60
- });
61
- }
62
- });
63
- export var resetTags = (_a = tagsSlice.actions, _a.resetTags), setSelectedTags = _a.setSelectedTags, toggleTagsModal = _a.toggleTagsModal;
64
- export var selectTags = function (state) { return state.tags; };
65
- export var selectSelectedTags = function (state) { return state.tags.selectedTags; };
66
- export var selectShowTagsModal = function (state) { return state.tags.showTagsModal; };
67
- export var selectSelectedTagNames = 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
- export var tagsReducer = tagsSlice.reducer;