The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
rearrange page and layout segments
Steven Teyfa50b0abe0a5
diff --git a/apps/web/app/partners.dub.co/(auth)/layout.tsx b/apps/web/app/partners.dub.co/(auth)/layout.tsxdeleted file mode 100644index 3d466e7b3b..0000000000--- a/apps/web/app/partners.dub.co/(auth)/layout.tsx+++ /dev/null@@ -1,16 +0,0 @@-import { Background } from "@dub/ui";--export default function AdminAuthLayout({- children,-}: {- children: React.ReactNode;-}) {- return (- <>- <Background />- <div className="relative z-10 flex flex-col items-center justify-center">- {children}- </div>- </>- );-}diff --git a/apps/web/app/partners.dub.co/(auth)/login/page.tsx b/apps/web/app/partners.dub.co/(auth)/login/page.tsxdeleted file mode 100644index da4e0992bf..0000000000--- a/apps/web/app/partners.dub.co/(auth)/login/page.tsx+++ /dev/null@@ -1 +0,0 @@-export { default } from "../../../app.dub.co/(auth)/login/page";diff --git a/apps/web/app/partners.dub.co/onboarding/layout.tsx b/apps/web/app/partners.dub.co/(onboarding)/layout.tsxsimilarity index 52%rename from apps/web/app/partners.dub.co/onboarding/layout.tsxrename to apps/web/app/partners.dub.co/(onboarding)/layout.tsxindex 5e7a8601cf..9615b603ef 100644--- a/apps/web/app/partners.dub.co/onboarding/layout.tsx+++ b/apps/web/app/partners.dub.co/(onboarding)/layout.tsx@@ -1,4 +1,4 @@-import { Grid } from "@dub/ui";+import { Grid, Wordmark } from "@dub/ui";export default function AdminAuthLayout({children,@@ -12,7 +12,15 @@ export default function AdminAuthLayout({<div className="absolute inset-0 -translate-y-1/2 -scale-x-100 bg-[conic-gradient(from_-32deg,#f00_0deg,#EAB308_99deg,#5CFF80_162deg,#00FFF9_216deg,#3A8BFD_288deg,#855AFC_360deg)] opacity-25 blur-[200px]" /></div><div className="relative z-10 flex flex-col items-center justify-center">- {children}+ <div className="relative mx-auto mt-10 flex w-full max-w-sm flex-col items-center px-3 text-center md:px-8">+ <div className="animate-slide-up-fade relative flex w-auto flex-col items-center [--offset:10px] [animation-duration:1.3s] [animation-fill-mode:both]">+ <Wordmark className="relative h-10" />+ <span className="text-sm font-medium text-neutral-700">+ Partner+ </span>+ </div>+ {children}+ </div></div></>);diff --git a/apps/web/app/partners.dub.co/(onboarding)/login/page.tsx b/apps/web/app/partners.dub.co/(onboarding)/login/page.tsxnew file mode 100644index 0000000000..c0eb8d2dcb--- /dev/null+++ b/apps/web/app/partners.dub.co/(onboarding)/login/page.tsx@@ -0,0 +1,3 @@+export default function PartnersLogin() {+ return <div>PartnersLogin</div>;+}diff --git a/apps/web/app/partners.dub.co/onboarding/onboarding-form.tsx b/apps/web/app/partners.dub.co/(onboarding)/onboarding/onboarding-form.tsxsimilarity index 86%rename from apps/web/app/partners.dub.co/onboarding/onboarding-form.tsxrename to apps/web/app/partners.dub.co/(onboarding)/onboarding/onboarding-form.tsxindex fb346c5b22..aa18d4c50b 100644--- a/apps/web/app/partners.dub.co/onboarding/onboarding-form.tsx+++ b/apps/web/app/partners.dub.co/(onboarding)/onboarding/onboarding-form.tsx@@ -66,24 +66,27 @@ export function OnboardingForm() {<label><span className="text-sm font-medium text-gray-800">Logo</span>- <Controller- control={control}- name="logo"- render={({ field }) => (- <FileUpload- accept="images"- className="mt-2 h-14 w-full rounded-md border border-gray-300"- iconClassName="w-5 h-5"- previewClassName="size-10 rounded-full"- variant="plain"- imageSrc={field.value}- readFile- onChange={({ src }) => field.onChange(src)}- content={null}- maxFileSizeMB={2}- />- )}- />+ <div className="flex items-end gap-2">+ <Controller+ control={control}+ name="logo"+ render={({ field }) => (+ <FileUpload+ accept="images"+ className="mt-2 size-20 rounded-md border border-gray-300"+ iconClassName="w-5 h-5"+ previewClassName="size-10 rounded-full"+ variant="plain"+ imageSrc={field.value}+ readFile+ onChange={({ src }) => field.onChange(src)}+ content={null}+ maxFileSizeMB={2}+ />+ )}+ />+ <p className="text-xs text-gray-500">Recommended size: 160x160px</p>+ </div></label><label>diff --git a/apps/web/app/partners.dub.co/(onboarding)/onboarding/page.tsx b/apps/web/app/partners.dub.co/(onboarding)/onboarding/page.tsxnew file mode 100644index 0000000000..c888842668--- /dev/null+++ b/apps/web/app/partners.dub.co/(onboarding)/onboarding/page.tsx@@ -0,0 +1,18 @@+import { ConnectedDots4 } from "@dub/ui/src/icons";+import { OnboardingForm } from "./onboarding-form";++export default function Onboarding() {+ return (+ <div className="my-10 flex w-full flex-col items-center md:mt-16 lg:mt-20">+ <div className="animate-slide-up-fade flex size-10 items-center justify-center rounded-full border border-neutral-200 backdrop-blur-sm [--offset:8px] [animation-delay:250ms] [animation-duration:1s] [animation-fill-mode:both]">+ <ConnectedDots4 className="size-5 text-neutral-900" />+ </div>+ <h1 className="animate-slide-up-fade mt-6 text-lg font-medium [--offset:8px] [animation-delay:250ms] [animation-duration:1s] [animation-fill-mode:both]">+ Create a Dub Partner profile+ </h1>+ <div className="animate-slide-up-fade mt-8 w-full [--offset:10px] [animation-delay:500ms] [animation-duration:1s] [animation-fill-mode:both]">+ <OnboardingForm />+ </div>+ </div>+ );+}diff --git a/apps/web/app/partners.dub.co/(onboarding)/page.tsx b/apps/web/app/partners.dub.co/(onboarding)/page.tsxnew file mode 100644index 0000000000..389505860b--- /dev/null+++ b/apps/web/app/partners.dub.co/(onboarding)/page.tsx@@ -0,0 +1,18 @@+import { constructMetadata } from "@dub/utils";++export const metadata = constructMetadata({+ noIndex: true,+});++export default function Partners() {+ return (+ <div>+ <h1 className="animate-slide-up-fade mt-10 text-2xl font-medium [--offset:10px] [animation-delay:250ms] [animation-duration:1s] [animation-fill-mode:both]">+ Dub Partner Portal+ </h1>+ <p className="animate-slide-up-fade mt-2 text-gray-500 [--offset:10px] [animation-delay:500ms] [animation-duration:1s] [animation-fill-mode:both]">+ Coming soon+ </p>+ </div>+ );+}diff --git a/apps/web/app/partners.dub.co/onboarding/page.tsx b/apps/web/app/partners.dub.co/onboarding/page.tsxdeleted file mode 100644index 4332af7fee..0000000000--- a/apps/web/app/partners.dub.co/onboarding/page.tsx+++ /dev/null@@ -1,24 +0,0 @@-import { Wordmark } from "@dub/ui";-import { ConnectedDots4 } from "@dub/ui/src/icons";-import { OnboardingForm } from "./onboarding-form";-export default function Onboarding() {- return (- <div className="relative mx-auto mt-10 flex w-full max-w-sm flex-col items-center px-3 text-center md:px-8">- <div className="animate-slide-up-fade relative flex w-auto flex-col items-center [--offset:10px] [animation-duration:1.3s] [animation-fill-mode:both]">- <Wordmark className="relative h-10" />- <span className="text-sm font-medium text-neutral-700">Partner</span>- </div>- <div className="my-10 flex w-full flex-col items-center md:mt-16 lg:mt-20">- <div className="animate-slide-up-fade flex size-10 items-center justify-center rounded-full border border-neutral-200 backdrop-blur-sm [--offset:8px] [animation-delay:250ms] [animation-duration:1s] [animation-fill-mode:both]">- <ConnectedDots4 className="size-5 text-neutral-900" />- </div>- <h1 className="animate-slide-up-fade mt-6 text-lg font-medium [--offset:8px] [animation-delay:250ms] [animation-duration:1s] [animation-fill-mode:both]">- Create a Dub Partner profile- </h1>- <div className="animate-slide-up-fade mt-8 w-full [--offset:10px] [animation-delay:500ms] [animation-duration:1s] [animation-fill-mode:both]">- <OnboardingForm />- </div>- </div>- </div>- );-}diff --git a/apps/web/app/partners.dub.co/page.tsx b/apps/web/app/partners.dub.co/page.tsxdeleted file mode 100644index d244c917bd..0000000000--- a/apps/web/app/partners.dub.co/page.tsx+++ /dev/null@@ -1,38 +0,0 @@-import { NewBackground } from "@/ui/shared/new-background";-import { Wordmark } from "@dub/ui";-import { constructMetadata } from "@dub/utils";--export const metadata = constructMetadata({- noIndex: true,-});--export default function Partners() {- return (- <div>- <NewBackground showAnimation />- <div className="relative mx-auto mt-24 flex max-w-sm flex-col items-center px-3 text-center md:mt-32 md:px-8 lg:mt-48">- <div className="animate-slide-up-fade relative flex w-auto items-center justify-center px-6 py-2 [--offset:20px] [animation-duration:1.3s] [animation-fill-mode:both]">- <div className="absolute inset-0 opacity-10">- {[...Array(3)].map((_, i) => (- <div- key={i}- className="animate-pulse-scale absolute inset-0 rounded-full mix-blend-color-burn"- style={{- animationDelay: `${i * -2}s`,- backgroundImage: `linear-gradient(90deg, #000, transparent, #000)`,- }}- />- ))}- </div>- <Wordmark className="relative h-16" />- </div>- <h1 className="animate-slide-up-fade mt-10 text-2xl font-medium [--offset:10px] [animation-delay:250ms] [animation-duration:1s] [animation-fill-mode:both]">- Dub Partner Portal- </h1>- <p className="animate-slide-up-fade mt-2 text-gray-500 [--offset:10px] [animation-delay:500ms] [animation-duration:1s] [animation-fill-mode:both]">- Coming soon- </p>- </div>- </div>- );-}diff --git a/apps/web/lib/actions/partners/onboard-partner.ts b/apps/web/lib/actions/partners/onboard-partner.tsindex 5a9f96fd5e..2fad6aaaad 100644--- a/apps/web/lib/actions/partners/onboard-partner.ts+++ b/apps/web/lib/actions/partners/onboard-partner.ts@@ -1,7 +1,7 @@"use server";import { createId } from "@/lib/api/utils";-import { getFeatureFlags } from "@/lib/edge-config";+import { userIsInBeta } from "@/lib/edge-config";import { prisma } from "@/lib/prisma";import { storage } from "@/lib/storage";import { nanoid } from "nanoid";@@ -21,8 +21,11 @@ export const onboardPartner = authUserActionClient.action(async ({ ctx, parsedInput }) => {const { user } = ctx;- const { partnersPortal } = await getFeatureFlags({ userEmail: user.email });- if (!partnersPortal) {+ const partnersPortalEnabled = await userIsInBeta(+ user.email,+ "partnersPortal",+ );+ if (!partnersPortalEnabled) {return {ok: false,error: "Partners portal feature flag disabled.",diff --git a/apps/web/lib/edge-config/get-feature-flags.ts b/apps/web/lib/edge-config/get-feature-flags.tsindex 110fd964c6..6b213b45d5 100644--- a/apps/web/lib/edge-config/get-feature-flags.ts+++ b/apps/web/lib/edge-config/get-feature-flags.ts@@ -6,11 +6,9 @@ type BetaFeaturesRecord = Record<BetaFeatures, string[]>;export const getFeatureFlags = async ({workspaceId,workspaceSlug,- userEmail,}: {workspaceId?: string;workspaceSlug?: string;- userEmail?: string;}) => {if (workspaceId) {workspaceId = workspaceId.startsWith("ws_")@@ -22,7 +20,6 @@ export const getFeatureFlags = async ({referrals: false,webhooks: false,noDubLink: false,- partnersPortal: false,};if (!process.env.NEXT_PUBLIC_IS_DUB || !process.env.EDGE_CONFIG) {@@ -43,11 +40,12 @@ export const getFeatureFlags = async ({}if (betaFeatures) {- for (const [featureFlag, identifiers] of Object.entries(betaFeatures)) {+ for (const [featureFlag, workspaceIdsOrSlugs] of Object.entries(+ betaFeatures,+ )) {if (- (workspaceId && identifiers.includes(workspaceId)) ||- (workspaceSlug && identifiers.includes(workspaceSlug)) ||- (userEmail && identifiers.includes(userEmail))+ (workspaceId && workspaceIdsOrSlugs.includes(workspaceId)) ||+ (workspaceSlug && workspaceIdsOrSlugs.includes(workspaceSlug))) {workspaceFeatures[featureFlag] = true;}diff --git a/apps/web/lib/edge-config/index.ts b/apps/web/lib/edge-config/index.tsindex 089eea982c..6c6de5fd4c 100644--- a/apps/web/lib/edge-config/index.ts+++ b/apps/web/lib/edge-config/index.ts@@ -7,3 +7,4 @@ export * from "./is-reserved-key";export * from "./is-reserved-username";export * from "./is-whitelisted-email";export * from "./update";+export * from "./user-is-in-beta";diff --git a/apps/web/lib/edge-config/user-is-in-beta.ts b/apps/web/lib/edge-config/user-is-in-beta.tsnew file mode 100644index 0000000000..f501cc3fd0--- /dev/null+++ b/apps/web/lib/edge-config/user-is-in-beta.ts@@ -0,0 +1,24 @@+import { get } from "@vercel/edge-config";++export const userIsInBeta = async (+ email: string,+ betaFeature: "partnersPortal",+) => {+ if (!process.env.NEXT_PUBLIC_IS_DUB || !process.env.EDGE_CONFIG) {+ return true;+ }++ const betaFeatures = await get("betaFeatures");++ if (!betaFeatures) {+ return false;+ }++ const betaFeatureList = betaFeatures[betaFeature];++ if (!betaFeatureList) {+ return false;+ }++ return betaFeatureList.includes(email);+};diff --git a/apps/web/lib/middleware/partners.ts b/apps/web/lib/middleware/partners.tsindex 57400c6ace..e6d25c32b0 100644--- a/apps/web/lib/middleware/partners.ts+++ b/apps/web/lib/middleware/partners.ts@@ -1,6 +1,6 @@import { parse } from "@/lib/middleware/utils";import { NextRequest, NextResponse } from "next/server";-import { getFeatureFlags } from "../edge-config";+import { userIsInBeta } from "../edge-config";import { getDefaultPartner } from "./utils/get-default-partner";import { getUserViaToken } from "./utils/get-user-via-token";@@ -16,19 +16,22 @@ export default async function PartnersMiddleware(req: NextRequest) {else if (user && path === "/login")return NextResponse.redirect(new URL("/", req.url)); // Redirect authenticated users to dashboard- const partners = user- ? (await getFeatureFlags({ userEmail: user.email })).partnersPortal+ const partnersEnabled = user+ ? await userIsInBeta(user.email, "partnersPortal"): false;- if (user && path === "/" && partners) {+ console.log({ partnersEnabled });++ if (user && path === "/" && partnersEnabled) {const defaultPartner = await getDefaultPartner(user);- if (!defaultPartner)+ if (!defaultPartner) {return NextResponse.redirect(new URL("/onboarding", req.url));+ }return NextResponse.redirect(new URL(`/${defaultPartner}`, req.url));}// Redirect to home if partner flag is off- if (!partners && !UNAUTHENTICATED_PATHS.includes(path))+ if (!partnersEnabled && !UNAUTHENTICATED_PATHS.includes(path))return NextResponse.redirect(new URL("/", req.url));return NextResponse.rewrite(diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.tsindex d5d2313750..fca6eda18c 100644--- a/apps/web/lib/types.ts+++ b/apps/web/lib/types.ts@@ -77,11 +77,7 @@ export type PlanProps = (typeof plans)[number];export type RoleProps = (typeof roles)[number];-export type BetaFeatures =- | "referrals"- | "webhooks"- | "noDubLink"- | "partnersPortal";+export type BetaFeatures = "referrals" | "webhooks" | "noDubLink";export type AddOns = "conversion" | "sso";