diff --git a/packages/common/src/hooks/purchaseContent/usePayExtraPresets.ts b/packages/common/src/hooks/purchaseContent/usePayExtraPresets.ts index 7fe10640e9b..3dc6e518086 100644 --- a/packages/common/src/hooks/purchaseContent/usePayExtraPresets.ts +++ b/packages/common/src/hooks/purchaseContent/usePayExtraPresets.ts @@ -8,8 +8,8 @@ import { useRemoteVar } from '../useRemoteVar' import { PayExtraAmountPresetValues, PayExtraPreset } from './types' /** Extracts and parses the Pay Extra presets from remote config */ -export const usePayExtraPresets = (key: StringKeys) => { - const configValue = useRemoteVar(key) +export const usePayExtraPresets = () => { + const configValue = useRemoteVar(StringKeys.PAY_EXTRA_PRESET_CENT_AMOUNTS) return useMemo(() => { const [low, medium, high] = parseIntList(configValue) return { diff --git a/packages/common/src/services/remote-config/defaults.ts b/packages/common/src/services/remote-config/defaults.ts index 6936a49f2ed..973b68e6377 100644 --- a/packages/common/src/services/remote-config/defaults.ts +++ b/packages/common/src/services/remote-config/defaults.ts @@ -90,7 +90,6 @@ export const remoteConfigStringDefaults: { [StringKeys.STRIPE_ALLOWED_COUNTRIES_2_LETTER]: '', [StringKeys.AUDIO_FEATURES_DEGRADED_TEXT]: null, [StringKeys.PAY_EXTRA_PRESET_CENT_AMOUNTS]: '200,500,1000', - [StringKeys.COINFLOW_ADD_FUNDS_PRESET_CENT_AMOUNTS]: '200,500,1000', [StringKeys.EXPLORE_PREMIUM_DENIED_USERS]: '' } diff --git a/packages/common/src/services/remote-config/types.ts b/packages/common/src/services/remote-config/types.ts index 54e83dc577d..8aba637304e 100644 --- a/packages/common/src/services/remote-config/types.ts +++ b/packages/common/src/services/remote-config/types.ts @@ -390,10 +390,7 @@ export enum StringKeys { PAY_EXTRA_PRESET_CENT_AMOUNTS = 'PAY_EXTRA_PRESET_CENT_AMOUNTS', /** Denylist of user ids for explore premium tracks page */ - EXPLORE_PREMIUM_DENIED_USERS = 'EXPLORE_PREMIUM_DENIED_USERS', - - /** Add funds preset amounts for Coinflow */ - COINFLOW_ADD_FUNDS_PRESET_CENT_AMOUNTS = 'COINFLOW_ADD_FUNDS_PRESET_CENT_AMOUNTS' + EXPLORE_PREMIUM_DENIED_USERS = 'EXPLORE_PREMIUM_DENIED_USERS' } export type AllRemoteConfigKeys = diff --git a/packages/mobile/src/components/premium-track-purchase-drawer/PremiumTrackPurchaseDrawer.tsx b/packages/mobile/src/components/premium-track-purchase-drawer/PremiumTrackPurchaseDrawer.tsx index ab9f6a384cf..6d71bbbfb18 100644 --- a/packages/mobile/src/components/premium-track-purchase-drawer/PremiumTrackPurchaseDrawer.tsx +++ b/packages/mobile/src/components/premium-track-purchase-drawer/PremiumTrackPurchaseDrawer.tsx @@ -23,8 +23,7 @@ import { usePurchaseContentFormConfiguration, usePurchaseMethod, useUSDCBalance, - PURCHASE_VENDOR, - StringKeys + PURCHASE_VENDOR } from '@audius/common' import { Formik, useField, useFormikContext } from 'formik' import { @@ -235,9 +234,7 @@ const RenderForm = ({ const styles = useStyles() const dispatch = useDispatch() const { specialLightGreen, primary } = useThemeColors() - const presetValues = usePayExtraPresets( - StringKeys.PAY_EXTRA_PRESET_CENT_AMOUNTS - ) + const presetValues = usePayExtraPresets() const { isEnabled: isIOSUSDCPurchaseEnabled } = useFeatureFlag( FeatureFlags.IOS_USDC_PURCHASE_ENABLED ) @@ -401,10 +398,7 @@ export const PremiumTrackPurchaseDrawer = () => { const styles = useStyles() const dispatch = useDispatch() const isUSDCEnabled = useIsUSDCEnabled() - const presetValues = usePayExtraPresets( - StringKeys.PAY_EXTRA_PRESET_CENT_AMOUNTS - ) - + const presetValues = usePayExtraPresets() const { data: { contentId: trackId }, isOpen, diff --git a/packages/mobile/src/components/premium-track-purchase-drawer/hooks/usePurchaseSummaryValues.ts b/packages/mobile/src/components/premium-track-purchase-drawer/hooks/usePurchaseSummaryValues.ts index 21715108c86..dd07819131a 100644 --- a/packages/mobile/src/components/premium-track-purchase-drawer/hooks/usePurchaseSummaryValues.ts +++ b/packages/mobile/src/components/premium-track-purchase-drawer/hooks/usePurchaseSummaryValues.ts @@ -6,8 +6,7 @@ import { getPurchaseSummaryValues, PayExtraPreset, usePayExtraPresets, - useUSDCPurchaseConfig, - StringKeys + useUSDCPurchaseConfig } from '@audius/common' import { useField } from 'formik' @@ -20,9 +19,7 @@ export const usePurchaseSummaryValues = ({ }) => { const [{ value: customAmount }] = useField(CUSTOM_AMOUNT) const [{ value: amountPreset }] = useField(AMOUNT_PRESET) - const presetValues = usePayExtraPresets( - StringKeys.PAY_EXTRA_PRESET_CENT_AMOUNTS - ) + const presetValues = usePayExtraPresets() const { minUSDCPurchaseAmountCents } = useUSDCPurchaseConfig() const extraAmount = getExtraAmount({ diff --git a/packages/web/src/components/add-funds-modal/AddFundsModal.tsx b/packages/web/src/components/add-funds-modal/AddFundsModal.tsx index fdca798b4be..19244ad7f8c 100644 --- a/packages/web/src/components/add-funds-modal/AddFundsModal.tsx +++ b/packages/web/src/components/add-funds-modal/AddFundsModal.tsx @@ -5,17 +5,11 @@ import { buyUSDCActions, PurchaseMethod, DEFAULT_PURCHASE_AMOUNT_CENTS, - PurchaseVendor, - PayExtraPreset, - getExtraAmount, - StringKeys, - usePayExtraPresets + PurchaseVendor } from '@audius/common' import { ModalContent, ModalHeader } from '@audius/stems' import cn from 'classnames' -import { Formik } from 'formik' import { useDispatch } from 'react-redux' -import { toFormikValidationSchema } from 'zod-formik-adapter' import { AddFunds } from 'components/add-funds/AddFunds' import { Text } from 'components/typography' @@ -25,7 +19,6 @@ import { isMobile } from 'utils/clientUtil' import zIndex from 'utils/zIndex' import styles from './AddFundsModal.module.css' -import { AddFundsSchema } from './validation' const messages = { addFunds: 'Add Funds', @@ -40,30 +33,13 @@ export const AddFundsModal = () => { const mobile = isMobile() const [page, setPage] = useState('add-funds') - const presetValues = usePayExtraPresets( - StringKeys.COINFLOW_ADD_FUNDS_PRESET_CENT_AMOUNTS - ) - const initialValues = { - AMOUNT_PRESET: PayExtraPreset.NONE, - CUSTOM_AMOUNT: undefined - } const handleClosed = useCallback(() => { setPage('add-funds') }, [setPage]) const handleContinue = useCallback( - ({ - purchaseMethod, - purchaseVendor, - amountPreset = PayExtraPreset.NONE, - customAmount - }: { - purchaseMethod: PurchaseMethod - purchaseVendor?: PurchaseVendor - amountPreset?: PayExtraPreset - customAmount?: number - }) => { + (purchaseMethod: PurchaseMethod, purchaseVendor?: PurchaseVendor) => { switch (purchaseMethod) { case PurchaseMethod.CRYPTO: setPage('crypto-transfer') @@ -73,14 +49,7 @@ export const AddFundsModal = () => { buyUSDCActions.onrampOpened({ vendor: purchaseVendor || PurchaseVendor.STRIPE, purchaseInfo: { - desiredAmount: - amountPreset !== PayExtraPreset.NONE - ? getExtraAmount({ - amountPreset, - presetValues, - customAmount - }) - : DEFAULT_PURCHASE_AMOUNT_CENTS + desiredAmount: DEFAULT_PURCHASE_AMOUNT_CENTS } }) ) @@ -90,7 +59,7 @@ export const AddFundsModal = () => { throw new Error('Add funds not supported with existing balance') } }, - [dispatch, presetValues] + [setPage, dispatch] ) return ( @@ -122,13 +91,7 @@ export const AddFundsModal = () => { {page === 'add-funds' ? ( - undefined} // Not using formik for submit - > - - + ) : ( setPage('add-funds')} /> )} diff --git a/packages/web/src/components/add-funds-modal/constants.ts b/packages/web/src/components/add-funds-modal/constants.ts deleted file mode 100644 index 60d9b0e2313..00000000000 --- a/packages/web/src/components/add-funds-modal/constants.ts +++ /dev/null @@ -1,9 +0,0 @@ -export const AMOUNT_PRESET = 'amountPreset' -export const CUSTOM_AMOUNT = 'customAmount' - -// Pay between $1 and $100 extra -export const minimumPayExtraAmountCents = 100 -export const maximumPayExtraAmountCents = 10000 - -export const CENTS_TO_USDC_MULTIPLIER = 10000 -export const DEFAULT_PURCHASE_AMOUNT_CENTS = 10 * 100 diff --git a/packages/web/src/components/add-funds-modal/types.ts b/packages/web/src/components/add-funds-modal/types.ts deleted file mode 100644 index 3a09c8c6195..00000000000 --- a/packages/web/src/components/add-funds-modal/types.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** Denotes the 3 preset amounts to show on the form, values are in cents. */ -export type PayExtraAmountPresetValues = { - [PayExtraPreset.LOW]: number - [PayExtraPreset.MEDIUM]: number - [PayExtraPreset.HIGH]: number -} - -export enum PayExtraPreset { - LOW = 'low', - MEDIUM = 'medium', - HIGH = 'high', - CUSTOM = 'custom', - NONE = 'none' -} diff --git a/packages/web/src/components/add-funds-modal/validation.ts b/packages/web/src/components/add-funds-modal/validation.ts deleted file mode 100644 index 4d4e051e40b..00000000000 --- a/packages/web/src/components/add-funds-modal/validation.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { z } from 'zod' - -import { - AMOUNT_PRESET, - CUSTOM_AMOUNT, - maximumPayExtraAmountCents, - minimumPayExtraAmountCents -} from './constants' -import { PayExtraPreset } from './types' - -const messages = { - amountInvalid: 'Please specify an amount between $1 and $100' -} - -const createPurchaseContentSchema = () => { - return z - .object({ - [CUSTOM_AMOUNT]: z - .number({ - required_error: messages.amountInvalid, - invalid_type_error: messages.amountInvalid - }) - .optional(), - [AMOUNT_PRESET]: z.nativeEnum(PayExtraPreset) - }) - .refine( - ({ amountPreset, customAmount }) => { - if (amountPreset !== PayExtraPreset.CUSTOM) return true - return ( - customAmount && - customAmount >= minimumPayExtraAmountCents && - customAmount <= maximumPayExtraAmountCents - ) - }, - { message: messages.amountInvalid, path: [CUSTOM_AMOUNT] } - ) -} - -export const AddFundsSchema = createPurchaseContentSchema() -export type AddFundsValues = z.input diff --git a/packages/web/src/components/add-funds/AddFunds.tsx b/packages/web/src/components/add-funds/AddFunds.tsx index 513cf90f5bc..d032d16a0e0 100644 --- a/packages/web/src/components/add-funds/AddFunds.tsx +++ b/packages/web/src/components/add-funds/AddFunds.tsx @@ -4,9 +4,7 @@ import { PurchaseMethod, PurchaseVendor, useCreateUserbankIfNeeded, - useUSDCBalance, - PayExtraPreset, - CUSTOM_AMOUNT + useUSDCBalance } from '@audius/common' import { USDC } from '@audius/fixed-decimal' import { @@ -19,9 +17,7 @@ import { } from '@audius/harmony' import { BN } from 'bn.js' import cn from 'classnames' -import { useField } from 'formik' -import { AMOUNT_PRESET } from 'components/add-funds-modal/constants' import { PaymentMethod } from 'components/payment-method/PaymentMethod' import { track } from 'services/analytics' import { audiusBackendInstance } from 'services/audius-backend/audius-backend-instance' @@ -37,17 +33,10 @@ const messages = { export const AddFunds = ({ onContinue }: { - onContinue: ({ - purchaseMethod, - purchaseVendor, - amountPreset, - customAmount - }: { - purchaseMethod: PurchaseMethod + onContinue: ( + purchaseMethod: PurchaseMethod, purchaseVendor?: PurchaseVendor - amountPreset?: PayExtraPreset - customAmount?: number - }) => void + ) => void }) => { useCreateUserbankIfNeeded({ recordAnalytics: track, @@ -59,8 +48,6 @@ export const AddFunds = ({ const [selectedPurchaseVendor, setSelectedPurchaseVendor] = useState< PurchaseVendor | undefined >(undefined) - const [{ value: amountPreset }, ,] = useField(AMOUNT_PRESET) - const [{ value: customAmount }, ,] = useField(CUSTOM_AMOUNT) const mobile = isMobile() const { data: balanceBN } = useUSDCBalance({ isPolling: true }) @@ -95,21 +82,14 @@ export const AddFunds = ({