@@ -2,6 +2,7 @@ import { combineReducers } from '@bigcommerce/data-store';
2
2
3
3
import { Address } from '../address' ;
4
4
import { CheckoutAction , CheckoutActionType } from '../checkout' ;
5
+ import { OrderAction , OrderActionType } from '../order' ;
5
6
6
7
import { BillingAddressAction , BillingAddressActionType } from './billing-address-actions' ;
7
8
import BillingAddressState , { BillingAddressErrorsState , BillingAddressStatusesState } from './billing-address-state' ;
@@ -13,9 +14,9 @@ const DEFAULT_STATE: BillingAddressState = {
13
14
14
15
export default function billingAddressReducer (
15
16
state : BillingAddressState = DEFAULT_STATE ,
16
- action : CheckoutAction
17
+ action : CheckoutAction | BillingAddressAction | OrderAction
17
18
) : BillingAddressState {
18
- const reducer = combineReducers < BillingAddressState , CheckoutAction | BillingAddressAction > ( {
19
+ const reducer = combineReducers < BillingAddressState , CheckoutAction | BillingAddressAction | OrderAction > ( {
19
20
data : dataReducer ,
20
21
errors : errorsReducer ,
21
22
statuses : statusesReducer ,
@@ -26,11 +27,12 @@ export default function billingAddressReducer(
26
27
27
28
function dataReducer (
28
29
data : Address | undefined ,
29
- action : CheckoutAction | BillingAddressAction
30
+ action : CheckoutAction | BillingAddressAction | OrderAction
30
31
) : Address | undefined {
31
32
switch ( action . type ) {
32
33
case BillingAddressActionType . UpdateBillingAddressSucceeded :
33
34
case CheckoutActionType . LoadCheckoutSucceeded :
35
+ case OrderActionType . LoadOrderSucceeded :
34
36
return action . payload ? action . payload . billingAddress : data ;
35
37
36
38
default :
@@ -40,7 +42,7 @@ function dataReducer(
40
42
41
43
function errorsReducer (
42
44
errors : BillingAddressErrorsState = DEFAULT_STATE . errors ,
43
- action : CheckoutAction | BillingAddressAction
45
+ action : CheckoutAction | BillingAddressAction | OrderAction
44
46
) : BillingAddressErrorsState {
45
47
switch ( action . type ) {
46
48
case CheckoutActionType . LoadCheckoutRequested :
@@ -64,7 +66,7 @@ function errorsReducer(
64
66
65
67
function statusesReducer (
66
68
statuses : BillingAddressStatusesState = DEFAULT_STATE . statuses ,
67
- action : CheckoutAction | BillingAddressAction
69
+ action : CheckoutAction | BillingAddressAction | OrderAction
68
70
) : BillingAddressStatusesState {
69
71
switch ( action . type ) {
70
72
case CheckoutActionType . LoadCheckoutRequested :
0 commit comments