Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions app/(marketing)/sponsors/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,12 @@ function SponsorSection({ tier }: { tier: SponsorTier }) {
<li className="flex" key={slotId}>
{checkoutBlocked ? (
<span
aria-disabled="true"
className={cn(
slotClassName,
"cursor-default text-xs leading-snug text-balance whitespace-normal hover:border-border hover:bg-transparent hover:text-muted-foreground dark:hover:bg-transparent"
"cursor-default text-xs leading-snug text-balance whitespace-normal"
)}
>
Coming soon
On the way to approval
</span>
) : (
<a
Expand All @@ -75,20 +74,12 @@ function SponsorSection({ tier }: { tier: SponsorTier }) {
export default async function SponsorsPage() {
await connection()
const tiers = getSponsorTiers()
const checkoutComingSoon = tiers.every((tier) =>
isSponsorCheckoutBlocked(tier.checkoutHref)
)

return (
<main className="flex-1 overflow-x-clip">
<div className="mx-auto w-full max-w-4xl px-4 pt-12 pb-24 sm:px-6 sm:pt-16">
<header className="flex flex-col items-center gap-4 pb-12 text-center">
<Logo className="size-16" cornerRadius={8} />
{checkoutComingSoon ? (
<p className="font-mono text-xs font-semibold tracking-wide text-muted-foreground uppercase">
Coming soon
</p>
) : null}
<h1 className="text-4xl font-semibold tracking-tight">
Sponsor 23rd
</h1>
Expand All @@ -98,12 +89,6 @@ export default async function SponsorsPage() {
logo and name on this page, links to your site, and includes you in
major release notes. The component registry stays free.
</p>
{checkoutComingSoon ? (
<p className="max-w-xl text-sm text-balance text-muted-foreground">
Checkout opens after Creem approves the store. Slots stay reserved
until then.
</p>
) : null}
</header>

<div className="flex flex-col gap-12">
Expand Down
6 changes: 0 additions & 6 deletions components/github-sponsor.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Link from "next/link"

import { SPONSOR_CHECKOUT_COMING_SOON } from "@/lib/sponsors"
import { cn } from "@/lib/utils"

export function GithubSponsor({ className }: { className?: string }) {
Expand All @@ -13,11 +12,6 @@ export function GithubSponsor({ className }: { className?: string }) {
)}
>
<span>Sponsor</span>
{SPONSOR_CHECKOUT_COMING_SOON ? (
<span className="font-mono text-[10px] font-medium tracking-wide uppercase">
Soon
</span>
) : null}
</Link>
)
}
10 changes: 1 addition & 9 deletions lib/sponsors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,8 @@ export function buildSponsorContactHref(tierName: string): string {
return `mailto:${SPONSOR_CONTACT_EMAIL}?subject=${subject}`
}

/**
* Live payment links are wired, but public checkout stays closed until Creem
* approves the store. Flip this off to open the slots.
*/
export const SPONSOR_CHECKOUT_COMING_SOON = true

/** Test checkout, and any checkout while the store is still awaiting approval. */
/** Creem test checkout stays off the page until the account is approved. */
export function isSponsorCheckoutBlocked(href: string): boolean {
if (SPONSOR_CHECKOUT_COMING_SOON) return true

try {
const url = new URL(href)
if (url.protocol !== "https:") return true
Expand Down
31 changes: 4 additions & 27 deletions tests/sponsors.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,7 @@ test("checkout URLs must be https, otherwise mailto fallback is used", () => {
)
})

const sponsorCheckoutComingSoon =
/export const SPONSOR_CHECKOUT_COMING_SOON = true/.test(sponsorsLib)

function isSponsorCheckoutBlocked(
href,
comingSoon = sponsorCheckoutComingSoon
) {
if (comingSoon) return true

function isSponsorCheckoutBlocked(href) {
try {
const url = new URL(href)
if (url.protocol !== "https:") return true
Expand All @@ -116,41 +108,28 @@ test("sponsors page lists empty slots as Be here", () => {
assert.match(sponsorsPage, /Be here/)
})

test("sponsor checkout stays coming soon until Creem approves", () => {
assert.equal(sponsorCheckoutComingSoon, true)
assert.match(sponsorsLib, /SPONSOR_CHECKOUT_COMING_SOON/)
assert.match(sponsorsLib, /if \(SPONSOR_CHECKOUT_COMING_SOON\) return true/)
test("Creem test checkout stays blocked until approval", () => {
assert.match(sponsorsLib, /function isSponsorCheckoutBlocked/)
assert.match(sponsorsLib, /pathname.startsWith\("\/test\/"\)/)
assert.match(sponsorsPage, /isSponsorCheckoutBlocked\(tier\.checkoutHref\)/)
assert.match(sponsorsPage, /Coming soon/)
assert.doesNotMatch(sponsorsPage, /On the way to approval/)
assert.match(sponsorsPage, /On the way to approval/)

for (const productId of [
"prod_4ZM6WkQrmCSBtFGCdYp7rZ",
"prod_7jEvtpKnPoVXOAZLBnoWfA",
"prod_MqDtYvXUGlGqgEz898MCA",
"prod_3aZ8AxbA2h43IRUMxigep0",
"prod_1lz1o8e7HtglOuXbMRnSmc",
]) {
assert.equal(
isSponsorCheckoutBlocked(`https://www.creem.io/payment/${productId}`),
true
)
assert.equal(
isSponsorCheckoutBlocked(`https://creem.io/test/product/${productId}`),
true
)
}

assert.equal(
isSponsorCheckoutBlocked("https://www.creem.io/payment/prod_gold", false),
isSponsorCheckoutBlocked("https://www.creem.io/payment/prod_gold"),
false
)
assert.equal(
isSponsorCheckoutBlocked("https://creem.io/test/product/prod_gold", false),
true
)
assert.equal(isSponsorCheckoutBlocked("mailto:radiumcoders@gmail.com"), true)
})

Expand Down Expand Up @@ -213,8 +192,6 @@ test("sponsors prices, terms, privacy, and support email match the shadscan layo
assert.match(docsShell, /SUPPORT_EMAIL/)
assert.match(sponsorLink, /href="\/sponsors"/)
assert.match(sponsorLink, />Sponsor</)
assert.match(sponsorLink, /SPONSOR_CHECKOUT_COMING_SOON/)
assert.match(sponsorLink, /Soon/)
assert.doesNotMatch(sponsorLink, /github\.com\/sponsors/)
assert.match(nextConfig, /source: "\/pricing"/)
assert.match(nextConfig, /destination: "\/sponsors"/)
Expand Down
Loading