@open-tender/cloud 0.1.59 → 0.1.60

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 (42) hide show
  1. package/dist/cjs/app/hooks.d.ts +0 -2
  2. package/dist/cjs/app/store.d.ts +0 -6
  3. package/dist/cjs/app/store.js +0 -1
  4. package/dist/cjs/services/api.d.ts +0 -5
  5. package/dist/cjs/services/api.js +0 -15
  6. package/dist/cjs/slices/allergens.d.ts +0 -2
  7. package/dist/cjs/slices/customer/account.d.ts +2 -2
  8. package/dist/cjs/slices/customer/account.js +13 -14
  9. package/dist/cjs/slices/customer/index.d.ts +0 -2
  10. package/dist/cjs/slices/customer/index.js +1 -4
  11. package/dist/cjs/slices/index.d.ts +0 -1
  12. package/dist/cjs/slices/index.js +0 -1
  13. package/dist/cjs/slices/order.d.ts +0 -6
  14. package/dist/cjs/slices/tags.d.ts +0 -2
  15. package/dist/cjs/slices/types.d.ts +0 -1
  16. package/dist/cjs/slices/types.js +0 -1
  17. package/dist/esm/app/hooks.d.ts +0 -2
  18. package/dist/esm/app/store.d.ts +0 -6
  19. package/dist/esm/app/store.js +1 -2
  20. package/dist/esm/services/api.d.ts +0 -5
  21. package/dist/esm/services/api.js +0 -15
  22. package/dist/esm/slices/allergens.d.ts +0 -2
  23. package/dist/esm/slices/customer/account.d.ts +2 -2
  24. package/dist/esm/slices/customer/account.js +12 -13
  25. package/dist/esm/slices/customer/index.d.ts +0 -2
  26. package/dist/esm/slices/customer/index.js +1 -4
  27. package/dist/esm/slices/index.d.ts +0 -1
  28. package/dist/esm/slices/index.js +0 -1
  29. package/dist/esm/slices/order.d.ts +0 -6
  30. package/dist/esm/slices/tags.d.ts +0 -2
  31. package/dist/esm/slices/types.d.ts +0 -1
  32. package/dist/esm/slices/types.js +0 -1
  33. package/package.json +3 -3
  34. package/dist/.DS_Store +0 -0
  35. package/dist/cjs/slices/customer/levelup.d.ts +0 -81
  36. package/dist/cjs/slices/customer/levelup.js +0 -184
  37. package/dist/cjs/slices/levelup.d.ts +0 -25
  38. package/dist/cjs/slices/levelup.js +0 -55
  39. package/dist/esm/slices/customer/levelup.d.ts +0 -81
  40. package/dist/esm/slices/customer/levelup.js +0 -177
  41. package/dist/esm/slices/levelup.d.ts +0 -25
  42. package/dist/esm/slices/levelup.js +0 -50
@@ -1,81 +0,0 @@
1
- import { AppState } from '../../app';
2
- import { LevelUp, RequestError, RequestStatus } from '@open-tender/types';
3
- export interface CustomerLevelUpState {
4
- entities: LevelUp[];
5
- error: RequestError;
6
- loading: RequestStatus;
7
- lookup: {
8
- [key: number | string]: number;
9
- };
10
- levelup?: any;
11
- }
12
- export declare enum CustomerLevelUpActionType {
13
- FetchCustomerLevelUp = "customer/fetchCustomerLevelUp",
14
- RemoveCustomerLevelUp = "customer/removeCustomerLevelUp",
15
- AddCustomerLevelUp = "customer/addCustomerLevelUp"
16
- }
17
- export declare const fetchCustomerLevelUp: import("@reduxjs/toolkit").AsyncThunk<LevelUp[], void, {
18
- state: AppState;
19
- rejectValue: RequestError;
20
- dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
21
- extra?: unknown;
22
- serializedErrorType?: unknown;
23
- pendingMeta?: unknown;
24
- fulfilledMeta?: unknown;
25
- rejectedMeta?: unknown;
26
- }>;
27
- export declare const removeCustomerLevelUp: import("@reduxjs/toolkit").AsyncThunk<LevelUp[], {
28
- levelupConnectId: number;
29
- callback?: (() => void) | undefined;
30
- }, {
31
- state: AppState;
32
- rejectValue: RequestError;
33
- dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
34
- extra?: unknown;
35
- serializedErrorType?: unknown;
36
- pendingMeta?: unknown;
37
- fulfilledMeta?: unknown;
38
- rejectedMeta?: unknown;
39
- }>;
40
- export declare const addCustomerLevelUp: import("@reduxjs/toolkit").AsyncThunk<LevelUp[], {
41
- data: LevelUp;
42
- callback?: (() => void) | undefined;
43
- }, {
44
- state: AppState;
45
- rejectValue: RequestError;
46
- dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
47
- extra?: unknown;
48
- serializedErrorType?: unknown;
49
- pendingMeta?: unknown;
50
- fulfilledMeta?: unknown;
51
- rejectedMeta?: unknown;
52
- }>;
53
- export declare const resetCustomerLevelUp: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"levelup/resetCustomerLevelUp">, setCustomerLevelUp: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "levelup/setCustomerLevelUp">, resetCustomerLevelUpError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"levelup/resetCustomerLevelUpError">;
54
- export declare const selectCustomerLevelUp: (state: AppState) => CustomerLevelUpState;
55
- export declare const customerLevelUpReducer: import("redux").Reducer<CustomerLevelUpState, import("redux").AnyAction>;
56
- export declare const makeLevelUpProgram: (user: any) => {
57
- name: any;
58
- description: any;
59
- progress: number;
60
- spend: any;
61
- remaining: string;
62
- threshold: any;
63
- credit: any;
64
- towards: string;
65
- rewards: never[];
66
- } | null;
67
- export declare const selectCustomerLevelUpProgram: (state: AppState) => {
68
- program: {
69
- name: any;
70
- description: any;
71
- progress: number;
72
- spend: any;
73
- remaining: string;
74
- threshold: any;
75
- credit: any;
76
- towards: string;
77
- rewards: never[];
78
- } | null;
79
- loading: RequestStatus;
80
- error: RequestError;
81
- };
@@ -1,177 +0,0 @@
1
- import { __awaiter } from "tslib";
2
- import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
3
- import { ReducerType } from '../types';
4
- import { MISSING_CUSTOMER } from '@open-tender/types';
5
- import { checkAuth, selectToken } from './account';
6
- import { showNotification } from '../notifications';
7
- const initialState = {
8
- entities: [],
9
- lookup: {},
10
- loading: 'idle',
11
- error: null
12
- };
13
- export var CustomerLevelUpActionType;
14
- (function (CustomerLevelUpActionType) {
15
- CustomerLevelUpActionType["FetchCustomerLevelUp"] = "customer/fetchCustomerLevelUp";
16
- CustomerLevelUpActionType["RemoveCustomerLevelUp"] = "customer/removeCustomerLevelUp";
17
- CustomerLevelUpActionType["AddCustomerLevelUp"] = "customer/addCustomerLevelUp";
18
- })(CustomerLevelUpActionType || (CustomerLevelUpActionType = {}));
19
- export const fetchCustomerLevelUp = createAsyncThunk(CustomerLevelUpActionType.FetchCustomerLevelUp, (_, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
20
- try {
21
- const api = getState().config.api;
22
- const token = selectToken(getState());
23
- if (!token)
24
- throw new Error(MISSING_CUSTOMER);
25
- const levelup = yield api.getCustomerLevelUp(token);
26
- return levelup;
27
- }
28
- catch (err) {
29
- const error = err;
30
- return checkAuth(error, dispatch, () => rejectWithValue(error));
31
- }
32
- }));
33
- export const removeCustomerLevelUp = createAsyncThunk(CustomerLevelUpActionType.RemoveCustomerLevelUp, (requestData, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
34
- try {
35
- const api = getState().config.api;
36
- const token = selectToken(getState());
37
- if (!token)
38
- throw new Error(MISSING_CUSTOMER);
39
- yield api.deleteCustomerLevelUp(token, requestData.levelupConnectId);
40
- dispatch(showNotification('LevelUp disconnected!'));
41
- if (requestData.callback)
42
- requestData.callback();
43
- return [];
44
- }
45
- catch (err) {
46
- const error = err;
47
- return checkAuth(error, dispatch, () => rejectWithValue(error));
48
- }
49
- }));
50
- export const addCustomerLevelUp = createAsyncThunk(CustomerLevelUpActionType.AddCustomerLevelUp, (requestData, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
51
- try {
52
- const api = getState().config.api;
53
- const token = selectToken(getState());
54
- if (!token)
55
- throw new Error(MISSING_CUSTOMER);
56
- const response = yield api.postCustomerLevelUp(token, requestData.data);
57
- dispatch(showNotification('LevelUp connected!'));
58
- if (requestData.callback)
59
- requestData.callback();
60
- return [response];
61
- }
62
- catch (err) {
63
- const error = err;
64
- return checkAuth(error, dispatch, () => rejectWithValue(error));
65
- }
66
- }));
67
- // export const fetchLevelUpCustomer = createAsyncThunk<
68
- // Array<LevelUp>,
69
- // { token: string; callback?: () => void },
70
- // { state: AppState; rejectValue: RequestError }
71
- // >(
72
- // CustomerLevelUpActionType.AddCustomerLevelUp,
73
- // async (requestData, { dispatch, getState, rejectWithValue }) => {
74
- // try {
75
- // const { api } = getState().config
76
- // if (!api) return
77
- // const auth = await api.postLevelUp({ token: requestData.token })
78
- // dispatch(fetchCustomer())
79
- // if (requestData.callback) requestData.callback()
80
- // return auth
81
- // } catch (err) {
82
- // return rejectWithValue(err as RequestError)
83
- // }
84
- // }
85
- // )
86
- const customerLevelUpSlice = createSlice({
87
- name: ReducerType.Levelup,
88
- initialState,
89
- reducers: {
90
- resetCustomerLevelUp: () => initialState,
91
- setCustomerLevelUp: (state, action) => {
92
- state.entities = action.payload;
93
- state.error = null;
94
- },
95
- resetCustomerLevelUpError: state => {
96
- state.error = null;
97
- state.loading = 'idle';
98
- }
99
- },
100
- extraReducers: builder => {
101
- builder
102
- .addCase(fetchCustomerLevelUp.fulfilled, (state, action) => {
103
- state.entities = action.payload;
104
- state.loading = 'idle';
105
- state.error = null;
106
- })
107
- .addCase(fetchCustomerLevelUp.pending, state => {
108
- state.loading = 'pending';
109
- })
110
- .addCase(fetchCustomerLevelUp.rejected, (state, action) => {
111
- state.error = action.payload;
112
- state.loading = 'idle';
113
- })
114
- .addCase(removeCustomerLevelUp.fulfilled, (state, action) => {
115
- state.entities = action.payload;
116
- state.loading = 'idle';
117
- state.error = null;
118
- })
119
- .addCase(removeCustomerLevelUp.pending, state => {
120
- state.loading = 'pending';
121
- })
122
- .addCase(removeCustomerLevelUp.rejected, (state, action) => {
123
- state.error = action.payload;
124
- state.loading = 'idle';
125
- })
126
- .addCase(addCustomerLevelUp.fulfilled, (state, action) => {
127
- state.entities = action.payload;
128
- state.loading = 'idle';
129
- state.error = null;
130
- })
131
- .addCase(addCustomerLevelUp.pending, state => {
132
- state.loading = 'pending';
133
- })
134
- .addCase(addCustomerLevelUp.rejected, (state, action) => {
135
- state.error = action.payload;
136
- state.loading = 'idle';
137
- });
138
- // .addCase(fetchLevelUpCustomer.fulfilled, () => initialState)
139
- // .addCase(fetchLevelUpCustomer.pending, state => {
140
- // state.loading = 'pending'
141
- // })
142
- // .addCase(fetchLevelUpCustomer.rejected, (state, action) => {
143
- // state.error = action.payload
144
- // state.loading = 'idle'
145
- // })
146
- }
147
- });
148
- export const { resetCustomerLevelUp, setCustomerLevelUp, resetCustomerLevelUpError } = customerLevelUpSlice.actions;
149
- export const selectCustomerLevelUp = (state) => state.customer.levelup;
150
- export const customerLevelUpReducer = customerLevelUpSlice.reducer;
151
- export const makeLevelUpProgram = (user) => {
152
- if (!user.program)
153
- return null;
154
- let { spend, credit, threshold } = user.program;
155
- const { name, description, reward } = user.program;
156
- credit = parseFloat(credit);
157
- spend = parseFloat(spend);
158
- threshold = parseFloat(threshold);
159
- const remaining = threshold - spend;
160
- const progress = (spend / threshold) * 100;
161
- return {
162
- name,
163
- description,
164
- progress,
165
- spend: spend.toFixed(2),
166
- remaining: remaining.toFixed(2),
167
- threshold: threshold.toFixed(2),
168
- credit: credit.toFixed(2),
169
- towards: `$${reward} off your order`,
170
- rewards: []
171
- };
172
- };
173
- export const selectCustomerLevelUpProgram = (state) => {
174
- const { entities, loading, error } = state.customer.levelup;
175
- const program = entities.length ? makeLevelUpProgram(entities[0]) : null;
176
- return { program, loading, error };
177
- };
@@ -1,25 +0,0 @@
1
- import { AppState } from '../app';
2
- import { RequestError, RequestStatus } from '@open-tender/types';
3
- export interface LevelupState {
4
- loading: RequestStatus;
5
- error: RequestError;
6
- }
7
- export declare enum LevelupActionType {
8
- FetchLevelUpCustomer = "levelup/fetchLevelUpCustomer"
9
- }
10
- export declare const fetchLevelUpCustomer: import("@reduxjs/toolkit").AsyncThunk<void, {
11
- token: string;
12
- callback?: (() => void) | undefined;
13
- }, {
14
- state: AppState;
15
- rejectValue: RequestError;
16
- dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
17
- extra?: unknown;
18
- serializedErrorType?: unknown;
19
- pendingMeta?: unknown;
20
- fulfilledMeta?: unknown;
21
- rejectedMeta?: unknown;
22
- }>;
23
- export declare const resetLevelup: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"levelup/resetLevelup">, resetLevelUpCustomer: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"levelup/resetLevelUpCustomer">;
24
- export declare const levelupReducer: import("redux").Reducer<LevelupState, import("redux").AnyAction>;
25
- export declare const selectLevelUp: (state: AppState) => LevelupState;
@@ -1,50 +0,0 @@
1
- import { __awaiter } from "tslib";
2
- import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
3
- import { ReducerType } from './types';
4
- import { fetchCustomer, fulfillLoginCustomer } from './customer';
5
- const initialState = {
6
- loading: 'idle',
7
- error: null
8
- };
9
- export var LevelupActionType;
10
- (function (LevelupActionType) {
11
- LevelupActionType["FetchLevelUpCustomer"] = "levelup/fetchLevelUpCustomer";
12
- })(LevelupActionType || (LevelupActionType = {}));
13
- export const fetchLevelUpCustomer = createAsyncThunk(LevelupActionType.FetchLevelUpCustomer, (data, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
14
- const { api } = getState().config;
15
- if (!api)
16
- return;
17
- try {
18
- const auth = yield api.postLevelUp({ token: data.token });
19
- dispatch(fulfillLoginCustomer(auth));
20
- dispatch(fetchCustomer());
21
- if (data.callback)
22
- data.callback();
23
- return;
24
- }
25
- catch (err) {
26
- return rejectWithValue(err);
27
- }
28
- }));
29
- const levelupSlice = createSlice({
30
- name: ReducerType.Levelup,
31
- initialState,
32
- reducers: {
33
- resetLevelup: () => initialState,
34
- resetLevelUpCustomer: () => initialState
35
- },
36
- extraReducers: builder => {
37
- builder
38
- .addCase(fetchLevelUpCustomer.fulfilled, () => initialState)
39
- .addCase(fetchLevelUpCustomer.pending, state => {
40
- state.loading = 'pending';
41
- })
42
- .addCase(fetchLevelUpCustomer.rejected, (state, action) => {
43
- state.loading = 'idle';
44
- state.error = action.payload;
45
- });
46
- }
47
- });
48
- export const { resetLevelup, resetLevelUpCustomer } = levelupSlice.actions;
49
- export const levelupReducer = levelupSlice.reducer;
50
- export const selectLevelUp = (state) => state.levelup;