@clicktap/state 0.8.0 → 0.9.0
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/index.esm.js +9 -3
- package/package.json +1 -1
- package/src/auth/AuthProvider.d.ts +1 -1
- package/src/quote/actions/addItems.d.ts +8 -0
- package/src/quote/actions/index.d.ts +2 -0
- package/src/quote/actions/removeItems.d.ts +8 -0
- package/src/quote/actors/addItems.d.ts +7 -0
- package/src/quote/actors/index.d.ts +3 -0
- package/src/quote/actors/refresh.d.ts +6 -0
- package/src/quote/actors/removeItems.d.ts +7 -0
- package/src/quote/guards/hasItems.d.ts +5 -0
- package/src/quote/guards/index.d.ts +1 -0
- package/src/quote/quote.d.ts +113 -0
- package/src/quote/types.d.ts +135 -0
- package/src/cart/cart.d.ts +0 -38
- package/src/cart/types.d.ts +0 -51
package/index.esm.js
CHANGED
|
@@ -488,9 +488,15 @@ var useUser = function useUser() {
|
|
|
488
488
|
*/
|
|
489
489
|
var getAuth = function getAuth() {
|
|
490
490
|
var refreshToken = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
491
|
-
var options
|
|
492
|
-
|
|
493
|
-
|
|
491
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
492
|
+
inspect: undefined,
|
|
493
|
+
endpoints: {
|
|
494
|
+
login: '',
|
|
495
|
+
logout: '',
|
|
496
|
+
refresh: '',
|
|
497
|
+
ssrRefresh: ''
|
|
498
|
+
}
|
|
499
|
+
};
|
|
494
500
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
495
501
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
496
502
|
while (1) {
|
package/package.json
CHANGED
|
@@ -290,7 +290,7 @@ type AuthOptions = {
|
|
|
290
290
|
* @todo should probably update signature to pass Partial<AuthContext> and
|
|
291
291
|
* Options, endpoints should probably be moved into context
|
|
292
292
|
*/
|
|
293
|
-
export declare const getAuth: (refreshToken
|
|
293
|
+
export declare const getAuth: (refreshToken?: string, options?: AuthOptions) => Promise<Actor<import("xstate").StateMachine<import("./auth").AuthMachineContext, import("./auth").RefreshTokenEvent | import("./auth").LoginEvent | import("./auth").LogoutEvent | import("./auth").ClearErrorsEvent | import("xstate").DoneActorEvent<import("./auth").AuthenticateSuccessEvent> | import("xstate").DoneActorEvent<import("./auth").RefreshTokenSuccessEvent>, {
|
|
294
294
|
[x: string]: import("xstate").ActorRef<import("xstate").PromiseSnapshot<{
|
|
295
295
|
type: string;
|
|
296
296
|
accessToken: string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { QuoteMachineContext, QuoteMachineEvents } from '../types';
|
|
2
|
+
export declare function addItems({ context, event, }: {
|
|
3
|
+
context: QuoteMachineContext;
|
|
4
|
+
event: QuoteMachineEvents;
|
|
5
|
+
}): QuoteMachineContext | {
|
|
6
|
+
items: Record<string, any>[];
|
|
7
|
+
};
|
|
8
|
+
export default addItems;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { QuoteMachineContext, QuoteMachineEvents } from '../types';
|
|
2
|
+
export declare function removeItems({ context, event, }: {
|
|
3
|
+
context: QuoteMachineContext;
|
|
4
|
+
event: QuoteMachineEvents;
|
|
5
|
+
}): QuoteMachineContext | {
|
|
6
|
+
items: Record<string, any>[];
|
|
7
|
+
};
|
|
8
|
+
export default removeItems;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AddItemsEvent, AddItemsSuccessEvent, QuoteMachineContext } from '../types';
|
|
2
|
+
export declare const addItems: import("xstate").PromiseActorLogic<AddItemsSuccessEvent, {
|
|
3
|
+
endpoint: QuoteMachineContext['endpoints']['addItems'];
|
|
4
|
+
items: AddItemsEvent['items'];
|
|
5
|
+
quoteId: QuoteMachineContext['quoteId'];
|
|
6
|
+
}>;
|
|
7
|
+
export default addItems;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RefreshSuccessEvent, QuoteMachineContext } from '../types';
|
|
2
|
+
export declare const refresh: import("xstate").PromiseActorLogic<RefreshSuccessEvent, {
|
|
3
|
+
endpoint: QuoteMachineContext['endpoints']['refresh'];
|
|
4
|
+
quoteId: QuoteMachineContext['quoteId'];
|
|
5
|
+
}>;
|
|
6
|
+
export default refresh;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RemoveItemsEvent, RemoveItemsSuccessEvent, QuoteMachineContext } from '../types';
|
|
2
|
+
export declare const removeItems: import("xstate").PromiseActorLogic<RemoveItemsSuccessEvent, {
|
|
3
|
+
endpoint: QuoteMachineContext['endpoints']['removeItems'];
|
|
4
|
+
items: RemoveItemsEvent['items'];
|
|
5
|
+
quoteId: QuoteMachineContext['quoteId'];
|
|
6
|
+
}>;
|
|
7
|
+
export default removeItems;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './hasItems';
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { QuoteMachineContext } from './types';
|
|
2
|
+
export declare const quoteMachine: import("xstate").StateMachine<QuoteMachineContext, import("./types").SetEmptyEvent | import("./types").SetActiveEvent | import("./types").AddItemsEvent | import("./types").RemoveItemsEvent | import("./types").ClearItemsEvent | import("./types").RefreshEvent | import("./types").ApplyPromotionEvent | import("./types").RemovePromotionEvent | import("./types").AddAddressEvent | import("./types").RemoveAddressEvent | import("./types").ApplyPaymentMethodEvent | import("./types").AddRewardEvent | import("./types").RemoveRewardEvent | import("./types").AddStoreCreditEvent | import("./types").RemoveStoreCreditEvent | import("./types").AddGiftCardEvent | import("./types").RemoveGiftCardEvent | import("xstate").DoneActorEvent<import("./types").AddItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").RemoveItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").ClearItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").RefreshSuccessEvent>, {
|
|
3
|
+
[x: string]: import("xstate").ActorRef<import("xstate").PromiseSnapshot<import("./types").AddItemsSuccessEvent, {
|
|
4
|
+
endpoint: "";
|
|
5
|
+
items: {
|
|
6
|
+
id: string;
|
|
7
|
+
quantity: number;
|
|
8
|
+
options: Record<string, any>;
|
|
9
|
+
}[];
|
|
10
|
+
quoteId: string;
|
|
11
|
+
}>, {
|
|
12
|
+
[k: string]: unknown;
|
|
13
|
+
type: string;
|
|
14
|
+
}> | import("xstate").ActorRef<import("xstate").PromiseSnapshot<import("./types").RemoveItemsSuccessEvent, {
|
|
15
|
+
endpoint: "";
|
|
16
|
+
items: {
|
|
17
|
+
id: string;
|
|
18
|
+
quantity: number;
|
|
19
|
+
}[];
|
|
20
|
+
quoteId: string;
|
|
21
|
+
}>, {
|
|
22
|
+
[k: string]: unknown;
|
|
23
|
+
type: string;
|
|
24
|
+
}> | import("xstate").ActorRef<import("xstate").PromiseSnapshot<import("./types").RefreshSuccessEvent, {
|
|
25
|
+
endpoint: "";
|
|
26
|
+
quoteId: string;
|
|
27
|
+
}>, {
|
|
28
|
+
[k: string]: unknown;
|
|
29
|
+
type: string;
|
|
30
|
+
}> | undefined;
|
|
31
|
+
}, {
|
|
32
|
+
src: "addItems";
|
|
33
|
+
logic: import("xstate").PromiseActorLogic<import("./types").AddItemsSuccessEvent, {
|
|
34
|
+
endpoint: "";
|
|
35
|
+
items: {
|
|
36
|
+
id: string;
|
|
37
|
+
quantity: number;
|
|
38
|
+
options: Record<string, any>;
|
|
39
|
+
}[];
|
|
40
|
+
quoteId: string;
|
|
41
|
+
}>;
|
|
42
|
+
id: string | undefined;
|
|
43
|
+
} | {
|
|
44
|
+
src: "removeItems";
|
|
45
|
+
logic: import("xstate").PromiseActorLogic<import("./types").RemoveItemsSuccessEvent, {
|
|
46
|
+
endpoint: "";
|
|
47
|
+
items: {
|
|
48
|
+
id: string;
|
|
49
|
+
quantity: number;
|
|
50
|
+
}[];
|
|
51
|
+
quoteId: string;
|
|
52
|
+
}>;
|
|
53
|
+
id: string | undefined;
|
|
54
|
+
} | {
|
|
55
|
+
src: "refresh";
|
|
56
|
+
logic: import("xstate").PromiseActorLogic<import("./types").RefreshSuccessEvent, {
|
|
57
|
+
endpoint: "";
|
|
58
|
+
quoteId: string;
|
|
59
|
+
}>;
|
|
60
|
+
id: string | undefined;
|
|
61
|
+
}, {
|
|
62
|
+
type: "addItems";
|
|
63
|
+
params: import("xstate").NonReducibleUnknown;
|
|
64
|
+
} | {
|
|
65
|
+
type: "removeItems";
|
|
66
|
+
params: import("xstate").NonReducibleUnknown;
|
|
67
|
+
}, {
|
|
68
|
+
type: "hasItems";
|
|
69
|
+
params: unknown;
|
|
70
|
+
}, string, {}, string, {
|
|
71
|
+
initialContext: Partial<QuoteMachineContext>;
|
|
72
|
+
initialState?: string | undefined;
|
|
73
|
+
}, import("xstate").NonReducibleUnknown, import("xstate").ResolveTypegenMeta<import("xstate").TypegenDisabled, import("./types").SetEmptyEvent | import("./types").SetActiveEvent | import("./types").AddItemsEvent | import("./types").RemoveItemsEvent | import("./types").ClearItemsEvent | import("./types").RefreshEvent | import("./types").ApplyPromotionEvent | import("./types").RemovePromotionEvent | import("./types").AddAddressEvent | import("./types").RemoveAddressEvent | import("./types").ApplyPaymentMethodEvent | import("./types").AddRewardEvent | import("./types").RemoveRewardEvent | import("./types").AddStoreCreditEvent | import("./types").RemoveStoreCreditEvent | import("./types").AddGiftCardEvent | import("./types").RemoveGiftCardEvent | import("xstate").DoneActorEvent<import("./types").AddItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").RemoveItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").ClearItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").RefreshSuccessEvent>, {
|
|
74
|
+
src: "addItems";
|
|
75
|
+
logic: import("xstate").PromiseActorLogic<import("./types").AddItemsSuccessEvent, {
|
|
76
|
+
endpoint: "";
|
|
77
|
+
items: {
|
|
78
|
+
id: string;
|
|
79
|
+
quantity: number;
|
|
80
|
+
options: Record<string, any>;
|
|
81
|
+
}[];
|
|
82
|
+
quoteId: string;
|
|
83
|
+
}>;
|
|
84
|
+
id: string | undefined;
|
|
85
|
+
} | {
|
|
86
|
+
src: "removeItems";
|
|
87
|
+
logic: import("xstate").PromiseActorLogic<import("./types").RemoveItemsSuccessEvent, {
|
|
88
|
+
endpoint: "";
|
|
89
|
+
items: {
|
|
90
|
+
id: string;
|
|
91
|
+
quantity: number;
|
|
92
|
+
}[];
|
|
93
|
+
quoteId: string;
|
|
94
|
+
}>;
|
|
95
|
+
id: string | undefined;
|
|
96
|
+
} | {
|
|
97
|
+
src: "refresh";
|
|
98
|
+
logic: import("xstate").PromiseActorLogic<import("./types").RefreshSuccessEvent, {
|
|
99
|
+
endpoint: "";
|
|
100
|
+
quoteId: string;
|
|
101
|
+
}>;
|
|
102
|
+
id: string | undefined;
|
|
103
|
+
}, {
|
|
104
|
+
type: "addItems";
|
|
105
|
+
params: import("xstate").NonReducibleUnknown;
|
|
106
|
+
} | {
|
|
107
|
+
type: "removeItems";
|
|
108
|
+
params: import("xstate").NonReducibleUnknown;
|
|
109
|
+
}, {
|
|
110
|
+
type: "hasItems";
|
|
111
|
+
params: unknown;
|
|
112
|
+
}, string, string>>;
|
|
113
|
+
export default quoteMachine;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { DoneActorEvent } from 'xstate';
|
|
2
|
+
/** @todo how do we want to handle quote items? */
|
|
3
|
+
export interface QuoteMachineContext {
|
|
4
|
+
quoteId: string;
|
|
5
|
+
currency: string;
|
|
6
|
+
items: Array<Record<string, any>>;
|
|
7
|
+
promotions: Array<Record<string, any>>;
|
|
8
|
+
addresses: {
|
|
9
|
+
billing: {
|
|
10
|
+
available: Array<Record<string, any>>;
|
|
11
|
+
};
|
|
12
|
+
shipping: {
|
|
13
|
+
available: Array<Record<string, any>>;
|
|
14
|
+
selected: string | null;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
totals: {
|
|
18
|
+
discount: number;
|
|
19
|
+
tax: number;
|
|
20
|
+
shipping: number;
|
|
21
|
+
shippingTax: number;
|
|
22
|
+
subtotal: number;
|
|
23
|
+
grandTotal: number;
|
|
24
|
+
};
|
|
25
|
+
payments: Array<Record<string, any>>;
|
|
26
|
+
storeCredit: Array<Record<string, any>>;
|
|
27
|
+
rewards: Array<Record<string, any>>;
|
|
28
|
+
giftCards: Array<Record<string, any>>;
|
|
29
|
+
settings: Array<Record<string, any>>;
|
|
30
|
+
endpoints: {
|
|
31
|
+
addItems: '';
|
|
32
|
+
removeItems: '';
|
|
33
|
+
clearItems: '';
|
|
34
|
+
refresh: '';
|
|
35
|
+
applyPromotion: '';
|
|
36
|
+
removePromotion: '';
|
|
37
|
+
addAddress: '';
|
|
38
|
+
removeAddress: '';
|
|
39
|
+
applyPaymentMethod: '';
|
|
40
|
+
addReward: '';
|
|
41
|
+
removeReward: '';
|
|
42
|
+
addStoreCredit: '';
|
|
43
|
+
removeStoreCredit: '';
|
|
44
|
+
addGiftCard: '';
|
|
45
|
+
removeGiftCard: '';
|
|
46
|
+
};
|
|
47
|
+
errors: Array<string>;
|
|
48
|
+
}
|
|
49
|
+
export interface SetEmptyEvent {
|
|
50
|
+
type: 'SET_EMPTY';
|
|
51
|
+
}
|
|
52
|
+
export interface SetActiveEvent {
|
|
53
|
+
type: 'SET_ACTIVE';
|
|
54
|
+
}
|
|
55
|
+
export interface AddItemsEvent {
|
|
56
|
+
type: 'ADD_ITEMS';
|
|
57
|
+
items: Array<{
|
|
58
|
+
id: string;
|
|
59
|
+
quantity: number;
|
|
60
|
+
options: Record<string, any>;
|
|
61
|
+
}>;
|
|
62
|
+
}
|
|
63
|
+
export interface RemoveItemsEvent {
|
|
64
|
+
type: 'REMOVE_ITEMS';
|
|
65
|
+
items: Array<{
|
|
66
|
+
id: string;
|
|
67
|
+
quantity: number;
|
|
68
|
+
}>;
|
|
69
|
+
}
|
|
70
|
+
export interface ClearItemsEvent {
|
|
71
|
+
type: 'CLEAR_ITEMS';
|
|
72
|
+
}
|
|
73
|
+
export interface RefreshEvent {
|
|
74
|
+
type: 'REFRESH';
|
|
75
|
+
}
|
|
76
|
+
export interface ApplyPromotionEvent {
|
|
77
|
+
type: 'APPLY_PROMOTION';
|
|
78
|
+
}
|
|
79
|
+
export interface RemovePromotionEvent {
|
|
80
|
+
type: 'REMOVE_PROMOTION';
|
|
81
|
+
}
|
|
82
|
+
export interface AddAddressEvent {
|
|
83
|
+
type: 'ADD_ADDRESS';
|
|
84
|
+
}
|
|
85
|
+
export interface RemoveAddressEvent {
|
|
86
|
+
type: 'REMOVE_ADDRESS';
|
|
87
|
+
}
|
|
88
|
+
export interface ApplyPaymentMethodEvent {
|
|
89
|
+
type: 'APPLY_PAYMENT_METHOD';
|
|
90
|
+
}
|
|
91
|
+
export interface AddRewardEvent {
|
|
92
|
+
type: 'ADD_REWARD';
|
|
93
|
+
}
|
|
94
|
+
export interface RemoveRewardEvent {
|
|
95
|
+
type: 'REMOVE_REWARD';
|
|
96
|
+
}
|
|
97
|
+
export interface AddStoreCreditEvent {
|
|
98
|
+
type: 'ADD_STORE_CREDIT';
|
|
99
|
+
}
|
|
100
|
+
export interface RemoveStoreCreditEvent {
|
|
101
|
+
type: 'REMOVE_STORE_CREDIT';
|
|
102
|
+
}
|
|
103
|
+
export interface AddGiftCardEvent {
|
|
104
|
+
type: 'ADD_GIFT_CARD';
|
|
105
|
+
}
|
|
106
|
+
export interface RemoveGiftCardEvent {
|
|
107
|
+
type: 'REMOVE_GIFT_CARD';
|
|
108
|
+
}
|
|
109
|
+
export interface AddItemsSuccessEvent {
|
|
110
|
+
type: 'ADD_ITEMS_SUCCESS';
|
|
111
|
+
items: Array<Record<string, any>>;
|
|
112
|
+
}
|
|
113
|
+
export interface RemoveItemsSuccessEvent {
|
|
114
|
+
type: 'REMOVE_ITEMS_SUCCESS';
|
|
115
|
+
items: Array<Record<string, any>>;
|
|
116
|
+
}
|
|
117
|
+
export interface ClearItemsSuccessEvent {
|
|
118
|
+
type: 'CLEAR_ITEMS_SUCCESS';
|
|
119
|
+
}
|
|
120
|
+
export interface RefreshSuccessEvent {
|
|
121
|
+
type: 'REFRESH_SUCCESS';
|
|
122
|
+
}
|
|
123
|
+
export type QuoteMachineEvents = SetEmptyEvent | SetActiveEvent | AddItemsEvent | RemoveItemsEvent | ClearItemsEvent | RefreshEvent | ApplyPromotionEvent | RemovePromotionEvent | AddAddressEvent | RemoveAddressEvent | ApplyPaymentMethodEvent | AddRewardEvent | RemoveRewardEvent | AddStoreCreditEvent | RemoveStoreCreditEvent | AddGiftCardEvent | RemoveGiftCardEvent | DoneActorEvent<AddItemsSuccessEvent> | DoneActorEvent<RemoveItemsSuccessEvent> | DoneActorEvent<ClearItemsSuccessEvent> | DoneActorEvent<RefreshSuccessEvent>;
|
|
124
|
+
export type AddItemsResponse = {
|
|
125
|
+
message?: string;
|
|
126
|
+
success: boolean;
|
|
127
|
+
};
|
|
128
|
+
export type RemoveItemsResponse = {
|
|
129
|
+
message?: string;
|
|
130
|
+
success: boolean;
|
|
131
|
+
};
|
|
132
|
+
export type RefreshResponse = {
|
|
133
|
+
message?: string;
|
|
134
|
+
success: boolean;
|
|
135
|
+
};
|
package/src/cart/cart.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { DoneActorEvent } from 'xstate';
|
|
2
|
-
import type { CartMachineContext, AddItemSuccessEvent } from './types';
|
|
3
|
-
export declare const cartMachine: import("xstate").StateMachine<CartMachineContext, import("./types").AddItemEvent | import("./types").RemoveItemEvent | import("./types").ResetItemsEvent | import("./types").SetEmptyEvent | import("./types").SetActiveEvent | DoneActorEvent<AddItemSuccessEvent> | DoneActorEvent<import("./types").RemoveItemSuccessEvent> | DoneActorEvent<import("./types").ResetItemsSuccessEvent>, {
|
|
4
|
-
[x: string]: import("xstate").ActorRef<import("xstate").PromiseSnapshot<AddItemSuccessEvent, {
|
|
5
|
-
cartToken: CartMachineContext['cartToken'];
|
|
6
|
-
}>, {
|
|
7
|
-
[k: string]: unknown;
|
|
8
|
-
type: string;
|
|
9
|
-
}> | undefined;
|
|
10
|
-
}, {
|
|
11
|
-
src: "addItem";
|
|
12
|
-
logic: import("xstate").PromiseActorLogic<AddItemSuccessEvent, {
|
|
13
|
-
cartToken: CartMachineContext['cartToken'];
|
|
14
|
-
}>;
|
|
15
|
-
id: string | undefined;
|
|
16
|
-
}, {
|
|
17
|
-
type: "addItem";
|
|
18
|
-
params: import("xstate").NonReducibleUnknown;
|
|
19
|
-
}, {
|
|
20
|
-
type: string;
|
|
21
|
-
params: import("xstate").NonReducibleUnknown;
|
|
22
|
-
}, string, {}, string, {
|
|
23
|
-
initialContext: Partial<CartMachineContext>;
|
|
24
|
-
initialState?: string | undefined;
|
|
25
|
-
}, import("xstate").NonReducibleUnknown, import("xstate").ResolveTypegenMeta<import("xstate").TypegenDisabled, import("./types").AddItemEvent | import("./types").RemoveItemEvent | import("./types").ResetItemsEvent | import("./types").SetEmptyEvent | import("./types").SetActiveEvent | DoneActorEvent<AddItemSuccessEvent> | DoneActorEvent<import("./types").RemoveItemSuccessEvent> | DoneActorEvent<import("./types").ResetItemsSuccessEvent>, {
|
|
26
|
-
src: "addItem";
|
|
27
|
-
logic: import("xstate").PromiseActorLogic<AddItemSuccessEvent, {
|
|
28
|
-
cartToken: CartMachineContext['cartToken'];
|
|
29
|
-
}>;
|
|
30
|
-
id: string | undefined;
|
|
31
|
-
}, {
|
|
32
|
-
type: "addItem";
|
|
33
|
-
params: import("xstate").NonReducibleUnknown;
|
|
34
|
-
}, {
|
|
35
|
-
type: string;
|
|
36
|
-
params: import("xstate").NonReducibleUnknown;
|
|
37
|
-
}, string, string>>;
|
|
38
|
-
export default cartMachine;
|
package/src/cart/types.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { DoneActorEvent } from 'xstate';
|
|
2
|
-
export type CartItem = {
|
|
3
|
-
id: number | string;
|
|
4
|
-
image: string | null;
|
|
5
|
-
name: string;
|
|
6
|
-
price: {
|
|
7
|
-
base: number;
|
|
8
|
-
adjusted?: number;
|
|
9
|
-
};
|
|
10
|
-
quantity: number;
|
|
11
|
-
};
|
|
12
|
-
export interface CartMachineContext {
|
|
13
|
-
cartToken: string;
|
|
14
|
-
currency: string;
|
|
15
|
-
items: Array<CartItem>;
|
|
16
|
-
user: object | null;
|
|
17
|
-
}
|
|
18
|
-
export interface AddItemEvent {
|
|
19
|
-
type: 'ADD_ITEM';
|
|
20
|
-
id: string;
|
|
21
|
-
quantity: number;
|
|
22
|
-
}
|
|
23
|
-
export interface RemoveItemEvent {
|
|
24
|
-
type: 'REMOVE_ITEM';
|
|
25
|
-
id: string;
|
|
26
|
-
quantity: number;
|
|
27
|
-
}
|
|
28
|
-
export interface ResetItemsEvent {
|
|
29
|
-
type: 'RESET_ITEMS';
|
|
30
|
-
}
|
|
31
|
-
export interface SetEmptyEvent {
|
|
32
|
-
type: 'SET_EMPTY';
|
|
33
|
-
}
|
|
34
|
-
export interface SetActiveEvent {
|
|
35
|
-
type: 'SET_ACTIVE';
|
|
36
|
-
}
|
|
37
|
-
export interface AddItemSuccessEvent {
|
|
38
|
-
type: 'ADD_ITEM_SUCCESS';
|
|
39
|
-
[k: string]: any;
|
|
40
|
-
}
|
|
41
|
-
export interface RemoveItemSuccessEvent {
|
|
42
|
-
type: 'ADD_ITEM_SUCCESS';
|
|
43
|
-
}
|
|
44
|
-
export interface ResetItemsSuccessEvent {
|
|
45
|
-
type: 'RESET_ITEMS_SUCCESS';
|
|
46
|
-
}
|
|
47
|
-
export type CartMachineEvents = AddItemEvent | RemoveItemEvent | ResetItemsEvent | SetEmptyEvent | SetActiveEvent | DoneActorEvent<AddItemSuccessEvent> | DoneActorEvent<RemoveItemSuccessEvent> | DoneActorEvent<ResetItemsSuccessEvent>;
|
|
48
|
-
export type AddItemResponse = {
|
|
49
|
-
message?: string;
|
|
50
|
-
success: boolean;
|
|
51
|
-
};
|