// @ts-nocheck import React, { useEffect } from 'react'; import styled from 'styled-components'; import { Button, Classes, Intent, Menu, MenuItem, Popover, Tag, Text, } from '@blueprintjs/core'; import { AppToaster, Box, Card, Group, Stack } from '@/components'; import { StripeLogo } from '@/icons/StripeLogo'; import { PaymentMethodsBoot, usePaymentMethodsBoot, } from './PreferencesPaymentMethodsBoot'; import { StripePreSetupDialog } from './dialogs/StripePreSetupDialog/StripePreSetupDialog'; import { DialogsName } from '@/constants/dialogs'; import { useAlertActions, useChangePreferencesPageTitle, useDialogActions, useDrawerActions, } from '@/hooks/state'; import { useCreateStripeAccountLink } from '@/hooks/query/stripe-integration'; import { StripeIntegrationEditDrawer } from './drawers/StripeIntegrationEditDrawer'; import { DRAWERS } from '@/constants/drawers'; import { MoreIcon } from '@/icons/More'; export default function PreferencesPaymentMethodsPage() { const changePageTitle = useChangePreferencesPageTitle(); useEffect(() => { changePageTitle('Payment Methods'); }, [changePageTitle]); return ( Accept payments from all the major debit and credit card networks through the supported payment gateways. ); } function StripePaymentMethod() { const { openDialog } = useDialogActions(); const { openDrawer } = useDrawerActions(); const { openAlert } = useAlertActions(); const { paymentMethodsState } = usePaymentMethodsBoot(); const stripeState = paymentMethodsState?.stripe; const isAccountCreated = stripeState?.isStripeAccountCreated; const isAccountActive = stripeState?.isStripePaymentActive; const stripeAccountId = stripeState?.stripeAccountId; const stripePaymentMethodId = stripeState?.stripePaymentMethodId; const { mutateAsync: createStripeAccountLink, isLoading: isCreateStripeLinkLoading, } = useCreateStripeAccountLink(); // Handle Stripe setup button click. const handleSetUpBtnClick = () => { openDialog(DialogsName.StripeSetup); }; // Handle complete Stripe setup button click. const handleCompleteSetUpBtnClick = () => { createStripeAccountLink({ stripeAccountId }) .then((res) => { const { clientSecret } = res; if (clientSecret.url) { window.open(clientSecret.url, '_blank'); } }) .catch(() => { AppToaster.show({ message: 'Something went wrong.', intent: Intent.DANGER, }); }); }; // Handle edit button click. const handleEditBtnClick = () => { openDrawer(DRAWERS.STRIPE_PAYMENT_INTEGRATION_EDIT); }; // Handle delete connection button click. const handleDeleteConnectionClick = () => { openAlert('delete-stripe-payment-method', { paymentMethodId: stripePaymentMethodId, }); }; return ( {isAccountActive && ( Active )} {isAccountActive && ( )} {!isAccountCreated && ( )} {isAccountCreated && !isAccountActive && ( )} {isAccountCreated && ( } >