Skip to content

Commit

Permalink
fix(ts): upi formatProps ts error (#2775)
Browse files Browse the repository at this point in the history
  • Loading branch information
longyulongyu authored Aug 2, 2024
1 parent a7fd00f commit e4c4569
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/rare-flies-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@adyen/adyen-web': patch
---

Fix TS error for UPI `formatProps`
9 changes: 4 additions & 5 deletions packages/lib/src/components/UPI/UPI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import UPIComponent from './components/UPIComponent';
import { CoreProvider } from '../../core/Context/CoreProvider';
import Await from '../internal/Await';
import QRLoader from '../internal/QRLoader';
import { UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';
import { App, UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';
import SRPanelProvider from '../../core/Errors/SRPanelProvider';
import { TxVariants } from '../tx-variants';
import isMobile from '../../utils/isMobile';
Expand All @@ -31,7 +31,6 @@ class UPI extends UIElement<UPIConfiguration> {
this.selectedMode = this.props.defaultMode;
}

// @ts-ignore fix later
formatProps(props: UPIConfiguration) {
if (!isMobile()) {
return {
Expand All @@ -45,12 +44,12 @@ class UPI extends UIElement<UPIConfiguration> {
const hasIntentApps = props.apps?.length > 0;
const fallbackDefaultMode = hasIntentApps ? 'intent' : 'vpa';
const allowedModes = [fallbackDefaultMode, 'qrCode'];
const upiCollectApp = {
const upiCollectApp: App = {
id: 'vpa',
name: props.i18n.get('upi.collect.dropdown.label'),
type: TxVariants.upi_collect
type: TxVariants.upi_collect as UpiType
};
const apps = hasIntentApps ? [...props.apps.map(app => ({ ...app, type: TxVariants.upi_intent })), upiCollectApp] : [];
const apps = hasIntentApps ? [...props.apps.map(app => ({ ...app, type: TxVariants.upi_intent as UpiType })), upiCollectApp] : [];
return {
...super.formatProps(props),
defaultMode: allowedModes.includes(props?.defaultMode) ? props.defaultMode : fallbackDefaultMode,
Expand Down

0 comments on commit e4c4569

Please sign in to comment.