@rebilly/instruments 3.23.0-beta.0 → 3.23.0-beta.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/dist/index.js +17 -10
- package/dist/index.min.js +56 -49
- package/package.json +1 -3
- package/src/functions/destroy.js +9 -11
- package/src/functions/mount/fetch-data.js +16 -14
- package/src/functions/mount/fetch-data.spec.js +93 -140
- package/src/functions/mount/index.js +10 -9
- package/src/functions/mount/mount.spec.js +7 -5
- package/src/functions/mount/setup-framepay-theme.js +1 -2
- package/src/functions/mount/setup-framepay.js +1 -3
- package/src/functions/mount/setup-i18n.js +2 -4
- package/src/functions/mount/setup-options.js +4 -6
- package/src/functions/on.spec.js +2 -3
- package/src/functions/purchase.js +5 -16
- package/src/functions/setup.js +4 -3
- package/src/functions/show.js +6 -7
- package/src/functions/show.spec.js +7 -11
- package/src/functions/update.js +3 -3
- package/src/functions/update.spec.js +3 -4
- package/src/instance.js +31 -11
- package/src/storefront/account-and-website.js +2 -3
- package/src/storefront/{fetch-plans-from-addons-bumpOffer.js → fetch-plans-from-addons-bumpOffers.js} +4 -5
- package/src/storefront/fetch-products-from-plans.js +4 -5
- package/src/storefront/index.js +4 -3
- package/src/storefront/invoices.js +4 -6
- package/src/storefront/payment-instruments.js +4 -5
- package/src/storefront/purchase.js +4 -5
- package/src/storefront/ready-to-pay.js +2 -2
- package/src/storefront/summary.js +3 -8
- package/src/storefront/transactions.js +2 -3
- package/src/style/base/index.js +0 -243
- package/src/views/common/iframe/base-iframe.js +2 -0
- package/src/views/common/iframe/events/update-addons-handler.js +13 -8
- package/src/views/common/iframe/events/update-coupons-handler.js +11 -5
- package/src/views/confirmation.js +6 -16
- package/src/views/method-selector/__snapshots__/method-selector.spec.js.snap +1 -182
- package/src/views/method-selector/generate-digital-wallet.js +1 -2
- package/src/views/method-selector/generate-digital-wallet.spec.js +37 -32
- package/src/views/method-selector/generate-framepay-config.js +1 -1
- package/src/views/method-selector/generate-framepay-config.spec.js +12 -9
- package/src/views/method-selector/get-payment-methods.js +1 -3
- package/src/views/method-selector/get-payment-methods.spec.js +34 -25
- package/src/views/method-selector/index.js +20 -39
- package/src/views/method-selector/method-selector.spec.js +109 -9
- package/src/views/method-selector/mount-express-methods.js +2 -1
- package/src/views/modal.js +3 -3
- package/src/views/result.js +5 -7
- package/src/views/summary.js +16 -12
- package/tests/mocks/rebilly-instruments-mock.js +19 -17
- package/tests/mocks/storefront-mock.js +9 -10
- package/tests/setup-jest.js +0 -2
- package/src/state/iframes.js +0 -23
- package/src/state/index.js +0 -61
- package/src/views/method-selector/mount-bump-offer.js +0 -99
package/src/state/index.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { reactive } from '@vue/reactivity';
|
|
2
|
-
import { Loader } from '../loader';
|
|
3
|
-
import { Translate } from '../i18n';
|
|
4
|
-
import iframes from './iframes';
|
|
5
|
-
|
|
6
|
-
export default (() => {
|
|
7
|
-
let state = null;
|
|
8
|
-
const defaultState = {
|
|
9
|
-
options: null,
|
|
10
|
-
data: {},
|
|
11
|
-
mountingPoints: null,
|
|
12
|
-
storefront: null,
|
|
13
|
-
form: null,
|
|
14
|
-
summary: null,
|
|
15
|
-
loader: new Loader(),
|
|
16
|
-
translate: new Translate,
|
|
17
|
-
hasMounted: false,
|
|
18
|
-
toModel() {
|
|
19
|
-
const model = {
|
|
20
|
-
...state,
|
|
21
|
-
data: state.data.toPostmatesMode ? state.data.toPostmatesModel() : {},
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// remove functions from model
|
|
25
|
-
delete model.toModel;
|
|
26
|
-
delete model.updateModel;
|
|
27
|
-
|
|
28
|
-
return JSON.parse(JSON.stringify(model));
|
|
29
|
-
},
|
|
30
|
-
updateModel() {
|
|
31
|
-
const modelSafeState = state?.toModel();
|
|
32
|
-
if (modelSafeState) {
|
|
33
|
-
const updateModel = {
|
|
34
|
-
data: modelSafeState.data,
|
|
35
|
-
options: modelSafeState.options
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (iframes.hasComponent('summary')) {
|
|
39
|
-
iframes.summary.component.call('update', updateModel);
|
|
40
|
-
}
|
|
41
|
-
if (iframes.hasComponent('summary')) {
|
|
42
|
-
iframes.form.component.call('update', updateModel);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
reset() {
|
|
47
|
-
if (state !== null) {
|
|
48
|
-
state = reactive({...defaultState});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
getInstance() {
|
|
55
|
-
if (state === null) {
|
|
56
|
-
state = reactive({...defaultState});
|
|
57
|
-
}
|
|
58
|
-
return state;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
})().getInstance();
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import state from '../../state';
|
|
2
|
-
import formatCurrency from '../../utils/format-currency';
|
|
3
|
-
import {fetchSummary} from '../../storefront/summary'
|
|
4
|
-
|
|
5
|
-
function lineItem({offer}) {
|
|
6
|
-
const plan = state.data.plans.find(item => item.id === offer.planId);
|
|
7
|
-
const product = state.data.products.find(item => item.id === plan.productId);
|
|
8
|
-
|
|
9
|
-
const rif = (condition, template) => condition ? template : '';
|
|
10
|
-
|
|
11
|
-
function unitPrice() {
|
|
12
|
-
const planPricing = plan.pricing.isBracket
|
|
13
|
-
? plan.pricing.brackets[0].price
|
|
14
|
-
: plan.pricing.price;
|
|
15
|
-
|
|
16
|
-
const basePrice = formatCurrency(planPricing, plan.currency);
|
|
17
|
-
return plan.pricing.isBracket ? `Starting at ${basePrice}` : basePrice;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const thumbnail = (item) => rif(item.thumbnail, `
|
|
21
|
-
<figure class="rebilly-instruments-bump-offer-line-item-figure">
|
|
22
|
-
<img src="${item.thumbnail}" :alt="${item.name}"/>
|
|
23
|
-
</figure>
|
|
24
|
-
`);
|
|
25
|
-
|
|
26
|
-
const synopsis = (item) => `
|
|
27
|
-
<div class="rebilly-instruments-bump-offer-line-item-synopsis">
|
|
28
|
-
<p class="rebilly-instruments-bump-offer-line-item-synopsis-title">
|
|
29
|
-
${item.name}
|
|
30
|
-
</p>
|
|
31
|
-
${rif(item.description, `
|
|
32
|
-
<p class="rebilly-instruments-bump-offer-line-item-synopsis-description">
|
|
33
|
-
${item.description}
|
|
34
|
-
</p>
|
|
35
|
-
`)}
|
|
36
|
-
</div>
|
|
37
|
-
`;
|
|
38
|
-
|
|
39
|
-
const breakdown = (item) => `
|
|
40
|
-
<div class="rebilly-instruments-bump-offer-line-item-price-breakdown">
|
|
41
|
-
${rif(item.quantity, `
|
|
42
|
-
<p class="rebilly-instruments-bump-offer-line-item-price-breakdown-quantity">
|
|
43
|
-
${item.quantity}
|
|
44
|
-
</p>
|
|
45
|
-
<svg class="rebilly-instruments-icon" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
46
|
-
<path d="M12 10.5858l2.8284-2.8284c.3906-.3906 1.0237-.3906 1.4142 0 .3906.3905.3906 1.0236 0 1.4142L13.4142 12l2.8284 2.8284c.3906.3906.3906 1.0237 0 1.4142-.3905.3906-1.0236.3906-1.4142 0L12 13.4142l-2.8284 2.8284c-.3906.3906-1.0237.3906-1.4142 0-.3906-.3905-.3906-1.0236 0-1.4142L10.5858 12 7.7574 9.1716c-.3906-.3906-.3906-1.0237 0-1.4142.3905-.3906 1.0236-.3906 1.4142 0L12 10.5858z" fill-rule="nonzero"/>
|
|
47
|
-
</svg>
|
|
48
|
-
`)}
|
|
49
|
-
<p class="rebilly-instruments-bump-offer-line-item-price-breakdown-unit-price">
|
|
50
|
-
${item.unitPrice}
|
|
51
|
-
</p>
|
|
52
|
-
<div>
|
|
53
|
-
`;
|
|
54
|
-
|
|
55
|
-
const line = {
|
|
56
|
-
...offer,
|
|
57
|
-
quantity: plan.pricing.isBracket ? null : offer.quantity,
|
|
58
|
-
name: product.name,
|
|
59
|
-
description: plan.name,
|
|
60
|
-
unitPrice: unitPrice(),
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return `
|
|
64
|
-
<div class="rebilly-instruments-bump-offer-line-item">
|
|
65
|
-
${thumbnail(line)}
|
|
66
|
-
${synopsis(line)}
|
|
67
|
-
${breakdown(line)}
|
|
68
|
-
</div>
|
|
69
|
-
`
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export function mountBumpOffer ({container}) {
|
|
73
|
-
container.insertAdjacentHTML('beforeEnd', `
|
|
74
|
-
<label for="rebilly-instruments-bump-offer" class="rebilly-instruments-form-field-checkbox">
|
|
75
|
-
<div class="rebilly-instruments-bump-offer-label">Yes, I want to upgrade!</div>
|
|
76
|
-
<input
|
|
77
|
-
type="checkbox"
|
|
78
|
-
id="rebilly-instruments-bump-offer"
|
|
79
|
-
/>
|
|
80
|
-
<span></span>
|
|
81
|
-
</label>
|
|
82
|
-
`);
|
|
83
|
-
|
|
84
|
-
const checkbox = document.getElementById('rebilly-instruments-bump-offer')
|
|
85
|
-
checkbox.addEventListener('click', async () => {
|
|
86
|
-
state.data.acceptBumpOffer = checkbox.checked;
|
|
87
|
-
await fetchSummary();
|
|
88
|
-
state.updateModel();
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
checkbox.checked = state.data.acceptBumpOffer;
|
|
92
|
-
|
|
93
|
-
state.options.bumpOffer.forEach(offer => {
|
|
94
|
-
const node = document.createElement('div');
|
|
95
|
-
node.classList.add('rebilly-instruments-bump-offer');
|
|
96
|
-
node.insertAdjacentHTML('beforeEnd', lineItem({offer}));
|
|
97
|
-
container.appendChild(node);
|
|
98
|
-
});
|
|
99
|
-
}
|