From 7aeb99bc6034f2ca40c80e0c361fccc30336a6f2 Mon Sep 17 00:00:00 2001 From: Ioan Ghisoi Date: Tue, 16 Jul 2024 16:20:31 +0100 Subject: [PATCH] Update language list and add extra condition for checking the window.Frames object --- package.json | 2 +- src/frames/Frames.tsx | 19 +++++++++++-------- src/frames/types/types.tsx | 24 +++++++++++++++++++++++- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 7bfd88b..c8620bd 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "frames-react", - "version": "1.1.1", + "version": "1.1.2", "peerDependencies": { "react": ">=16.8" }, diff --git a/src/frames/Frames.tsx b/src/frames/Frames.tsx index 6d5600d..44d4a17 100755 --- a/src/frames/Frames.tsx +++ b/src/frames/Frames.tsx @@ -29,14 +29,17 @@ export class Frames extends Component { } shouldComponentUpdate(nextProps: FramesProps) { - if (nextProps.config.cardholder && nextProps.config.cardholder.name) { - window.Frames.cardholder.name = nextProps.config.cardholder.name; - } - if (nextProps.config.cardholder && nextProps.config.cardholder.billingAddress) { - window.Frames.cardholder.billingAddress = nextProps.config.cardholder.billingAddress; - } - if (nextProps.config.cardholder && nextProps.config.cardholder.phone) { - window.Frames.cardholder.phone = nextProps.config.cardholder.phone; + if (typeof window !== 'undefined' && window.Frames) { + if (nextProps.config.cardholder && nextProps.config.cardholder.name) { + window.Frames.cardholder.name = nextProps.config.cardholder.name; + } + if (nextProps.config.cardholder && nextProps.config.cardholder.billingAddress) { + window.Frames.cardholder.billingAddress = + nextProps.config.cardholder.billingAddress; + } + if (nextProps.config.cardholder && nextProps.config.cardholder.phone) { + window.Frames.cardholder.phone = nextProps.config.cardholder.phone; + } } return true; } diff --git a/src/frames/types/types.tsx b/src/frames/types/types.tsx index 39a5416..66e5388 100755 --- a/src/frames/types/types.tsx +++ b/src/frames/types/types.tsx @@ -23,7 +23,29 @@ export interface FramesLocalization { cardSchemeHeader?: string; } -export type FramesLanguages = 'EN-GB' | 'ES-ES' | 'FR-FR' | 'DE-DE' | 'KR-KR' | 'IT-IT' | 'NL-NL'; +export type FramesLanguages = + | 'AR' + | 'ZH-CH' + | 'ZH-HK' + | 'ZH-TW' + | 'DA-DK' + | 'NL-NL' + | 'EN-GB' + | 'FIL-PH' + | 'FI-FI' + | 'FR-FR' + | 'DE-DE' + | 'HI-IN' + | 'ID-ID' + | 'IT-IT' + | 'JA-JP' + | 'KO-KR' + | 'MS-MY' + | 'NB-NO' + | 'ES-ES' + | 'SV-SE' + | 'TH-TH' + | 'VI-VN'; export type FrameElementIdentifer = 'card-number' | 'expiry-date' | 'cvv';