Skip to content

Commit

Permalink
Adding the new CapitalFinancingPromotion component (#209)
Browse files Browse the repository at this point in the history
Adding the new CapitalFinancingPromotion component

Switch the old CapitalOverview embedded component to the new CapitalFinancingPromotion embedded component. This new embedded component will display details of a financing offer for the account if there is one.
  • Loading branch information
chaitali-stripe authored Jan 7, 2025
1 parent da62221 commit 0e96d6d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
26 changes: 23 additions & 3 deletions app/(dashboard)/finances/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import React, {useState, useEffect} from 'react';
import {
ConnectCapitalFinancing,
ConnectCapitalFinancingPromotion,
ConnectCapitalOverview,
ConnectComponentsProvider,
ConnectFinancialAccount,
ConnectFinancialAccountTransactions,
} from '@stripe/react-connect-js';
Expand All @@ -11,8 +14,23 @@ import EmbeddedComponentContainer from '@/app/components/EmbeddedComponentContai
import {LandmarkIcon, LoaderCircle} from 'lucide-react';
import {Button} from '@/components/ui/button';
import {useFinancialAccount} from '@/app/hooks/useFinancialAccount';
import {FinancingProductType} from '@stripe/connect-js';

export default function Finances() {
// Only show the financing offer if there is one to show
const [showFinancingOffer, setShowFinancingOffer] = React.useState(false);
const handleFinancingOfferLoaded = ({productType}: FinancingProductType) => {
switch (productType) {
case 'none':
setShowFinancingOffer(false);
break;
case 'standard':
case 'refill':
setShowFinancingOffer(true);
break;
}
};

const {
financialAccount,
error: useFinancialAccountError,
Expand Down Expand Up @@ -69,9 +87,11 @@ export default function Finances() {
<>
{displayFinancialAccount ? (
<>
<Container>
<EmbeddedComponentContainer componentName="CapitalOverview">
<ConnectCapitalOverview />
<Container className={showFinancingOffer ? '' : 'hidden'}>
<EmbeddedComponentContainer componentName="CapitalFinancingPromotion">
<ConnectCapitalFinancingPromotion
onEligibleFinancingOfferLoaded={handleFinancingOfferLoaded}
/>
</EmbeddedComponentContainer>
</Container>
<Container>
Expand Down
2 changes: 1 addition & 1 deletion app/api/account_session/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export async function POST(req: NextRequest) {
disable_stripe_user_authentication: isCustom,
},
},
capital_overview: {
capital_financing_promotion: {
enabled: true,
},
...(hasIssuingAndTreasury ? issuingAndTreasuryComponents : {}),
Expand Down
4 changes: 2 additions & 2 deletions app/components/EmbeddedComponentContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const EmbeddedComponentContainer = ({
'https://docs.stripe.com/connect/supported-embedded-components/account-onboarding',
Balances:
'https://docs.stripe.com/connect/supported-embedded-components/balances',
CapitalOverview:
'https://docs.stripe.com/connect/supported-embedded-components/capital-overview',
CapitalFinancingPromotion:
'https://docs.stripe.com/connect/supported-embedded-components/capital-financing-promotion',
Documents:
'https://docs.stripe.com/connect/supported-embedded-components/documents',
FinancialAccount:
Expand Down

0 comments on commit 0e96d6d

Please sign in to comment.