The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
simplify
Steven Teye2d3f677b632
diff --git a/apps/web/app/(ee)/app.dub.co/embed/supported-countries/page.tsx b/apps/web/app/(ee)/app.dub.co/embed/supported-countries/page.tsxindex 1a4da7530e..27d1f794a8 100644--- a/apps/web/app/(ee)/app.dub.co/embed/supported-countries/page.tsx+++ b/apps/web/app/(ee)/app.dub.co/embed/supported-countries/page.tsx@@ -1,5 +1,75 @@-import PayoutSupportedCountries from "./payout-supported-countries";+"use client";++import { useMediaQuery } from "@dub/ui";+import {+ cn,+ CONNECT_SUPPORTED_COUNTRIES,+ COUNTRIES,+ PAYPAL_SUPPORTED_COUNTRIES,+} from "@dub/utils";+import { useState } from "react";export default function SupportedCountriesEmbed() {- return <PayoutSupportedCountries />;+ const supportedCountries = [+ ...CONNECT_SUPPORTED_COUNTRIES,+ ...PAYPAL_SUPPORTED_COUNTRIES,+ ];+ const sortedCountries = supportedCountries.sort((a, b) =>+ COUNTRIES[a].localeCompare(COUNTRIES[b]),+ );+ return <CountryGrid countries={sortedCountries} />;+}++function CountryGrid({ countries }: { countries: string[] }) {+ const { isMobile } = useMediaQuery();+ const showCount = isMobile ? 16 : 30;+ const [expanded, setExpanded] = useState(false);++ const displayCountries =+ countries.length <= showCount || expanded+ ? countries+ : countries.slice(0, showCount);++ return (+ <div className="not-prose relative px-2">+ <div+ className={cn(+ "grid grid-cols-2 gap-5 py-4 sm:grid-cols-3",+ countries.length > showCount && !expanded && "max-h-[420px]",+ countries.length > showCount && expanded && "pb-12",+ )}+ >+ {displayCountries.map((country) => (+ <div key={country} className="flex items-center gap-3">+ <img+ src={`https://hatscripts.github.io/circle-flags/flags/${country.toLowerCase()}.svg`}+ alt={country}+ width={32}+ height={32}+ className="size-5 rounded-full border border-neutral-200 shadow-md"+ draggable={false}+ />+ <span className="text-sm font-medium">{COUNTRIES[country]}</span>+ </div>+ ))}+ </div>+ {countries.length > showCount && (+ <>+ {!expanded && (+ <div className="absolute bottom-0 h-24 w-full bg-gradient-to-t from-neutral-50 to-transparent" />+ )}+ <button+ onClick={() => setExpanded(!expanded)}+ className={`absolute left-1/2 -translate-x-1/2 transform rounded-full border border-gray-200 bg-white px-4 py-1 text-sm text-gray-500 shadow-sm hover:text-gray-700 ${+ expanded ? "-bottom-2" : "bottom-6"+ }`}+ >+ {expanded+ ? "Show less"+ : `Show ${countries.length - showCount} more`}+ </button>+ </>+ )}+ </div>+ );}diff --git a/apps/web/app/(ee)/app.dub.co/embed/supported-countries/payout-supported-countries.tsx b/apps/web/app/(ee)/app.dub.co/embed/supported-countries/payout-supported-countries.tsxdeleted file mode 100644index 3981d76176..0000000000--- a/apps/web/app/(ee)/app.dub.co/embed/supported-countries/payout-supported-countries.tsx+++ /dev/null@@ -1,75 +0,0 @@-"use client";--import { useMediaQuery } from "@dub/ui";-import {- cn,- CONNECT_SUPPORTED_COUNTRIES,- COUNTRIES,- PAYPAL_SUPPORTED_COUNTRIES,-} from "@dub/utils";-import { useState } from "react";--function CountryGrid({ countries }: { countries: string[] }) {- const { isMobile } = useMediaQuery();- const showCount = isMobile ? 16 : 30;- const [expanded, setExpanded] = useState(false);-- const displayCountries =- countries.length <= showCount || expanded- ? countries- : countries.slice(0, showCount);-- return (- <div className="not-prose relative px-2">- <div- className={cn(- "grid grid-cols-2 gap-5 py-4 sm:grid-cols-3",- countries.length > showCount && !expanded && "max-h-[420px]",- countries.length > showCount && expanded && "pb-12",- )}- >- {displayCountries.map((country) => (- <div key={country} className="flex items-center gap-3">- <img- src={`https://hatscripts.github.io/circle-flags/flags/${country.toLowerCase()}.svg`}- alt={country}- width={32}- height={32}- className="size-5 rounded-full border border-neutral-200 shadow-md"- draggable={false}- />- <span className="text-sm font-medium">{COUNTRIES[country]}</span>- </div>- ))}- </div>- {countries.length > showCount && (- <>- {!expanded && (- <div className="absolute bottom-0 h-24 w-full bg-gradient-to-t from-neutral-50 to-transparent" />- )}- <button- onClick={() => setExpanded(!expanded)}- className={`absolute left-1/2 -translate-x-1/2 transform rounded-full border border-gray-200 bg-white px-4 py-1 text-sm text-gray-500 shadow-sm hover:text-gray-700 ${- expanded ? "-bottom-2" : "bottom-6"- }`}- >- {expanded- ? "Show less"- : `Show ${countries.length - showCount} more`}- </button>- </>- )}- </div>- );-}--export default function PayoutSupportedCountries() {- const supportedCountries = [- ...CONNECT_SUPPORTED_COUNTRIES,- ...PAYPAL_SUPPORTED_COUNTRIES,- ];- const sortedCountries = supportedCountries.sort((a, b) =>- COUNTRIES[a].localeCompare(COUNTRIES[b]),- );- return <CountryGrid countries={sortedCountries} />;-}diff --git a/apps/web/lib/middleware/embed.ts b/apps/web/lib/middleware/embed.tsindex acf67e1d88..be5535ed5d 100644--- a/apps/web/lib/middleware/embed.ts+++ b/apps/web/lib/middleware/embed.ts@@ -6,7 +6,7 @@ const PUBLIC_EMBED_PATHS = ["/embed/supported-countries"];export function EmbedMiddleware(req: NextRequest) {const { path, searchParamsObj, fullPath } = parse(req);- if (PUBLIC_EMBED_PATHS.some((p) => path === p || path.startsWith(`${p}/`))) {+ if (PUBLIC_EMBED_PATHS.includes(path)) {return NextResponse.rewrite(new URL(`/app.dub.co${fullPath}`, req.url));}