@open-tender/cloud 0.0.119 → 0.0.120
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.
|
@@ -35,3 +35,29 @@ export declare const addCustomerLevelUp: import("@reduxjs/toolkit").AsyncThunk<L
|
|
|
35
35
|
export declare const resetCustomerLevelUp: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setCustomerLevelUp: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>;
|
|
36
36
|
export declare const selectCustomerLevelUp: (state: AppState) => CustomerLevelUpState;
|
|
37
37
|
export declare const customerLevelUpReducer: import("redux").Reducer<CustomerLevelUpState, import("redux").AnyAction>;
|
|
38
|
+
export declare const makeLevelUpProgram: (user: any) => {
|
|
39
|
+
name: any;
|
|
40
|
+
description: any;
|
|
41
|
+
progress: number;
|
|
42
|
+
spend: any;
|
|
43
|
+
remaining: string;
|
|
44
|
+
threshold: any;
|
|
45
|
+
credit: any;
|
|
46
|
+
towards: string;
|
|
47
|
+
rewards: never[];
|
|
48
|
+
} | null;
|
|
49
|
+
export declare const selectCustomerLevelUpProgram: (state: AppState) => {
|
|
50
|
+
program: {
|
|
51
|
+
name: any;
|
|
52
|
+
description: any;
|
|
53
|
+
progress: number;
|
|
54
|
+
spend: any;
|
|
55
|
+
remaining: string;
|
|
56
|
+
threshold: any;
|
|
57
|
+
credit: any;
|
|
58
|
+
towards: string;
|
|
59
|
+
rewards: never[];
|
|
60
|
+
} | null;
|
|
61
|
+
loading: RequestStatus;
|
|
62
|
+
error: RequestError;
|
|
63
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.customerLevelUpReducer = exports.selectCustomerLevelUp = exports.setCustomerLevelUp = exports.resetCustomerLevelUp = exports.addCustomerLevelUp = exports.removeCustomerLevelUp = exports.fetchCustomerLevelUp = exports.CustomerLevelUpActionType = void 0;
|
|
4
|
+
exports.selectCustomerLevelUpProgram = exports.makeLevelUpProgram = exports.customerLevelUpReducer = exports.selectCustomerLevelUp = exports.setCustomerLevelUp = exports.resetCustomerLevelUp = exports.addCustomerLevelUp = exports.removeCustomerLevelUp = exports.fetchCustomerLevelUp = exports.CustomerLevelUpActionType = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
7
7
|
const types_1 = require("../types");
|
|
@@ -153,3 +153,32 @@ _a = customerLevelUpSlice.actions, exports.resetCustomerLevelUp = _a.resetCustom
|
|
|
153
153
|
const selectCustomerLevelUp = (state) => state.customer.levelup;
|
|
154
154
|
exports.selectCustomerLevelUp = selectCustomerLevelUp;
|
|
155
155
|
exports.customerLevelUpReducer = customerLevelUpSlice.reducer;
|
|
156
|
+
const makeLevelUpProgram = (user) => {
|
|
157
|
+
if (!user.program)
|
|
158
|
+
return null;
|
|
159
|
+
let { spend, credit, threshold } = user.program;
|
|
160
|
+
const { name, description, reward } = user.program;
|
|
161
|
+
credit = parseFloat(credit);
|
|
162
|
+
spend = parseFloat(spend);
|
|
163
|
+
threshold = parseFloat(threshold);
|
|
164
|
+
const remaining = threshold - spend;
|
|
165
|
+
const progress = ((spend / threshold) * 100);
|
|
166
|
+
return {
|
|
167
|
+
name,
|
|
168
|
+
description,
|
|
169
|
+
progress,
|
|
170
|
+
spend: spend.toFixed(2),
|
|
171
|
+
remaining: remaining.toFixed(2),
|
|
172
|
+
threshold: threshold.toFixed(2),
|
|
173
|
+
credit: credit.toFixed(2),
|
|
174
|
+
towards: `$${reward} off your order`,
|
|
175
|
+
rewards: [],
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
exports.makeLevelUpProgram = makeLevelUpProgram;
|
|
179
|
+
const selectCustomerLevelUpProgram = (state) => {
|
|
180
|
+
const { entities, loading, error } = state.customer.levelup;
|
|
181
|
+
const program = entities.length ? (0, exports.makeLevelUpProgram)(entities[0]) : null;
|
|
182
|
+
return { program, loading, error };
|
|
183
|
+
};
|
|
184
|
+
exports.selectCustomerLevelUpProgram = selectCustomerLevelUpProgram;
|
|
@@ -35,3 +35,29 @@ export declare const addCustomerLevelUp: import("@reduxjs/toolkit").AsyncThunk<L
|
|
|
35
35
|
export declare const resetCustomerLevelUp: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setCustomerLevelUp: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>;
|
|
36
36
|
export declare const selectCustomerLevelUp: (state: AppState) => CustomerLevelUpState;
|
|
37
37
|
export declare const customerLevelUpReducer: import("redux").Reducer<CustomerLevelUpState, import("redux").AnyAction>;
|
|
38
|
+
export declare const makeLevelUpProgram: (user: any) => {
|
|
39
|
+
name: any;
|
|
40
|
+
description: any;
|
|
41
|
+
progress: number;
|
|
42
|
+
spend: any;
|
|
43
|
+
remaining: string;
|
|
44
|
+
threshold: any;
|
|
45
|
+
credit: any;
|
|
46
|
+
towards: string;
|
|
47
|
+
rewards: never[];
|
|
48
|
+
} | null;
|
|
49
|
+
export declare const selectCustomerLevelUpProgram: (state: AppState) => {
|
|
50
|
+
program: {
|
|
51
|
+
name: any;
|
|
52
|
+
description: any;
|
|
53
|
+
progress: number;
|
|
54
|
+
spend: any;
|
|
55
|
+
remaining: string;
|
|
56
|
+
threshold: any;
|
|
57
|
+
credit: any;
|
|
58
|
+
towards: string;
|
|
59
|
+
rewards: never[];
|
|
60
|
+
} | null;
|
|
61
|
+
loading: RequestStatus;
|
|
62
|
+
error: RequestError;
|
|
63
|
+
};
|
|
@@ -148,3 +148,30 @@ const customerLevelUpSlice = createSlice({
|
|
|
148
148
|
export const { resetCustomerLevelUp, setCustomerLevelUp } = customerLevelUpSlice.actions;
|
|
149
149
|
export const selectCustomerLevelUp = (state) => state.customer.levelup;
|
|
150
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
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/cloud",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.120",
|
|
4
4
|
"description": "A library of hooks, reducers, utility functions, and types for use with Open Tender applications that utilize our cloud-based Order API.",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"react": "^18.2.0"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@open-tender/types": "^0.0.
|
|
58
|
+
"@open-tender/types": "^0.0.122",
|
|
59
59
|
"@open-tender/utils": "^0.0.46"
|
|
60
60
|
}
|
|
61
61
|
}
|