@open-tender/cloud 0.3.2 → 0.3.4
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/services/api.d.ts +2 -0
- package/dist/cjs/services/api.js +6 -0
- package/dist/cjs/slices/checkout.js +3 -1
- package/dist/cjs/slices/customer/loyalty.d.ts +1 -1
- package/dist/cjs/slices/customer/loyalty.js +9 -5
- package/dist/esm/services/api.d.ts +2 -0
- package/dist/esm/services/api.js +6 -0
- package/dist/esm/slices/checkout.js +3 -1
- package/dist/esm/slices/customer/loyalty.d.ts +1 -1
- package/dist/esm/slices/customer/loyalty.js +9 -5
- package/package.json +3 -3
- package/dist/.DS_Store +0 -0
|
@@ -113,6 +113,7 @@ declare class OpenTenderAPI {
|
|
|
113
113
|
postResetPassword(new_password: string, token: string): Promise<unknown>;
|
|
114
114
|
getCustomer(token: string): Promise<unknown>;
|
|
115
115
|
putCustomer(token: string, data: any): Promise<unknown>;
|
|
116
|
+
deleteCustomer(token: string): Promise<void | null | undefined>;
|
|
116
117
|
postCustomerPosToken(token: string, posToken: string): Promise<unknown>;
|
|
117
118
|
postSendVerificationEmail(token: string, linkUrl: string): Promise<unknown>;
|
|
118
119
|
postVerifyAccount(verifyToken: string): Promise<unknown>;
|
|
@@ -156,6 +157,7 @@ declare class OpenTenderAPI {
|
|
|
156
157
|
getCustomerFcmToken(token: string): Promise<unknown>;
|
|
157
158
|
deleteCustomerFcmToken(token: string): Promise<unknown>;
|
|
158
159
|
getCustomerLoyalty(token: string): Promise<unknown>;
|
|
160
|
+
getCustomerLoyaltyV2(token: string): Promise<unknown>;
|
|
159
161
|
getCustomerThanx(token: string): Promise<unknown>;
|
|
160
162
|
getThanxCardSignature(token: string, acct: string): Promise<unknown>;
|
|
161
163
|
getCustomerTpls(token: string): Promise<unknown>;
|
package/dist/cjs/services/api.js
CHANGED
|
@@ -541,6 +541,9 @@ class OpenTenderAPI {
|
|
|
541
541
|
putCustomer(token, data) {
|
|
542
542
|
return this.request(`/customer`, 'PUT', data, null, token);
|
|
543
543
|
}
|
|
544
|
+
deleteCustomer(token) {
|
|
545
|
+
return this.request(`/customer`, 'DELETE', null, null, token);
|
|
546
|
+
}
|
|
544
547
|
postCustomerPosToken(token, posToken) {
|
|
545
548
|
const data = { pos_token: posToken };
|
|
546
549
|
return this.request(`/customer/pos-token`, 'POST', data, null, token);
|
|
@@ -684,6 +687,9 @@ class OpenTenderAPI {
|
|
|
684
687
|
getCustomerLoyalty(token) {
|
|
685
688
|
return this.request(`/customer/loyalty`, 'GET', null, null, token);
|
|
686
689
|
}
|
|
690
|
+
getCustomerLoyaltyV2(token) {
|
|
691
|
+
return this.request(`/v2/customer/loyalty`, 'GET', null, null, token);
|
|
692
|
+
}
|
|
687
693
|
getCustomerThanx(token) {
|
|
688
694
|
return this.request(`/customer/thanx`, 'GET', null, null, token);
|
|
689
695
|
}
|
|
@@ -40,8 +40,9 @@ const assembleOrder = (orderData, save = false) => {
|
|
|
40
40
|
const { revenue_center_id: revenueCenterId } = revenueCenter || {};
|
|
41
41
|
if (!revenueCenterId || !serviceType || !requestedAt || !cart)
|
|
42
42
|
return null;
|
|
43
|
-
const { form } = checkout;
|
|
43
|
+
const { form, check } = checkout;
|
|
44
44
|
const { customer, address, details, surcharges, discounts, promoCodes, points, tenders, tip } = form;
|
|
45
|
+
const { deposit = null } = check || {};
|
|
45
46
|
// const defaultTip = check ? getDefaultTip(check.config) : null
|
|
46
47
|
const fullAddress = Object.assign(Object.assign({}, order.address), address);
|
|
47
48
|
const data = {
|
|
@@ -49,6 +50,7 @@ const assembleOrder = (orderData, save = false) => {
|
|
|
49
50
|
cart: cart,
|
|
50
51
|
cartId: groupOrder.cartId || null,
|
|
51
52
|
customer,
|
|
53
|
+
deposit,
|
|
52
54
|
details,
|
|
53
55
|
deviceType,
|
|
54
56
|
discounts,
|
|
@@ -169,6 +169,6 @@ export declare const selectCustomerPointsProgram: (orderType: OrderType | null)
|
|
|
169
169
|
}> & {
|
|
170
170
|
clearCache: () => void;
|
|
171
171
|
};
|
|
172
|
-
export declare const selectCustomerPoints: (orderType: OrderType | null) => (state: AppState) =>
|
|
172
|
+
export declare const selectCustomerPoints: (orderType: OrderType | null) => (state: AppState) => `${number}.${number}` | null | undefined;
|
|
173
173
|
export declare const selectPointsProgram: (state: AppState) => import("@open-tender/types").LoyaltyProgram | null;
|
|
174
174
|
export declare const customerLoyaltyReducer: import("redux").Reducer<CustomerLoyaltyState, import("redux").AnyAction>;
|
|
@@ -23,7 +23,7 @@ exports.fetchCustomerLoyalty = (0, toolkit_1.createAsyncThunk)(CustomerLoyaltyAc
|
|
|
23
23
|
const token = (0, account_1.selectToken)(getState());
|
|
24
24
|
if (!token)
|
|
25
25
|
throw new Error(types_2.MISSING_CUSTOMER);
|
|
26
|
-
return yield api.
|
|
26
|
+
return yield api.getCustomerLoyaltyV2(token);
|
|
27
27
|
}
|
|
28
28
|
catch (err) {
|
|
29
29
|
const error = err;
|
|
@@ -67,7 +67,7 @@ exports.selectCustomerLoyaltyProgram = (0, toolkit_1.createSelector)((state) =>
|
|
|
67
67
|
const { entities, loading, error } = state.customer.loyalty;
|
|
68
68
|
return { entities, loading, error };
|
|
69
69
|
}, ({ entities, loading, error }) => {
|
|
70
|
-
const programs = entities.filter(i => i.
|
|
70
|
+
const programs = entities.filter(i => i.earn_order_type === null || i.earn_order_type === 'OLO');
|
|
71
71
|
const program = programs.length ? programs[0] : null;
|
|
72
72
|
return { program, loading, error };
|
|
73
73
|
});
|
|
@@ -78,14 +78,18 @@ const selectCustomerPointsProgram = (orderType) => (0, toolkit_1.createSelector)
|
|
|
78
78
|
}, ({ loyaltyPrograms }) => {
|
|
79
79
|
if (!loyaltyPrograms)
|
|
80
80
|
return null;
|
|
81
|
-
const programs = loyaltyPrograms.filter(i =>
|
|
82
|
-
|
|
81
|
+
const programs = loyaltyPrograms.filter(i => {
|
|
82
|
+
var _a;
|
|
83
|
+
return ((_a = i.perk) === null || _a === void 0 ? void 0 : _a.loyalty_perk) === 'BANKABLE_POINTS' &&
|
|
84
|
+
(i.earn_order_type === null || i.earn_order_type === orderType);
|
|
85
|
+
});
|
|
83
86
|
return programs.length ? programs[0] : null;
|
|
84
87
|
});
|
|
85
88
|
exports.selectCustomerPointsProgram = selectCustomerPointsProgram;
|
|
86
89
|
const selectCustomerPoints = (orderType) => (state) => {
|
|
90
|
+
var _a;
|
|
87
91
|
const program = (0, exports.selectCustomerPointsProgram)(orderType)(state);
|
|
88
|
-
return program ? program.
|
|
92
|
+
return program ? (_a = program.perk) === null || _a === void 0 ? void 0 : _a.credit : null;
|
|
89
93
|
};
|
|
90
94
|
exports.selectCustomerPoints = selectCustomerPoints;
|
|
91
95
|
const selectPointsProgram = (state) => {
|
|
@@ -113,6 +113,7 @@ declare class OpenTenderAPI {
|
|
|
113
113
|
postResetPassword(new_password: string, token: string): Promise<unknown>;
|
|
114
114
|
getCustomer(token: string): Promise<unknown>;
|
|
115
115
|
putCustomer(token: string, data: any): Promise<unknown>;
|
|
116
|
+
deleteCustomer(token: string): Promise<void | null | undefined>;
|
|
116
117
|
postCustomerPosToken(token: string, posToken: string): Promise<unknown>;
|
|
117
118
|
postSendVerificationEmail(token: string, linkUrl: string): Promise<unknown>;
|
|
118
119
|
postVerifyAccount(verifyToken: string): Promise<unknown>;
|
|
@@ -156,6 +157,7 @@ declare class OpenTenderAPI {
|
|
|
156
157
|
getCustomerFcmToken(token: string): Promise<unknown>;
|
|
157
158
|
deleteCustomerFcmToken(token: string): Promise<unknown>;
|
|
158
159
|
getCustomerLoyalty(token: string): Promise<unknown>;
|
|
160
|
+
getCustomerLoyaltyV2(token: string): Promise<unknown>;
|
|
159
161
|
getCustomerThanx(token: string): Promise<unknown>;
|
|
160
162
|
getThanxCardSignature(token: string, acct: string): Promise<unknown>;
|
|
161
163
|
getCustomerTpls(token: string): Promise<unknown>;
|
package/dist/esm/services/api.js
CHANGED
|
@@ -539,6 +539,9 @@ class OpenTenderAPI {
|
|
|
539
539
|
putCustomer(token, data) {
|
|
540
540
|
return this.request(`/customer`, 'PUT', data, null, token);
|
|
541
541
|
}
|
|
542
|
+
deleteCustomer(token) {
|
|
543
|
+
return this.request(`/customer`, 'DELETE', null, null, token);
|
|
544
|
+
}
|
|
542
545
|
postCustomerPosToken(token, posToken) {
|
|
543
546
|
const data = { pos_token: posToken };
|
|
544
547
|
return this.request(`/customer/pos-token`, 'POST', data, null, token);
|
|
@@ -682,6 +685,9 @@ class OpenTenderAPI {
|
|
|
682
685
|
getCustomerLoyalty(token) {
|
|
683
686
|
return this.request(`/customer/loyalty`, 'GET', null, null, token);
|
|
684
687
|
}
|
|
688
|
+
getCustomerLoyaltyV2(token) {
|
|
689
|
+
return this.request(`/v2/customer/loyalty`, 'GET', null, null, token);
|
|
690
|
+
}
|
|
685
691
|
getCustomerThanx(token) {
|
|
686
692
|
return this.request(`/customer/thanx`, 'GET', null, null, token);
|
|
687
693
|
}
|
|
@@ -36,8 +36,9 @@ const assembleOrder = (orderData, save = false) => {
|
|
|
36
36
|
const { revenue_center_id: revenueCenterId } = revenueCenter || {};
|
|
37
37
|
if (!revenueCenterId || !serviceType || !requestedAt || !cart)
|
|
38
38
|
return null;
|
|
39
|
-
const { form } = checkout;
|
|
39
|
+
const { form, check } = checkout;
|
|
40
40
|
const { customer, address, details, surcharges, discounts, promoCodes, points, tenders, tip } = form;
|
|
41
|
+
const { deposit = null } = check || {};
|
|
41
42
|
// const defaultTip = check ? getDefaultTip(check.config) : null
|
|
42
43
|
const fullAddress = Object.assign(Object.assign({}, order.address), address);
|
|
43
44
|
const data = {
|
|
@@ -45,6 +46,7 @@ const assembleOrder = (orderData, save = false) => {
|
|
|
45
46
|
cart: cart,
|
|
46
47
|
cartId: groupOrder.cartId || null,
|
|
47
48
|
customer,
|
|
49
|
+
deposit,
|
|
48
50
|
details,
|
|
49
51
|
deviceType,
|
|
50
52
|
discounts,
|
|
@@ -169,6 +169,6 @@ export declare const selectCustomerPointsProgram: (orderType: OrderType | null)
|
|
|
169
169
|
}> & {
|
|
170
170
|
clearCache: () => void;
|
|
171
171
|
};
|
|
172
|
-
export declare const selectCustomerPoints: (orderType: OrderType | null) => (state: AppState) =>
|
|
172
|
+
export declare const selectCustomerPoints: (orderType: OrderType | null) => (state: AppState) => `${number}.${number}` | null | undefined;
|
|
173
173
|
export declare const selectPointsProgram: (state: AppState) => import("@open-tender/types").LoyaltyProgram | null;
|
|
174
174
|
export declare const customerLoyaltyReducer: import("redux").Reducer<CustomerLoyaltyState, import("redux").AnyAction>;
|
|
@@ -19,7 +19,7 @@ export const fetchCustomerLoyalty = createAsyncThunk(CustomerLoyaltyActionType.F
|
|
|
19
19
|
const token = selectToken(getState());
|
|
20
20
|
if (!token)
|
|
21
21
|
throw new Error(MISSING_CUSTOMER);
|
|
22
|
-
return yield api.
|
|
22
|
+
return yield api.getCustomerLoyaltyV2(token);
|
|
23
23
|
}
|
|
24
24
|
catch (err) {
|
|
25
25
|
const error = err;
|
|
@@ -62,7 +62,7 @@ export const selectCustomerLoyaltyProgram = createSelector((state) => {
|
|
|
62
62
|
const { entities, loading, error } = state.customer.loyalty;
|
|
63
63
|
return { entities, loading, error };
|
|
64
64
|
}, ({ entities, loading, error }) => {
|
|
65
|
-
const programs = entities.filter(i => i.
|
|
65
|
+
const programs = entities.filter(i => i.earn_order_type === null || i.earn_order_type === 'OLO');
|
|
66
66
|
const program = programs.length ? programs[0] : null;
|
|
67
67
|
return { program, loading, error };
|
|
68
68
|
});
|
|
@@ -73,13 +73,17 @@ export const selectCustomerPointsProgram = (orderType) => createSelector((state)
|
|
|
73
73
|
}, ({ loyaltyPrograms }) => {
|
|
74
74
|
if (!loyaltyPrograms)
|
|
75
75
|
return null;
|
|
76
|
-
const programs = loyaltyPrograms.filter(i =>
|
|
77
|
-
|
|
76
|
+
const programs = loyaltyPrograms.filter(i => {
|
|
77
|
+
var _a;
|
|
78
|
+
return ((_a = i.perk) === null || _a === void 0 ? void 0 : _a.loyalty_perk) === 'BANKABLE_POINTS' &&
|
|
79
|
+
(i.earn_order_type === null || i.earn_order_type === orderType);
|
|
80
|
+
});
|
|
78
81
|
return programs.length ? programs[0] : null;
|
|
79
82
|
});
|
|
80
83
|
export const selectCustomerPoints = (orderType) => (state) => {
|
|
84
|
+
var _a;
|
|
81
85
|
const program = selectCustomerPointsProgram(orderType)(state);
|
|
82
|
-
return program ? program.
|
|
86
|
+
return program ? (_a = program.perk) === null || _a === void 0 ? void 0 : _a.credit : null;
|
|
83
87
|
};
|
|
84
88
|
export const selectPointsProgram = (state) => {
|
|
85
89
|
const { orderType } = state.order;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/cloud",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
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",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"typescript": "^4.8.2"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@open-tender/types": "^0.3.
|
|
53
|
-
"@open-tender/utils": "^0.3.
|
|
52
|
+
"@open-tender/types": "^0.3.15",
|
|
53
|
+
"@open-tender/utils": "^0.3.10",
|
|
54
54
|
"@reduxjs/toolkit": "^1.8.5",
|
|
55
55
|
"react": "^18.2.0"
|
|
56
56
|
}
|
package/dist/.DS_Store
DELETED
|
Binary file
|