From bd8377f8025cc38caa81e7bb0688e7bde3783ac8 Mon Sep 17 00:00:00 2001 From: Elian Date: Thu, 9 May 2024 15:02:37 +0200 Subject: [PATCH] feat: add prices to paid themes (#1094) --- src/pages/themes/_components/ThemeCTAs.astro | 109 ++++++++++++------- src/pages/themes/_types/index.ts | 4 + 2 files changed, 74 insertions(+), 39 deletions(-) diff --git a/src/pages/themes/_components/ThemeCTAs.astro b/src/pages/themes/_components/ThemeCTAs.astro index 6913a0c22f..dfd18a607d 100644 --- a/src/pages/themes/_components/ThemeCTAs.astro +++ b/src/pages/themes/_components/ThemeCTAs.astro @@ -1,50 +1,81 @@ --- -import type { HTMLAttributes } from "astro/types"; -import ExternalLinkIcon from "~/icons/ExternalLinkIcon.jsx"; -import type { ThemeAndAuthor } from "../_types/index.ts"; - -export type Props = HTMLAttributes<"div"> & { - theme: ThemeAndAuthor; +import type { HTMLAttributes } from 'astro/types'; +import { THEMES_API_URL } from '~/helpers/constants.ts'; +import ExternalLinkIcon from '~/icons/ExternalLinkIcon.jsx'; +import type { ThemeAndAuthor } from '../_types/index.ts'; +export type Props = HTMLAttributes<'div'> & { + theme: ThemeAndAuthor; }; const { theme, class: className, ...attrs } = Astro.props; --- -
- { - theme.Theme.buyUrl && ( - - Buy now - - ) - } - { - theme.Theme.repoUrl && ( - - Get started - - ) - } - { - theme.Theme.demoUrl && ( - - Live demo - - ) - } +
+ { + theme.Theme.sellingThroughPortal ? ( + + + {theme.Theme.price ? `$${theme.Theme.price / 100} - ` : null} + Buy now + + + ) : ( + theme.Theme.buyUrl && ( + + + {theme.Theme.price ? `$${theme.Theme.price} - ` : null} + Buy now + + + ) + ) + } + { + theme.Theme.repoUrl && ( + + Get started + + ) + } + { + theme.Theme.demoUrl && ( + + Live demo + + ) + }
diff --git a/src/pages/themes/_types/index.ts b/src/pages/themes/_types/index.ts index 1e47b4d1ed..5803bd7e2a 100644 --- a/src/pages/themes/_types/index.ts +++ b/src/pages/themes/_types/index.ts @@ -25,6 +25,10 @@ export type Theme = { approved: boolean; denied: boolean; hidden: boolean; + price: number; + sellingThroughPortal: boolean; + stripeProductId?: string; + stripePriceId?: string; }; export type ThemeHasCategory = {