From dec82f802f34360a19ffac0692d400661c19190c Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Mon, 14 Aug 2023 18:54:37 +0200 Subject: [PATCH] refactor: move types to config from client (#51266) --- client/src/components/Donation/donate-form.tsx | 6 +++--- client/src/components/Donation/paypal-button.tsx | 11 ++++------- client/src/components/Donation/types.ts | 7 ------- config/donation-settings.ts | 10 +++++++--- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/client/src/components/Donation/donate-form.tsx b/client/src/components/Donation/donate-form.tsx index f90abe3c053..c9168e9bd1e 100644 --- a/client/src/components/Donation/donate-form.tsx +++ b/client/src/components/Donation/donate-form.tsx @@ -11,7 +11,8 @@ import { amountsConfig, durationsConfig, defaultDonation, - modalDefaultDonation + modalDefaultDonation, + type DonationConfig } from '../../../../config/donation-settings'; import { defaultDonationFormState } from '../../redux'; import { updateDonationFormState, postCharge } from '../../redux/actions'; @@ -35,8 +36,7 @@ import { PaymentContext, PostPayment, HandleAuthentication, - DonationApprovalData, - DonationConfig + DonationApprovalData } from './types'; import './donation.css'; diff --git a/client/src/components/Donation/paypal-button.tsx b/client/src/components/Donation/paypal-button.tsx index 3e54d4fd119..4cd8bb0fb8e 100644 --- a/client/src/components/Donation/paypal-button.tsx +++ b/client/src/components/Donation/paypal-button.tsx @@ -6,17 +6,14 @@ import { paypalConfigurator, paypalConfigTypes, defaultDonation, - PaymentProvider + PaymentProvider, + type DonationDuration, + type DonationAmount } from '../../../../config/donation-settings'; import envData from '../../../../config/env.json'; import { userSelector, signInLoadingSelector } from '../../redux/selectors'; import { Themes } from '../settings/theme'; -import { - DonationApprovalData, - PostPayment, - DonationDuration, - DonationAmount -} from './types'; +import { DonationApprovalData, PostPayment } from './types'; import PayPalButtonScriptLoader from './paypal-button-script-loader'; type PaypalButtonProps = { diff --git a/client/src/components/Donation/types.ts b/client/src/components/Donation/types.ts index 956c8da1518..b07060d2b2a 100644 --- a/client/src/components/Donation/types.ts +++ b/client/src/components/Donation/types.ts @@ -8,13 +8,6 @@ export type HandleAuthentication = ( paymentMethod: string ) => Promise; -export type DonationAmount = 500 | 1000 | 2000 | 3000 | 4000 | 5000; -export type DonationDuration = 'one-time' | 'month'; -export interface DonationConfig { - donationAmount: DonationAmount; - donationDuration: DonationDuration; -} - export interface PostPayment { paymentProvider: PaymentProvider; data?: DonationApprovalData; diff --git a/config/donation-settings.ts b/config/donation-settings.ts index 723b2e0c379..3b08af927c1 100644 --- a/config/donation-settings.ts +++ b/config/donation-settings.ts @@ -1,5 +1,11 @@ // Configuration for client side -import { DonationConfig } from '../client/src/components/Donation/types'; + +export type DonationAmount = 500 | 1000 | 2000 | 3000 | 4000 | 5000; +export type DonationDuration = 'one-time' | 'month'; +export interface DonationConfig { + donationAmount: DonationAmount; + donationDuration: DonationDuration; +} export const durationsConfig: { month: 'monthly'; @@ -80,8 +86,6 @@ export const paypalConfigTypes = { } }; -type DonationAmount = 500 | 1000 | 2000 | 3000 | 4000 | 5000; - interface OneTimeConfig { amount: DonationAmount; duration: 'one-time';