@ordergroove/offers 2.30.1-alpha-PR-714-9.8 → 2.30.1
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/CHANGELOG.md +8 -0
- package/dist/bundle-report.html +28 -28
- package/dist/examples.js +1 -1
- package/dist/examples.js.map +2 -2
- package/dist/offers.js +34 -34
- package/dist/offers.js.map +2 -2
- package/examples/index.html +0 -1
- package/examples/index.js +8 -9
- package/package.json +3 -3
- package/src/components/Offer.js +0 -1
- package/src/core/__tests__/adapters.spec.js +1 -309
- package/src/core/__tests__/reducer.spec.js +1 -79
- package/src/core/actions-preview.js +0 -127
- package/src/core/adapters.js +1 -14
- package/src/core/constants.js +0 -2
- package/src/core/reducer.js +1 -12
package/examples/index.html
CHANGED
package/examples/index.js
CHANGED
|
@@ -8,24 +8,24 @@ import { getMarkup, getStyles } from '@ordergroove/offers-templates';
|
|
|
8
8
|
window.og_settings = {
|
|
9
9
|
// object were key is product id and value is an array of plan discount
|
|
10
10
|
product_discounts: {
|
|
11
|
-
|
|
11
|
+
UD729: {
|
|
12
12
|
'3_1': ['30.00', '10%', '$27.00'],
|
|
13
13
|
'1_2': ['30.00', '20%', '$24.00']
|
|
14
14
|
},
|
|
15
|
-
|
|
15
|
+
UD728: [
|
|
16
16
|
{
|
|
17
|
-
frequency: '
|
|
18
|
-
prepaidShipments:
|
|
17
|
+
frequency: '1_2',
|
|
18
|
+
prepaidShipments: '3',
|
|
19
19
|
regularPrice: '$15.00',
|
|
20
20
|
subscriptionPrice: '$13.50',
|
|
21
21
|
discountRate: '10%'
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
|
-
frequency: '
|
|
24
|
+
frequency: '3_1',
|
|
25
25
|
prepaidShipments: null,
|
|
26
26
|
regularPrice: '$15.00',
|
|
27
|
-
subscriptionPrice: '$
|
|
28
|
-
discountRate: '
|
|
27
|
+
subscriptionPrice: '$12.00',
|
|
28
|
+
discountRate: '20%'
|
|
29
29
|
}
|
|
30
30
|
]
|
|
31
31
|
}
|
|
@@ -179,8 +179,7 @@ const offersExamples = [
|
|
|
179
179
|
},
|
|
180
180
|
{
|
|
181
181
|
name: 'Prepaid',
|
|
182
|
-
|
|
183
|
-
selector: 'og-offer[location="prepaid-pdp"]',
|
|
182
|
+
selector: 'og-offer[location="initial"]',
|
|
184
183
|
config: {
|
|
185
184
|
settings: {
|
|
186
185
|
...settings,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ordergroove/offers",
|
|
3
|
-
"version": "2.30.1
|
|
3
|
+
"version": "2.30.1",
|
|
4
4
|
"description": "offer state component",
|
|
5
5
|
"author": "Eugenio Lattanzio <eugenio63@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/ordergroove/plush-toys#readme",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"throttle-debounce": "^2.1.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@ordergroove/offers-templates": "^0.5.
|
|
48
|
+
"@ordergroove/offers-templates": "^0.5.1"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "80a8e7736af03c41fc30fc1fe9294cfd947b2482"
|
|
51
51
|
}
|
package/src/components/Offer.js
CHANGED
|
@@ -64,7 +64,6 @@ export class Offer extends TemplateElement {
|
|
|
64
64
|
if (preview === 'preview-standard-offer') this.preview = 'regular';
|
|
65
65
|
else if (preview === 'preview-upsell-offer') this.preview = 'upsell';
|
|
66
66
|
else if (preview === 'preview-subscribed-offer') this.preview = 'subscribed';
|
|
67
|
-
else if (preview === 'preview-prepaid-offer') this.preview = 'prepaid';
|
|
68
67
|
}
|
|
69
68
|
|
|
70
69
|
static get styles() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getProductsForPurchasePost, getObjectStructuredProductPlans
|
|
1
|
+
import { getProductsForPurchasePost, getObjectStructuredProductPlans } from '../adapters';
|
|
2
2
|
|
|
3
3
|
describe('adapters', () => {
|
|
4
4
|
describe('getProductsForPurchasePost', () => {
|
|
@@ -480,312 +480,4 @@ describe('adapters', () => {
|
|
|
480
480
|
expect(actual).toEqual(expected);
|
|
481
481
|
});
|
|
482
482
|
});
|
|
483
|
-
|
|
484
|
-
describe('mergeProductPlansToState', () => {
|
|
485
|
-
it('Should merge productPlans to state correctly', () => {
|
|
486
|
-
const state = {
|
|
487
|
-
UD728: [
|
|
488
|
-
{
|
|
489
|
-
frequency: '3_1',
|
|
490
|
-
prepaidShipments: null,
|
|
491
|
-
regularPrice: '30.00',
|
|
492
|
-
subscriptionPrice: '$27.00',
|
|
493
|
-
discountRate: '10%'
|
|
494
|
-
},
|
|
495
|
-
{
|
|
496
|
-
frequency: '1_2',
|
|
497
|
-
prepaidShipments: null,
|
|
498
|
-
regularPrice: '30.00',
|
|
499
|
-
subscriptionPrice: '$24.00',
|
|
500
|
-
discountRate: '20%'
|
|
501
|
-
}
|
|
502
|
-
],
|
|
503
|
-
UD729: [
|
|
504
|
-
{
|
|
505
|
-
frequency: '1_3',
|
|
506
|
-
prepaidShipments: null,
|
|
507
|
-
regularPrice: '$15.00',
|
|
508
|
-
subscriptionPrice: '$13.50',
|
|
509
|
-
discountRate: '10%'
|
|
510
|
-
},
|
|
511
|
-
{
|
|
512
|
-
frequency: '2_3',
|
|
513
|
-
prepaidShipments: null,
|
|
514
|
-
regularPrice: '$15.00',
|
|
515
|
-
subscriptionPrice: '$13.50',
|
|
516
|
-
discountRate: '10%'
|
|
517
|
-
}
|
|
518
|
-
],
|
|
519
|
-
UD730: [
|
|
520
|
-
{
|
|
521
|
-
frequency: '1_2',
|
|
522
|
-
prepaidShipments: null,
|
|
523
|
-
regularPrice: '30.00',
|
|
524
|
-
subscriptionPrice: '$24.00',
|
|
525
|
-
discountRate: '20%'
|
|
526
|
-
}
|
|
527
|
-
]
|
|
528
|
-
};
|
|
529
|
-
|
|
530
|
-
const productPlans = {
|
|
531
|
-
UD728: [
|
|
532
|
-
{
|
|
533
|
-
frequency: '3_1',
|
|
534
|
-
prepaidShipments: null,
|
|
535
|
-
regularPrice: '30.00',
|
|
536
|
-
subscriptionPrice: '$27.00',
|
|
537
|
-
discountRate: '10%'
|
|
538
|
-
}
|
|
539
|
-
],
|
|
540
|
-
UD729: [
|
|
541
|
-
{
|
|
542
|
-
frequency: '1_3',
|
|
543
|
-
regularPrice: '$15.00',
|
|
544
|
-
subscriptionPrice: '$12.00',
|
|
545
|
-
discountRate: '25%',
|
|
546
|
-
prepaidShipments: 3,
|
|
547
|
-
regularPrepaidPrice: '$36.00',
|
|
548
|
-
prepaidSavingsPerShipment: '$3.00',
|
|
549
|
-
prepaidSavingsTotal: '$9.00',
|
|
550
|
-
prepaidExtraSavingsPercentage: '10%'
|
|
551
|
-
},
|
|
552
|
-
{
|
|
553
|
-
frequency: '1_3',
|
|
554
|
-
regularPrice: '$15.00',
|
|
555
|
-
subscriptionPrice: '$12.00',
|
|
556
|
-
discountRate: '20%',
|
|
557
|
-
prepaidShipments: 6,
|
|
558
|
-
regularPrepaidPrice: '$72.00',
|
|
559
|
-
prepaidSavingsPerShipment: '$3.00',
|
|
560
|
-
prepaidSavingsTotal: '$18.00',
|
|
561
|
-
prepaidExtraSavingsPercentage: '10%'
|
|
562
|
-
},
|
|
563
|
-
{
|
|
564
|
-
frequency: '1_3',
|
|
565
|
-
regularPrice: '$15.00',
|
|
566
|
-
subscriptionPrice: '$12.00',
|
|
567
|
-
discountRate: '20%',
|
|
568
|
-
prepaidShipments: 12,
|
|
569
|
-
regularPrepaidPrice: '$144.00',
|
|
570
|
-
prepaidSavingsPerShipment: '$3.00',
|
|
571
|
-
prepaidSavingsTotal: '$36.00',
|
|
572
|
-
prepaidExtraSavingsPercentage: '10%'
|
|
573
|
-
}
|
|
574
|
-
],
|
|
575
|
-
UD730: [
|
|
576
|
-
{
|
|
577
|
-
frequency: '1_2',
|
|
578
|
-
prepaidShipments: null,
|
|
579
|
-
regularPrice: '30.00',
|
|
580
|
-
subscriptionPrice: '$24.00',
|
|
581
|
-
discountRate: '21%'
|
|
582
|
-
}
|
|
583
|
-
]
|
|
584
|
-
};
|
|
585
|
-
|
|
586
|
-
const expected = {
|
|
587
|
-
UD728: [
|
|
588
|
-
{
|
|
589
|
-
frequency: '3_1',
|
|
590
|
-
prepaidShipments: null,
|
|
591
|
-
regularPrice: '30.00',
|
|
592
|
-
subscriptionPrice: '$27.00',
|
|
593
|
-
discountRate: '10%'
|
|
594
|
-
},
|
|
595
|
-
{
|
|
596
|
-
frequency: '1_2',
|
|
597
|
-
prepaidShipments: null,
|
|
598
|
-
regularPrice: '30.00',
|
|
599
|
-
subscriptionPrice: '$24.00',
|
|
600
|
-
discountRate: '20%'
|
|
601
|
-
}
|
|
602
|
-
],
|
|
603
|
-
UD729: [
|
|
604
|
-
{
|
|
605
|
-
frequency: '1_3',
|
|
606
|
-
prepaidShipments: null,
|
|
607
|
-
regularPrice: '$15.00',
|
|
608
|
-
subscriptionPrice: '$13.50',
|
|
609
|
-
discountRate: '10%'
|
|
610
|
-
},
|
|
611
|
-
{
|
|
612
|
-
frequency: '2_3',
|
|
613
|
-
prepaidShipments: null,
|
|
614
|
-
regularPrice: '$15.00',
|
|
615
|
-
subscriptionPrice: '$13.50',
|
|
616
|
-
discountRate: '10%'
|
|
617
|
-
},
|
|
618
|
-
{
|
|
619
|
-
frequency: '1_3',
|
|
620
|
-
regularPrice: '$15.00',
|
|
621
|
-
subscriptionPrice: '$12.00',
|
|
622
|
-
discountRate: '25%',
|
|
623
|
-
prepaidShipments: 3,
|
|
624
|
-
regularPrepaidPrice: '$36.00',
|
|
625
|
-
prepaidSavingsPerShipment: '$3.00',
|
|
626
|
-
prepaidSavingsTotal: '$9.00',
|
|
627
|
-
prepaidExtraSavingsPercentage: '10%'
|
|
628
|
-
},
|
|
629
|
-
{
|
|
630
|
-
frequency: '1_3',
|
|
631
|
-
regularPrice: '$15.00',
|
|
632
|
-
subscriptionPrice: '$12.00',
|
|
633
|
-
discountRate: '20%',
|
|
634
|
-
prepaidShipments: 6,
|
|
635
|
-
regularPrepaidPrice: '$72.00',
|
|
636
|
-
prepaidSavingsPerShipment: '$3.00',
|
|
637
|
-
prepaidSavingsTotal: '$18.00',
|
|
638
|
-
prepaidExtraSavingsPercentage: '10%'
|
|
639
|
-
},
|
|
640
|
-
{
|
|
641
|
-
frequency: '1_3',
|
|
642
|
-
regularPrice: '$15.00',
|
|
643
|
-
subscriptionPrice: '$12.00',
|
|
644
|
-
discountRate: '20%',
|
|
645
|
-
prepaidShipments: 12,
|
|
646
|
-
regularPrepaidPrice: '$144.00',
|
|
647
|
-
prepaidSavingsPerShipment: '$3.00',
|
|
648
|
-
prepaidSavingsTotal: '$36.00',
|
|
649
|
-
prepaidExtraSavingsPercentage: '10%'
|
|
650
|
-
}
|
|
651
|
-
],
|
|
652
|
-
UD730: [
|
|
653
|
-
{
|
|
654
|
-
frequency: '1_2',
|
|
655
|
-
prepaidShipments: null,
|
|
656
|
-
regularPrice: '30.00',
|
|
657
|
-
subscriptionPrice: '$24.00',
|
|
658
|
-
discountRate: '20%'
|
|
659
|
-
},
|
|
660
|
-
{
|
|
661
|
-
frequency: '1_2',
|
|
662
|
-
prepaidShipments: null,
|
|
663
|
-
regularPrice: '30.00',
|
|
664
|
-
subscriptionPrice: '$24.00',
|
|
665
|
-
discountRate: '21%'
|
|
666
|
-
}
|
|
667
|
-
]
|
|
668
|
-
};
|
|
669
|
-
|
|
670
|
-
expect(mergeProductPlansToState(state, productPlans)).toEqual(expected);
|
|
671
|
-
});
|
|
672
|
-
|
|
673
|
-
it('Should not add anything if productPlans are equal to state', () => {
|
|
674
|
-
const state = {
|
|
675
|
-
UD729: [
|
|
676
|
-
{
|
|
677
|
-
frequency: '1_3',
|
|
678
|
-
regularPrice: '$15.00',
|
|
679
|
-
subscriptionPrice: '$12.00',
|
|
680
|
-
discountRate: '25%',
|
|
681
|
-
prepaidShipments: 3,
|
|
682
|
-
regularPrepaidPrice: '$36.00',
|
|
683
|
-
prepaidSavingsPerShipment: '$3.00',
|
|
684
|
-
prepaidSavingsTotal: '$9.00',
|
|
685
|
-
prepaidExtraSavingsPercentage: '10%'
|
|
686
|
-
},
|
|
687
|
-
{
|
|
688
|
-
frequency: '1_3',
|
|
689
|
-
regularPrice: '$15.00',
|
|
690
|
-
subscriptionPrice: '$12.00',
|
|
691
|
-
discountRate: '20%',
|
|
692
|
-
prepaidShipments: 6,
|
|
693
|
-
regularPrepaidPrice: '$72.00',
|
|
694
|
-
prepaidSavingsPerShipment: '$3.00',
|
|
695
|
-
prepaidSavingsTotal: '$18.00',
|
|
696
|
-
prepaidExtraSavingsPercentage: '10%'
|
|
697
|
-
},
|
|
698
|
-
{
|
|
699
|
-
frequency: '1_3',
|
|
700
|
-
regularPrice: '$15.00',
|
|
701
|
-
subscriptionPrice: '$12.00',
|
|
702
|
-
discountRate: '20%',
|
|
703
|
-
prepaidShipments: 12,
|
|
704
|
-
regularPrepaidPrice: '$144.00',
|
|
705
|
-
prepaidSavingsPerShipment: '$3.00',
|
|
706
|
-
prepaidSavingsTotal: '$36.00',
|
|
707
|
-
prepaidExtraSavingsPercentage: '10%'
|
|
708
|
-
}
|
|
709
|
-
]
|
|
710
|
-
};
|
|
711
|
-
|
|
712
|
-
const productPlans = {
|
|
713
|
-
UD729: [
|
|
714
|
-
{
|
|
715
|
-
frequency: '1_3',
|
|
716
|
-
regularPrice: '$15.00',
|
|
717
|
-
subscriptionPrice: '$12.00',
|
|
718
|
-
discountRate: '25%',
|
|
719
|
-
prepaidShipments: 3,
|
|
720
|
-
regularPrepaidPrice: '$36.00',
|
|
721
|
-
prepaidSavingsPerShipment: '$3.00',
|
|
722
|
-
prepaidSavingsTotal: '$9.00',
|
|
723
|
-
prepaidExtraSavingsPercentage: '10%'
|
|
724
|
-
},
|
|
725
|
-
{
|
|
726
|
-
frequency: '1_3',
|
|
727
|
-
regularPrice: '$15.00',
|
|
728
|
-
subscriptionPrice: '$12.00',
|
|
729
|
-
discountRate: '20%',
|
|
730
|
-
prepaidShipments: 6,
|
|
731
|
-
regularPrepaidPrice: '$72.00',
|
|
732
|
-
prepaidSavingsPerShipment: '$3.00',
|
|
733
|
-
prepaidSavingsTotal: '$18.00',
|
|
734
|
-
prepaidExtraSavingsPercentage: '10%'
|
|
735
|
-
},
|
|
736
|
-
{
|
|
737
|
-
frequency: '1_3',
|
|
738
|
-
regularPrice: '$15.00',
|
|
739
|
-
subscriptionPrice: '$12.00',
|
|
740
|
-
discountRate: '20%',
|
|
741
|
-
prepaidShipments: 12,
|
|
742
|
-
regularPrepaidPrice: '$144.00',
|
|
743
|
-
prepaidSavingsPerShipment: '$3.00',
|
|
744
|
-
prepaidSavingsTotal: '$36.00',
|
|
745
|
-
prepaidExtraSavingsPercentage: '10%'
|
|
746
|
-
}
|
|
747
|
-
]
|
|
748
|
-
};
|
|
749
|
-
|
|
750
|
-
const expected = {
|
|
751
|
-
UD729: [
|
|
752
|
-
{
|
|
753
|
-
frequency: '1_3',
|
|
754
|
-
regularPrice: '$15.00',
|
|
755
|
-
subscriptionPrice: '$12.00',
|
|
756
|
-
discountRate: '25%',
|
|
757
|
-
prepaidShipments: 3,
|
|
758
|
-
regularPrepaidPrice: '$36.00',
|
|
759
|
-
prepaidSavingsPerShipment: '$3.00',
|
|
760
|
-
prepaidSavingsTotal: '$9.00',
|
|
761
|
-
prepaidExtraSavingsPercentage: '10%'
|
|
762
|
-
},
|
|
763
|
-
{
|
|
764
|
-
frequency: '1_3',
|
|
765
|
-
regularPrice: '$15.00',
|
|
766
|
-
subscriptionPrice: '$12.00',
|
|
767
|
-
discountRate: '20%',
|
|
768
|
-
prepaidShipments: 6,
|
|
769
|
-
regularPrepaidPrice: '$72.00',
|
|
770
|
-
prepaidSavingsPerShipment: '$3.00',
|
|
771
|
-
prepaidSavingsTotal: '$18.00',
|
|
772
|
-
prepaidExtraSavingsPercentage: '10%'
|
|
773
|
-
},
|
|
774
|
-
{
|
|
775
|
-
frequency: '1_3',
|
|
776
|
-
regularPrice: '$15.00',
|
|
777
|
-
subscriptionPrice: '$12.00',
|
|
778
|
-
discountRate: '20%',
|
|
779
|
-
prepaidShipments: 12,
|
|
780
|
-
regularPrepaidPrice: '$144.00',
|
|
781
|
-
prepaidSavingsPerShipment: '$3.00',
|
|
782
|
-
prepaidSavingsTotal: '$36.00',
|
|
783
|
-
prepaidExtraSavingsPercentage: '10%'
|
|
784
|
-
}
|
|
785
|
-
]
|
|
786
|
-
};
|
|
787
|
-
|
|
788
|
-
expect(mergeProductPlansToState(state, productPlans)).toEqual(expected);
|
|
789
|
-
});
|
|
790
|
-
});
|
|
791
483
|
});
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
prepaidShipmentsSelected
|
|
15
15
|
} from '../reducer';
|
|
16
16
|
import * as constants from '../constants';
|
|
17
|
-
import { getObjectStructuredProductPlans
|
|
17
|
+
import { getObjectStructuredProductPlans } from '../adapters';
|
|
18
18
|
|
|
19
19
|
describe('reducers', () => {
|
|
20
20
|
function testMergeReducerWithActionAndPayload(reducerFn, actionType, payload) {
|
|
@@ -955,84 +955,6 @@ describe('reducers', () => {
|
|
|
955
955
|
|
|
956
956
|
expect(actual).toEqual(getObjectStructuredProductPlans(payload));
|
|
957
957
|
});
|
|
958
|
-
|
|
959
|
-
it('should return object structure payload given action ADD_PRODUCT_PLANS using mergeProductPlansToState', () => {
|
|
960
|
-
const state = {
|
|
961
|
-
'variant-1': {
|
|
962
|
-
'1_3': ['$15.00', '10%', '$13.50'],
|
|
963
|
-
'2_3': ['$15.00', '10%', '$13.50'],
|
|
964
|
-
'3_3': ['$15.00', '20%', '$12.00']
|
|
965
|
-
},
|
|
966
|
-
'variant-2': [
|
|
967
|
-
{
|
|
968
|
-
frequency: '1_3',
|
|
969
|
-
prepaidShipments: null,
|
|
970
|
-
regularPrice: '$30.00',
|
|
971
|
-
subscriptionPrice: '$27.00',
|
|
972
|
-
discountRate: '10%'
|
|
973
|
-
},
|
|
974
|
-
{
|
|
975
|
-
frequency: '2_3',
|
|
976
|
-
prepaidShipments: null,
|
|
977
|
-
regularPrice: '$30.00',
|
|
978
|
-
subscriptionPrice: '$27.00',
|
|
979
|
-
discountRate: '10%'
|
|
980
|
-
},
|
|
981
|
-
{
|
|
982
|
-
frequency: '3_3',
|
|
983
|
-
prepaidShipments: 3,
|
|
984
|
-
regularPrice: '$30.00',
|
|
985
|
-
subscriptionPrice: '$24.00',
|
|
986
|
-
discountRate: '20%'
|
|
987
|
-
}
|
|
988
|
-
]
|
|
989
|
-
};
|
|
990
|
-
|
|
991
|
-
const payload = {
|
|
992
|
-
'variant-2': [
|
|
993
|
-
{
|
|
994
|
-
frequency: '1_3',
|
|
995
|
-
regularPrice: '$15.00',
|
|
996
|
-
subscriptionPrice: '$12.00',
|
|
997
|
-
discountRate: '25%',
|
|
998
|
-
prepaidShipments: 3,
|
|
999
|
-
regularPrepaidPrice: '$36.00',
|
|
1000
|
-
prepaidSavingsPerShipment: '$3.00',
|
|
1001
|
-
prepaidSavingsTotal: '$9.00',
|
|
1002
|
-
prepaidExtraSavingsPercentage: '10%'
|
|
1003
|
-
},
|
|
1004
|
-
{
|
|
1005
|
-
frequency: '1_3',
|
|
1006
|
-
regularPrice: '$15.00',
|
|
1007
|
-
subscriptionPrice: '$12.00',
|
|
1008
|
-
discountRate: '20%',
|
|
1009
|
-
prepaidShipments: 6,
|
|
1010
|
-
regularPrepaidPrice: '$72.00',
|
|
1011
|
-
prepaidSavingsPerShipment: '$3.00',
|
|
1012
|
-
prepaidSavingsTotal: '$18.00',
|
|
1013
|
-
prepaidExtraSavingsPercentage: '10%'
|
|
1014
|
-
},
|
|
1015
|
-
{
|
|
1016
|
-
frequency: '1_3',
|
|
1017
|
-
regularPrice: '$15.00',
|
|
1018
|
-
subscriptionPrice: '$12.00',
|
|
1019
|
-
discountRate: '20%',
|
|
1020
|
-
prepaidShipments: 12,
|
|
1021
|
-
regularPrepaidPrice: '$144.00',
|
|
1022
|
-
prepaidSavingsPerShipment: '$3.00',
|
|
1023
|
-
prepaidSavingsTotal: '$36.00',
|
|
1024
|
-
prepaidExtraSavingsPercentage: '10%'
|
|
1025
|
-
}
|
|
1026
|
-
]
|
|
1027
|
-
};
|
|
1028
|
-
|
|
1029
|
-
const actual = productPlans(state, {
|
|
1030
|
-
type: constants.ADD_PRODUCT_PLANS,
|
|
1031
|
-
payload: payload
|
|
1032
|
-
});
|
|
1033
|
-
|
|
1034
|
-
expect(actual).toEqual(mergeProductPlansToState(state, getObjectStructuredProductPlans(payload)));
|
|
1035
|
-
});
|
|
1036
958
|
});
|
|
1037
959
|
|
|
1038
960
|
describe('prepaidShipmentsSelected', () => {
|
|
@@ -122,128 +122,6 @@ export const setPreviewUpsellOffer = (isPreview, productId, offer) =>
|
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
124
|
|
|
125
|
-
export const setPreviewPrepaid = (isPreview, productId, offer) =>
|
|
126
|
-
async function setPreviewPrepaidThunk(dispatch, getState) {
|
|
127
|
-
await dispatch({
|
|
128
|
-
type: constants.SET_PREVIEW_PREPAID_OFFER,
|
|
129
|
-
payload: isPreview
|
|
130
|
-
});
|
|
131
|
-
await dispatch({
|
|
132
|
-
type: constants.UNAUTHORIZED
|
|
133
|
-
});
|
|
134
|
-
await dispatch(
|
|
135
|
-
receiveOffer(
|
|
136
|
-
{
|
|
137
|
-
in_stock: { [productId]: true },
|
|
138
|
-
eligibility_groups: { [productId]: ['subscription', 'upsell', 'prepaid'] },
|
|
139
|
-
result: 'success',
|
|
140
|
-
autoship: { [productId]: true },
|
|
141
|
-
autoship_by_default: { [productId]: false },
|
|
142
|
-
modifiers: {},
|
|
143
|
-
module_view: { regular: '096135e6650111e9a444bc764e106cf4' },
|
|
144
|
-
incentives_display: {
|
|
145
|
-
'47c01e9aacbe40389b5c7325d79091aa': {
|
|
146
|
-
field: 'sub_total',
|
|
147
|
-
object: 'order',
|
|
148
|
-
type: 'Discount Percent',
|
|
149
|
-
value: 5
|
|
150
|
-
},
|
|
151
|
-
e6534b9d877f41e586c37b7d8abc3a58: {
|
|
152
|
-
field: 'total_price',
|
|
153
|
-
object: 'item',
|
|
154
|
-
type: 'Discount Percent',
|
|
155
|
-
value: 10
|
|
156
|
-
},
|
|
157
|
-
f35e842710b24929922db4a529eecd40: {
|
|
158
|
-
field: 'total_price',
|
|
159
|
-
object: 'item',
|
|
160
|
-
type: 'Discount Percent',
|
|
161
|
-
value: 10
|
|
162
|
-
},
|
|
163
|
-
'5be321d7c17f4e18a757212b9a20bfcc': {
|
|
164
|
-
field: 'total_price',
|
|
165
|
-
object: 'item',
|
|
166
|
-
type: 'Discount Percent',
|
|
167
|
-
value: 1
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
incentives: {
|
|
171
|
-
[productId]: {
|
|
172
|
-
initial: ['5be321d7c17f4e18a757212b9a20bfcc'],
|
|
173
|
-
ongoing: [
|
|
174
|
-
'e6534b9d877f41e586c37b7d8abc3a58',
|
|
175
|
-
'47c01e9aacbe40389b5c7325d79091aa',
|
|
176
|
-
'f35e842710b24929922db4a529eecd40'
|
|
177
|
-
]
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
offer
|
|
182
|
-
)
|
|
183
|
-
);
|
|
184
|
-
await dispatch({
|
|
185
|
-
type: constants.ADD_PRODUCT_PLANS,
|
|
186
|
-
payload: {
|
|
187
|
-
[productId]: [
|
|
188
|
-
{
|
|
189
|
-
frequency: '1_3',
|
|
190
|
-
regularPrice: '$15.00',
|
|
191
|
-
subscriptionPrice: '$12.00',
|
|
192
|
-
discountRate: '25%',
|
|
193
|
-
prepaidShipments: 3,
|
|
194
|
-
regularPrepaidPrice: '$36.00',
|
|
195
|
-
prepaidSavingsPerShipment: '$3.00',
|
|
196
|
-
prepaidSavingsTotal: '$9.00',
|
|
197
|
-
prepaidExtraSavingsPercentage: '10%'
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
frequency: '1_3',
|
|
201
|
-
regularPrice: '$15.00',
|
|
202
|
-
subscriptionPrice: '$12.00',
|
|
203
|
-
discountRate: '20%',
|
|
204
|
-
prepaidShipments: 6,
|
|
205
|
-
regularPrepaidPrice: '$72.00',
|
|
206
|
-
prepaidSavingsPerShipment: '$3.00',
|
|
207
|
-
prepaidSavingsTotal: '$18.00',
|
|
208
|
-
prepaidExtraSavingsPercentage: '10%'
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
frequency: '1_3',
|
|
212
|
-
regularPrice: '$15.00',
|
|
213
|
-
subscriptionPrice: '$12.00',
|
|
214
|
-
discountRate: '20%',
|
|
215
|
-
prepaidShipments: 12,
|
|
216
|
-
regularPrepaidPrice: '$144.00',
|
|
217
|
-
prepaidSavingsPerShipment: '$3.00',
|
|
218
|
-
prepaidSavingsTotal: '$36.00',
|
|
219
|
-
prepaidExtraSavingsPercentage: '10%'
|
|
220
|
-
}
|
|
221
|
-
]
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
await dispatch({
|
|
225
|
-
type: constants.SET_CONFIG,
|
|
226
|
-
payload: {
|
|
227
|
-
prepaidSellingPlans: {
|
|
228
|
-
[productId]: [
|
|
229
|
-
{
|
|
230
|
-
numberShipments: 3,
|
|
231
|
-
sellingPlan: '1_3'
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
numberShipments: 6,
|
|
235
|
-
sellingPlan: '1_3'
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
numberShipments: 12,
|
|
239
|
-
sellingPlan: '1_3'
|
|
240
|
-
}
|
|
241
|
-
]
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
};
|
|
246
|
-
|
|
247
125
|
export const setPreview = (value, oldValue, offer) =>
|
|
248
126
|
async function(dispatch, getState) {
|
|
249
127
|
await dispatch({ type: constants.LOCAL_STORAGE_CLEAR });
|
|
@@ -267,11 +145,6 @@ export const setPreview = (value, oldValue, offer) =>
|
|
|
267
145
|
dispatch(setPreviewStandardOffer(true, offer.product.id, offer));
|
|
268
146
|
dispatch(optinProduct(offer.product, '2_2'));
|
|
269
147
|
break;
|
|
270
|
-
case 'prepaid':
|
|
271
|
-
dispatch(setPreviewPrepaid(true, offer.product.id, offer));
|
|
272
|
-
// Prepaid needs to be subscribed to appear
|
|
273
|
-
dispatch(optinProduct(offer.product, '1_3'));
|
|
274
|
-
break;
|
|
275
148
|
default:
|
|
276
149
|
}
|
|
277
150
|
};
|
package/src/core/adapters.js
CHANGED
|
@@ -75,17 +75,4 @@ export const getObjectStructuredProductPlans = (productPlans = {}) => {
|
|
|
75
75
|
return adaptedProductPlans;
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
-
export
|
|
79
|
-
Object.entries(newProductPlans).forEach(([key, value]) => {
|
|
80
|
-
if (Object.prototype.hasOwnProperty.call(state, key)) {
|
|
81
|
-
const mergedArray = state[key].concat(value);
|
|
82
|
-
const uniqueArray = [...new Set(mergedArray.map(item => JSON.stringify(item)))];
|
|
83
|
-
state[key] = uniqueArray.map(item => JSON.parse(item));
|
|
84
|
-
} else {
|
|
85
|
-
state[key] = value;
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
return state;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export default { getProductsForPurchasePost, getObjectStructuredProductPlans, mergeProductPlansToState };
|
|
78
|
+
export default { getProductsForPurchasePost, getObjectStructuredProductPlans };
|
package/src/core/constants.js
CHANGED
|
@@ -31,7 +31,6 @@ export const SET_LOCALE = 'SET_LOCALE';
|
|
|
31
31
|
export const SET_CONFIG = 'SET_CONFIG';
|
|
32
32
|
export const SET_PREVIEW_STANDARD_OFFER = 'SET_PREVIEW_STANDARD_OFFER';
|
|
33
33
|
export const SET_PREVIEW_UPSELL_OFFER = 'SET_PREVIEW_UPSELL_OFFER';
|
|
34
|
-
export const SET_PREVIEW_PREPAID_OFFER = 'SET_PREVIEW_PREPAID_OFFER';
|
|
35
34
|
export const ADD_TEMPLATE = 'ADD_TEMPLATE';
|
|
36
35
|
export const SET_TEMPLATES = 'SET_TEMPLATES';
|
|
37
36
|
export const LOCAL_STORAGE_CHANGE = 'LOCAL_STORAGE_CHANGE';
|
|
@@ -39,7 +38,6 @@ export const LOCAL_STORAGE_CLEAR = 'LOCAL_STORAGE_CLEAR';
|
|
|
39
38
|
export const SET_FIRST_ORDER_PLACE_DATE = 'SET_FIRST_ORDER_PLACE_DATE';
|
|
40
39
|
export const SET_PRODUCT_TO_SUBSCRIBE = 'SET_PRODUCT_TO_SUBSCRIBE';
|
|
41
40
|
export const RECEIVE_PRODUCT_PLANS = 'RECEIVE_PRODUCT_PLANS';
|
|
42
|
-
export const ADD_PRODUCT_PLANS = 'ADD_PRODUCT_PLANS';
|
|
43
41
|
export const SETUP_PRODUCT = 'SETUP_PRODUCT';
|
|
44
42
|
export const SETUP_CART = 'SETUP_CART';
|
|
45
43
|
export const DEFAULT_OFFER_MODULE = 'pdp';
|