@open-tender/cloud 0.1.12 → 0.1.13
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AppState } from '../../app';
|
|
2
|
-
import {
|
|
2
|
+
import { CreditCardData, CreditCards, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
3
|
export interface CustomerCreditCardsState {
|
|
4
4
|
entities: CreditCards;
|
|
5
5
|
error: RequestError;
|
|
@@ -26,7 +26,7 @@ export declare const fetchCustomerCreditCards: import("@reduxjs/toolkit").AsyncT
|
|
|
26
26
|
}>;
|
|
27
27
|
export declare const updateCustomerCreditCard: import("@reduxjs/toolkit").AsyncThunk<CreditCards, {
|
|
28
28
|
cardId: number;
|
|
29
|
-
data:
|
|
29
|
+
data: CreditCardData;
|
|
30
30
|
callback?: (() => void) | undefined;
|
|
31
31
|
}, {
|
|
32
32
|
state: AppState;
|
|
@@ -52,7 +52,7 @@ export declare const removeCustomerCreditCard: import("@reduxjs/toolkit").AsyncT
|
|
|
52
52
|
rejectedMeta?: unknown;
|
|
53
53
|
}>;
|
|
54
54
|
export declare const addCustomerCreditCard: import("@reduxjs/toolkit").AsyncThunk<CreditCards, {
|
|
55
|
-
data:
|
|
55
|
+
data: CreditCardData;
|
|
56
56
|
callback?: (() => void) | undefined;
|
|
57
57
|
}, {
|
|
58
58
|
state: AppState;
|
|
@@ -66,5 +66,5 @@ export declare const addCustomerCreditCard: import("@reduxjs/toolkit").AsyncThun
|
|
|
66
66
|
}>;
|
|
67
67
|
export declare const resetCustomerCreditCards: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"creditCards/resetCustomerCreditCards">, resetCustomerCreditCardsError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"creditCards/resetCustomerCreditCardsError">, setCustomerCreditCards: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "creditCards/setCustomerCreditCards">;
|
|
68
68
|
export declare const selectCustomerCreditCards: (state: AppState) => CustomerCreditCardsState;
|
|
69
|
-
export declare const selectCustomerCreditCardsForPayment: (state: AppState) => CreditCard[];
|
|
69
|
+
export declare const selectCustomerCreditCardsForPayment: (state: AppState) => import("@open-tender/types").CreditCard[];
|
|
70
70
|
export declare const customerCreditCardsReducer: import("redux").Reducer<CustomerCreditCardsState, import("redux").AnyAction>;
|
|
@@ -35,18 +35,18 @@ exports.fetchCustomerCreditCards = (0, toolkit_1.createAsyncThunk)(CustomerCredi
|
|
|
35
35
|
return (0, account_1.checkAuth)(error, dispatch, () => rejectWithValue(error));
|
|
36
36
|
}
|
|
37
37
|
}));
|
|
38
|
-
exports.updateCustomerCreditCard = (0, toolkit_1.createAsyncThunk)(CustomerCreditCardsActionType.UpdateCustomerCreditCard, (
|
|
38
|
+
exports.updateCustomerCreditCard = (0, toolkit_1.createAsyncThunk)(CustomerCreditCardsActionType.UpdateCustomerCreditCard, ({ cardId, data, callback }, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
39
39
|
try {
|
|
40
40
|
const api = getState().config.api;
|
|
41
41
|
const token = (0, account_1.selectToken)(getState());
|
|
42
42
|
if (!token)
|
|
43
43
|
throw new Error(types_2.MISSING_CUSTOMER);
|
|
44
|
-
yield api.putCustomerCreditCard(token,
|
|
44
|
+
yield api.putCustomerCreditCard(token, cardId, data);
|
|
45
45
|
const includeLinked = true;
|
|
46
46
|
const creditCards = yield api.getCustomerCreditCards(token, includeLinked);
|
|
47
47
|
dispatch((0, notifications_1.showNotification)('Credit card updated!'));
|
|
48
|
-
if (
|
|
49
|
-
|
|
48
|
+
if (callback)
|
|
49
|
+
callback();
|
|
50
50
|
return creditCards;
|
|
51
51
|
}
|
|
52
52
|
catch (err) {
|
|
@@ -54,18 +54,18 @@ exports.updateCustomerCreditCard = (0, toolkit_1.createAsyncThunk)(CustomerCredi
|
|
|
54
54
|
return (0, account_1.checkAuth)(error, dispatch, () => rejectWithValue(error));
|
|
55
55
|
}
|
|
56
56
|
}));
|
|
57
|
-
exports.removeCustomerCreditCard = (0, toolkit_1.createAsyncThunk)(CustomerCreditCardsActionType.RemoveCustomerCreditCard, (
|
|
57
|
+
exports.removeCustomerCreditCard = (0, toolkit_1.createAsyncThunk)(CustomerCreditCardsActionType.RemoveCustomerCreditCard, ({ cardId, callback }, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
58
58
|
try {
|
|
59
59
|
const api = getState().config.api;
|
|
60
60
|
const token = (0, account_1.selectToken)(getState());
|
|
61
61
|
if (!token)
|
|
62
62
|
throw new Error(types_2.MISSING_CUSTOMER);
|
|
63
|
-
yield api.deleteCustomerCreditCard(token,
|
|
63
|
+
yield api.deleteCustomerCreditCard(token, cardId);
|
|
64
64
|
const includeLinked = true;
|
|
65
65
|
const creditCards = yield api.getCustomerCreditCards(token, includeLinked);
|
|
66
66
|
dispatch((0, notifications_1.showNotification)('Credit card removed!'));
|
|
67
|
-
if (
|
|
68
|
-
|
|
67
|
+
if (callback)
|
|
68
|
+
callback();
|
|
69
69
|
return creditCards;
|
|
70
70
|
}
|
|
71
71
|
catch (err) {
|
|
@@ -73,18 +73,18 @@ exports.removeCustomerCreditCard = (0, toolkit_1.createAsyncThunk)(CustomerCredi
|
|
|
73
73
|
return (0, account_1.checkAuth)(error, dispatch, () => rejectWithValue(error));
|
|
74
74
|
}
|
|
75
75
|
}));
|
|
76
|
-
exports.addCustomerCreditCard = (0, toolkit_1.createAsyncThunk)(CustomerCreditCardsActionType.AddCustomerCreditCard, (
|
|
76
|
+
exports.addCustomerCreditCard = (0, toolkit_1.createAsyncThunk)(CustomerCreditCardsActionType.AddCustomerCreditCard, ({ data, callback }, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
77
77
|
try {
|
|
78
78
|
const api = getState().config.api;
|
|
79
79
|
const token = (0, account_1.selectToken)(getState());
|
|
80
80
|
if (!token)
|
|
81
81
|
throw new Error(types_2.MISSING_CUSTOMER);
|
|
82
|
-
yield api.postCustomerCreditCard(token,
|
|
82
|
+
yield api.postCustomerCreditCard(token, data);
|
|
83
83
|
const includeLinked = true;
|
|
84
84
|
const creditCards = yield api.getCustomerCreditCards(token, includeLinked);
|
|
85
85
|
dispatch((0, notifications_1.showNotification)('Credit card added!'));
|
|
86
|
-
if (
|
|
87
|
-
|
|
86
|
+
if (callback)
|
|
87
|
+
callback();
|
|
88
88
|
return creditCards;
|
|
89
89
|
}
|
|
90
90
|
catch (err) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AppState } from '../../app';
|
|
2
|
-
import {
|
|
2
|
+
import { CreditCardData, CreditCards, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
3
|
export interface CustomerCreditCardsState {
|
|
4
4
|
entities: CreditCards;
|
|
5
5
|
error: RequestError;
|
|
@@ -26,7 +26,7 @@ export declare const fetchCustomerCreditCards: import("@reduxjs/toolkit").AsyncT
|
|
|
26
26
|
}>;
|
|
27
27
|
export declare const updateCustomerCreditCard: import("@reduxjs/toolkit").AsyncThunk<CreditCards, {
|
|
28
28
|
cardId: number;
|
|
29
|
-
data:
|
|
29
|
+
data: CreditCardData;
|
|
30
30
|
callback?: (() => void) | undefined;
|
|
31
31
|
}, {
|
|
32
32
|
state: AppState;
|
|
@@ -52,7 +52,7 @@ export declare const removeCustomerCreditCard: import("@reduxjs/toolkit").AsyncT
|
|
|
52
52
|
rejectedMeta?: unknown;
|
|
53
53
|
}>;
|
|
54
54
|
export declare const addCustomerCreditCard: import("@reduxjs/toolkit").AsyncThunk<CreditCards, {
|
|
55
|
-
data:
|
|
55
|
+
data: CreditCardData;
|
|
56
56
|
callback?: (() => void) | undefined;
|
|
57
57
|
}, {
|
|
58
58
|
state: AppState;
|
|
@@ -66,5 +66,5 @@ export declare const addCustomerCreditCard: import("@reduxjs/toolkit").AsyncThun
|
|
|
66
66
|
}>;
|
|
67
67
|
export declare const resetCustomerCreditCards: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"creditCards/resetCustomerCreditCards">, resetCustomerCreditCardsError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"creditCards/resetCustomerCreditCardsError">, setCustomerCreditCards: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "creditCards/setCustomerCreditCards">;
|
|
68
68
|
export declare const selectCustomerCreditCards: (state: AppState) => CustomerCreditCardsState;
|
|
69
|
-
export declare const selectCustomerCreditCardsForPayment: (state: AppState) => CreditCard[];
|
|
69
|
+
export declare const selectCustomerCreditCardsForPayment: (state: AppState) => import("@open-tender/types").CreditCard[];
|
|
70
70
|
export declare const customerCreditCardsReducer: import("redux").Reducer<CustomerCreditCardsState, import("redux").AnyAction>;
|
|
@@ -31,18 +31,18 @@ export const fetchCustomerCreditCards = createAsyncThunk(CustomerCreditCardsActi
|
|
|
31
31
|
return checkAuth(error, dispatch, () => rejectWithValue(error));
|
|
32
32
|
}
|
|
33
33
|
}));
|
|
34
|
-
export const updateCustomerCreditCard = createAsyncThunk(CustomerCreditCardsActionType.UpdateCustomerCreditCard, (
|
|
34
|
+
export const updateCustomerCreditCard = createAsyncThunk(CustomerCreditCardsActionType.UpdateCustomerCreditCard, ({ cardId, data, callback }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
35
|
try {
|
|
36
36
|
const api = getState().config.api;
|
|
37
37
|
const token = selectToken(getState());
|
|
38
38
|
if (!token)
|
|
39
39
|
throw new Error(MISSING_CUSTOMER);
|
|
40
|
-
yield api.putCustomerCreditCard(token,
|
|
40
|
+
yield api.putCustomerCreditCard(token, cardId, data);
|
|
41
41
|
const includeLinked = true;
|
|
42
42
|
const creditCards = yield api.getCustomerCreditCards(token, includeLinked);
|
|
43
43
|
dispatch(showNotification('Credit card updated!'));
|
|
44
|
-
if (
|
|
45
|
-
|
|
44
|
+
if (callback)
|
|
45
|
+
callback();
|
|
46
46
|
return creditCards;
|
|
47
47
|
}
|
|
48
48
|
catch (err) {
|
|
@@ -50,18 +50,18 @@ export const updateCustomerCreditCard = createAsyncThunk(CustomerCreditCardsActi
|
|
|
50
50
|
return checkAuth(error, dispatch, () => rejectWithValue(error));
|
|
51
51
|
}
|
|
52
52
|
}));
|
|
53
|
-
export const removeCustomerCreditCard = createAsyncThunk(CustomerCreditCardsActionType.RemoveCustomerCreditCard, (
|
|
53
|
+
export const removeCustomerCreditCard = createAsyncThunk(CustomerCreditCardsActionType.RemoveCustomerCreditCard, ({ cardId, callback }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
54
|
try {
|
|
55
55
|
const api = getState().config.api;
|
|
56
56
|
const token = selectToken(getState());
|
|
57
57
|
if (!token)
|
|
58
58
|
throw new Error(MISSING_CUSTOMER);
|
|
59
|
-
yield api.deleteCustomerCreditCard(token,
|
|
59
|
+
yield api.deleteCustomerCreditCard(token, cardId);
|
|
60
60
|
const includeLinked = true;
|
|
61
61
|
const creditCards = yield api.getCustomerCreditCards(token, includeLinked);
|
|
62
62
|
dispatch(showNotification('Credit card removed!'));
|
|
63
|
-
if (
|
|
64
|
-
|
|
63
|
+
if (callback)
|
|
64
|
+
callback();
|
|
65
65
|
return creditCards;
|
|
66
66
|
}
|
|
67
67
|
catch (err) {
|
|
@@ -69,18 +69,18 @@ export const removeCustomerCreditCard = createAsyncThunk(CustomerCreditCardsActi
|
|
|
69
69
|
return checkAuth(error, dispatch, () => rejectWithValue(error));
|
|
70
70
|
}
|
|
71
71
|
}));
|
|
72
|
-
export const addCustomerCreditCard = createAsyncThunk(CustomerCreditCardsActionType.AddCustomerCreditCard, (
|
|
72
|
+
export const addCustomerCreditCard = createAsyncThunk(CustomerCreditCardsActionType.AddCustomerCreditCard, ({ data, callback }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
73
|
try {
|
|
74
74
|
const api = getState().config.api;
|
|
75
75
|
const token = selectToken(getState());
|
|
76
76
|
if (!token)
|
|
77
77
|
throw new Error(MISSING_CUSTOMER);
|
|
78
|
-
yield api.postCustomerCreditCard(token,
|
|
78
|
+
yield api.postCustomerCreditCard(token, data);
|
|
79
79
|
const includeLinked = true;
|
|
80
80
|
const creditCards = yield api.getCustomerCreditCards(token, includeLinked);
|
|
81
81
|
dispatch(showNotification('Credit card added!'));
|
|
82
|
-
if (
|
|
83
|
-
|
|
82
|
+
if (callback)
|
|
83
|
+
callback();
|
|
84
84
|
return creditCards;
|
|
85
85
|
}
|
|
86
86
|
catch (err) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/cloud",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
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",
|