Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

add layout

Kiran Ka87280dd702f
diff --git a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/guide-list.tsx b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/guide-list.tsx
index b0bed9362a..a415008eac 100644
--- a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/guide-list.tsx
+++ b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/guide-list.tsx
@@ -1,12 +1,17 @@
+"use client";
+
+import { onboardProgramAction } from "@/lib/actions/partners/onboard-program";
+import useWorkspace from "@/lib/swr/use-workspace";
import { Shopify } from "@/ui/layout/sidebar/conversions/icons/shopify";
import { Stripe } from "@/ui/layout/sidebar/conversions/icons/stripe";
-import { ToggleGroup } from "@dub/ui";
-import { Framer } from "lucide-react";
+import { Button, ToggleGroup } from "@dub/ui";
+import { useAction } from "next-safe-action/hooks";
+import { useRouter } from "next/navigation";
+import { useState } from "react";
+import { toast } from "sonner";
import { IntegrationGuide, IntegrationType } from "./types";
interface GuidesListProps {
- integrationType: IntegrationType;
- onIntegrationTypeChange: (type: IntegrationType) => void;
onGuideSelect: (guide: IntegrationGuide) => void;
}
@@ -15,36 +20,61 @@ export const guides: IntegrationGuide[] = [
type: "no-code",
title: "Framer",
description: "Dub Analytics",
- icon: <Framer />,
+ icon: Shopify,
recommended: true,
},
{
type: "no-code",
title: "Shopify",
description: "Dub Analytics",
- icon: <Shopify />,
+ icon: Shopify,
},
{
type: "no-code",
title: "Webflow",
description: "Dub Analytics",
- icon: <Stripe />,
+ icon: Stripe,
},
{
type: "code",
title: "WordPress",
description: "Dub Analytics",
- icon: <Shopify />,
+ icon: Shopify,
},
];
-export function GuidesList({
- integrationType,
- onIntegrationTypeChange,
- onGuideSelect,
-}: GuidesListProps) {
+export function GuidesList({ onGuideSelect }: GuidesListProps) {
+ const router = useRouter();
+ const [hasSubmitted, setHasSubmitted] = useState(false);
+ const { id: workspaceId, slug: workspaceSlug, mutate } = useWorkspace();
+ const [integrationType, setIntegrationType] =
+ useState<IntegrationType>("no-code");
+
+ const { executeAsync, isPending } = useAction(onboardProgramAction, {
+ onSuccess: () => {
+ router.push(`/${workspaceSlug}/program/new/overview`);
+ mutate();
+ },
+ onError: ({ error }) => {
+ toast.error(error.serverError);
+ },
+ });
+
+ const onContinue = async () => {
+ if (!workspaceId) {
+ return;
+ }
+
+ setHasSubmitted(true);
+
+ await executeAsync({
+ workspaceId,
+ step: "connect",
+ });
+ };
+
return (
- <>
+ <div className="space-y-10">
<div className="flex flex-col gap-4">
<ToggleGroup
className="flex w-full items-center gap-1 rounded-md border border-neutral-200 bg-neutral-100 p-1"
@@ -55,7 +85,7 @@ export function GuidesList({
{ value: "code", label: "Developer integrations" },
]}
selected={integrationType}
- selectAction={onIntegrationTypeChange}
+ selectAction={(value) => setIntegrationType(value as IntegrationType)}
/>
</div>
@@ -75,7 +105,7 @@ export function GuidesList({
)}
<div className="mb-4 flex h-16 items-center justify-center">
- <IconWrapper>{guide.icon}</IconWrapper>
+ <guide.icon className="size-11" />
</div>
<div className="text-center">
@@ -89,10 +119,15 @@ export function GuidesList({
</button>
))}
</div>
- </>
+
+ <Button
+ text="I'll do this later"
+ variant="secondary"
+ className="w-full"
+ type="button"
+ onClick={onContinue}
+ loading={isPending || hasSubmitted}
+ />
+ </div>
);
}
-
-const IconWrapper = ({ children }: { children: React.ReactNode }) => (
- <div className="flex size-11 items-center justify-center">{children}</div>
-);
diff --git a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/guide.tsx b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/guide.tsx
index b249f07634..17c43d9daa 100644
--- a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/guide.tsx
+++ b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/guide.tsx
@@ -1,5 +1,108 @@
+"use client";
+
+import { onboardProgramAction } from "@/lib/actions/partners/onboard-program";
+import useWorkspace from "@/lib/swr/use-workspace";
+import { Button } from "@dub/ui";
+import { useAction } from "next-safe-action/hooks";
+import { useRouter } from "next/navigation";
+import { useState } from "react";
+import { toast } from "sonner";
import { IntegrationGuide } from "./types";
-export function Guide({ guide }: { guide: IntegrationGuide }) {
- return <>{guide.title}</>;
+export function Guide({
+ guide,
+ clearSelectedGuide,
+}: {
+ guide: IntegrationGuide;
+ clearSelectedGuide: () => void;
+}) {
+ const router = useRouter();
+ const [hasSubmitted, setHasSubmitted] = useState(false);
+ const { id: workspaceId, slug: workspaceSlug, mutate } = useWorkspace();
+
+ const { executeAsync, isPending } = useAction(onboardProgramAction, {
+ onSuccess: () => {
+ router.push(`/${workspaceSlug}/program/new/overview`);
+ mutate();
+ },
+ onError: ({ error }) => {
+ toast.error(error.serverError);
+ },
+ });
+
+ const onContinue = async () => {
+ if (!workspaceId) {
+ return;
+ }
+
+ setHasSubmitted(true);
+
+ await executeAsync({
+ workspaceId,
+ step: "connect",
+ });
+ };
+
+ const Icon = guide.icon;
+
+ return (
+ <>
+ <hr className="mb-6 border-neutral-200" />
+ <div className="mx-auto max-w-2xl">
+ <div className="flex items-center justify-between">
+ <Icon className="size-8" />
+ <Button
+ text="Select another method"
+ variant="secondary"
+ className="h-8 w-fit rounded-lg px-2"
+ type="button"
+ onClick={clearSelectedGuide}
+ />
+ </div>
+
+ <h2 className="py-2 text-xl font-semibold leading-7 text-neutral-900">
+ Instructions for {guide.title}
+ </h2>
+
+ <div className="rounded-2xl bg-white p-0 py-6 shadow-none">
+ {/* Step 1 */}
+ <div className="mb-4">
+ <div className="mb-1 text-base font-bold">
+ Step 1: Install the Dub {guide.title} App
+ </div>
+ <div className="mb-6 text-neutral-600">
+ Ensure your program is connected to your website, so you can track
+ your clicks, leads, and sales on your program.
+ </div>
+ </div>
+
+ {/* Help Article Section */}
+ <div className="mb-8 flex min-h-[260px] items-center justify-center rounded-2xl bg-neutral-100">
+ <span className="text-center text-neutral-500">
+ Rest of the help article content
+ </span>
+ </div>
+
+ <div className="flex flex-col gap-2">
+ <Button
+ text="I've completed this"
+ className="w-full"
+ type="button"
+ onClick={onContinue}
+ loading={isPending || hasSubmitted}
+ />
+
+ <Button
+ text="I'll do this later"
+ variant="secondary"
+ className="w-full"
+ type="button"
+ onClick={onContinue}
+ loading={isPending || hasSubmitted}
+ />
+ </div>
+ </div>
+ </div>
+ </>
+ );
}
diff --git a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/page-client.tsx b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/page-client.tsx
index fb2a9fc11a..09789966bc 100644
--- a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/page-client.tsx
+++ b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/page-client.tsx
@@ -1,72 +1,31 @@
"use client";
-import { onboardProgramAction } from "@/lib/actions/partners/onboard-program";
-import useWorkspace from "@/lib/swr/use-workspace";
-import { Button } from "@dub/ui";
-import { useAction } from "next-safe-action/hooks";
-import { useRouter } from "next/navigation";
import { useState } from "react";
-import { toast } from "sonner";
import { Guide } from "./guide";
import { GuidesList } from "./guide-list";
-import { IntegrationGuide, IntegrationType } from "./types";
+import { IntegrationGuide } from "./types";
export function PageClient() {
- const router = useRouter();
- const [hasSubmitted, setHasSubmitted] = useState(false);
- const { id: workspaceId, slug: workspaceSlug, mutate } = useWorkspace();
- const [integrationType, setIntegrationType] =
- useState<IntegrationType>("no-code");
const [selectedGuide, setSelectedGuide] = useState<IntegrationGuide | null>(
null,
);
- const { executeAsync, isPending } = useAction(onboardProgramAction, {
- onSuccess: () => {
- router.push(`/${workspaceSlug}/program/new/overview`);
- mutate();
- },
- onError: ({ error }) => {
- toast.error(error.serverError);
- },
- });
-
- const onClick = async () => {
- if (!workspaceId) return;
-
- setHasSubmitted(true);
- await executeAsync({
- workspaceId,
- step: "connect",
- });
- };
-
return (
<div>
- <p className="text-sm text-neutral-600">
+ <p className="mb-6 text-sm text-neutral-600">
Ensure your program is connected to your website, so you can track your
clicks, leads, and sales on your program.
</p>
- <div className="mt-6 space-y-10">
+ <div>
{selectedGuide ? (
- <Guide guide={selectedGuide} />
- ) : (
- <GuidesList
- integrationType={integrationType}
- onIntegrationTypeChange={setIntegrationType}
- onGuideSelect={setSelectedGuide}
+ <Guide
+ guide={selectedGuide}
+ clearSelectedGuide={() => setSelectedGuide(null)}
/>
+ ) : (
+ <GuidesList onGuideSelect={setSelectedGuide} />
)}
-
- <Button
- text="I'll do this later"
- variant="secondary"
- className="w-full"
- loading={isPending || hasSubmitted}
- type="button"
- onClick={onClick}
- />
</div>
</div>
);
diff --git a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/types.ts b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/types.ts
index 0beea2691e..42826c0aa8 100644
--- a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/types.ts
+++ b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/types.ts
@@ -4,6 +4,6 @@ export type IntegrationGuide = {
type: IntegrationType;
title: string;
description?: string;
- icon: JSX.Element;
+ icon: any;
recommended?: boolean;
};