PluginProbe
Pay with Vipps and MobilePay for WooCommerce / 6.2.6
Pay with Vipps and MobilePay for WooCommerce v6.2.6
6.2.6 6.3.0 6.2.5 6.2.4 6.2.3 6.2.2 6.2.1 6.2.0 6.1.10 6.1.9 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1.0 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 6.0.0 All 189 releases
woo-vipps / payment / src / Blocks / src / vipps-badge / save.tsx

save.tsx in Pay with Vipps and MobilePay for WooCommerce 6.2.6, at payment/src/Blocks/src/vipps-badge/save.tsx

49 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import type { BlockSaveProps } from '@wordpress/blocks';
2 import { useBlockProps } from '@wordpress/block-editor';
3
4 import type { VippsBadgeBlockAttributes, VippsBadgeBlockConfig } from './types';
5
6 declare var injectedVippsBadgeBlockConfig: VippsBadgeBlockConfig;
7 const blockConfig = injectedVippsBadgeBlockConfig;
8
9 export default function save({
10 attributes,
11 }: BlockSaveProps<VippsBadgeBlockAttributes>) {
12 // Let the user choose the variant. If the current one isn't in the list, add it (though we don't know the label then. IOK 2020-12-18
13 const variantOptions = blockConfig.variants;
14 const current = attributes.variant;
15 let found = false;
16 for (let i = 0; i < variantOptions.length; i++) {
17 if (current == variantOptions[i].value) {
18 found = true;
19 break;
20 }
21 }
22 if (!found) variantOptions.push({ label: current, value: current });
23 const attrs = {
24 variant: current,
25 // Looks like button and badge web components now use 'da' instead of 'dk' for danish. LP 2026-08-11
26 language: 'dk' === attributes.language ? 'da' : attributes.language,
27 brand: blockConfig.brand,
28 };
29
30 let extraclass =
31 attributes.className && attributes.className !== 'undefined'
32 ? attributes.className
33 : '';
34
35 return (
36 <>
37 <div
38 {...useBlockProps.save({
39 className: 'vipps-badge-wrapper ' + extraclass,
40 })}
41 >
42 {/* <vipps-badge> is a web component that is enqueued with slug vipps-onsite-messageing. LP 18.11.2024 */}
43 {/* @ts-ignore */}
44 <vipps-mobilepay-badge {...attrs} />
45 </div>
46 </>
47 );
48 }
49