File tree Expand file tree Collapse file tree 4 files changed +58
-73
lines changed
client/extensions/woocommerce/state
ui/shipping/zones/methods Expand file tree Collapse file tree 4 files changed +58
-73
lines changed Original file line number Diff line number Diff line change 1- /** @format */
2-
31/**
42 * Internal dependencies
53 */
6- import { createReducer } from 'state/utils' ;
4+ import { withoutPersistence } from 'state/utils' ;
75import {
86 WOOCOMMERCE_SHIPPING_CLASSES_REQUEST ,
97 WOOCOMMERCE_SHIPPING_CLASSES_REQUEST_SUCCESS ,
108} from 'woocommerce/state/action-types' ;
119import { LOADING } from 'woocommerce/state/constants' ;
1210
13- const reducers = { } ;
14-
15- reducers [ WOOCOMMERCE_SHIPPING_CLASSES_REQUEST ] = ( ) => {
16- return LOADING ;
17- } ;
18-
19- reducers [ WOOCOMMERCE_SHIPPING_CLASSES_REQUEST_SUCCESS ] = ( state , { data } ) => {
20- return data ;
21- } ;
22-
23- export default createReducer ( { } , reducers ) ;
11+ export default withoutPersistence ( function ( state = { } , action ) {
12+ switch ( action . type ) {
13+ case WOOCOMMERCE_SHIPPING_CLASSES_REQUEST :
14+ return LOADING ;
15+ case WOOCOMMERCE_SHIPPING_CLASSES_REQUEST_SUCCESS :
16+ return action . data ;
17+ }
18+ return state ;
19+ } ) ;
Original file line number Diff line number Diff line change 1- /** @format */
2-
31/**
42 * Internal dependencies
53 */
6-
7- import { createReducer } from 'state/utils' ;
4+ import { withoutPersistence } from 'state/utils' ;
85import {
96 WOOCOMMERCE_SHIPPING_ZONE_METHOD_SET_TAXABLE ,
107 WOOCOMMERCE_SHIPPING_ZONE_METHOD_SET_COST ,
@@ -15,20 +12,20 @@ const initialState = {
1512 cost : 5 ,
1613} ;
1714
18- const reducer = { } ;
15+ export default withoutPersistence ( function ( state = initialState , action ) {
16+ switch ( action . type ) {
17+ case WOOCOMMERCE_SHIPPING_ZONE_METHOD_SET_TAXABLE :
18+ return {
19+ ...state ,
20+ tax_status : action . isTaxable ? 'taxable' : 'none' ,
21+ } ;
1922
20- reducer [ WOOCOMMERCE_SHIPPING_ZONE_METHOD_SET_TAXABLE ] = ( state , { isTaxable } ) => {
21- return {
22- ...state ,
23- tax_status : isTaxable ? 'taxable' : 'none' ,
24- } ;
25- } ;
26-
27- reducer [ WOOCOMMERCE_SHIPPING_ZONE_METHOD_SET_COST ] = ( state , { cost } ) => {
28- return {
29- ...state ,
30- cost,
31- } ;
32- } ;
23+ case WOOCOMMERCE_SHIPPING_ZONE_METHOD_SET_COST :
24+ return {
25+ ...state ,
26+ cost : action . cost ,
27+ } ;
28+ }
3329
34- export default createReducer ( initialState , reducer ) ;
30+ return state ;
31+ } ) ;
Original file line number Diff line number Diff line change 1- /** @format */
2-
31/**
42 * Internal dependencies
53 */
6-
7- import { createReducer } from 'state/utils' ;
4+ import { withoutPersistence } from 'state/utils' ;
85import {
96 WOOCOMMERCE_SHIPPING_ZONE_METHOD_SET_CONDITION ,
107 WOOCOMMERCE_SHIPPING_ZONE_METHOD_SET_MIN_COST ,
@@ -15,20 +12,19 @@ const initialState = {
1512 min_amount : 0 ,
1613} ;
1714
18- const reducer = { } ;
19-
20- reducer [ WOOCOMMERCE_SHIPPING_ZONE_METHOD_SET_CONDITION ] = ( state , { condition } ) => {
21- return {
22- ...state ,
23- requires : condition ,
24- } ;
25- } ;
26-
27- reducer [ WOOCOMMERCE_SHIPPING_ZONE_METHOD_SET_MIN_COST ] = ( state , { cost } ) => {
28- return {
29- ...state ,
30- min_amount : cost ,
31- } ;
32- } ;
15+ export default withoutPersistence ( function ( state = initialState , action ) {
16+ switch ( action . type ) {
17+ case WOOCOMMERCE_SHIPPING_ZONE_METHOD_SET_CONDITION :
18+ return {
19+ ...state ,
20+ requires : action . condition ,
21+ } ;
3322
34- export default createReducer ( initialState , reducer ) ;
23+ case WOOCOMMERCE_SHIPPING_ZONE_METHOD_SET_MIN_COST :
24+ return {
25+ ...state ,
26+ min_amount : action . cost ,
27+ } ;
28+ }
29+ return state ;
30+ } ) ;
Original file line number Diff line number Diff line change 1- /** @format */
2-
31/**
42 * Internal dependencies
53 */
6-
7- import { createReducer } from 'state/utils' ;
4+ import { withoutPersistence } from 'state/utils' ;
85import {
96 WOOCOMMERCE_SHIPPING_ZONE_METHOD_SET_TAXABLE ,
107 WOOCOMMERCE_SHIPPING_ZONE_METHOD_SET_COST ,
@@ -15,20 +12,19 @@ const initialState = {
1512 cost : 0 ,
1613} ;
1714
18- const reducer = { } ;
19-
20- reducer [ WOOCOMMERCE_SHIPPING_ZONE_METHOD_SET_TAXABLE ] = ( state , { isTaxable } ) => {
21- return {
22- ...state ,
23- tax_status : isTaxable ? 'taxable' : 'none' ,
24- } ;
25- } ;
26-
27- reducer [ WOOCOMMERCE_SHIPPING_ZONE_METHOD_SET_COST ] = ( state , { cost } ) => {
28- return {
29- ...state ,
30- cost,
31- } ;
32- } ;
15+ export default withoutPersistence ( function ( state = initialState , action ) {
16+ switch ( action . type ) {
17+ case WOOCOMMERCE_SHIPPING_ZONE_METHOD_SET_TAXABLE :
18+ return {
19+ ...state ,
20+ tax_status : action . isTaxable ? 'taxable' : 'none' ,
21+ } ;
3322
34- export default createReducer ( initialState , reducer ) ;
23+ case WOOCOMMERCE_SHIPPING_ZONE_METHOD_SET_COST :
24+ return {
25+ ...state ,
26+ cost : action . cost ,
27+ } ;
28+ }
29+ return state ;
30+ } ) ;
You can’t perform that action at this time.
0 commit comments