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.

WIP buttons

Tim Wilsoncaddbfc78b04
diff --git a/apps/web/app/partners.dub.co/(onboarding)/onboarding/online-presence/online-presence-form.tsx b/apps/web/app/partners.dub.co/(onboarding)/onboarding/online-presence/online-presence-form.tsx
index e0a5f2d5a7..5e61a14c2f 100644
--- a/apps/web/app/partners.dub.co/(onboarding)/onboarding/online-presence/online-presence-form.tsx
+++ b/apps/web/app/partners.dub.co/(onboarding)/onboarding/online-presence/online-presence-form.tsx
@@ -1,7 +1,7 @@
"use client";
import { updateOnlinePresenceAction } from "@/lib/actions/partners/update-online-presence";
-import { Button } from "@dub/ui";
+import { Button, Globe } from "@dub/ui";
import { cn } from "@dub/utils/src/functions";
import { useAction } from "next-safe-action/hooks";
import { useRouter } from "next/navigation";
@@ -79,17 +79,26 @@ export function OnlinePresenceForm({
>
<label>
<span className="text-sm font-medium text-neutral-800">Website</span>
- <input
- type="url"
- className={cn(
- "mt-2 block w-full rounded-md focus:outline-none sm:text-sm",
- errors.website
- ? "border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500"
- : "border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:ring-neutral-500",
- )}
- placeholder="https://"
- {...register("website")}
- />
+ <div className="relative">
+ <input
+ type="url"
+ className={cn(
+ "mt-2 block w-full rounded-md focus:outline-none sm:text-sm",
+ errors.website
+ ? "border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500"
+ : "border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:ring-neutral-500",
+ )}
+ placeholder="https://example.com"
+ {...register("website")}
+ />
+ <Button
+ className="absolute right-1.5 top-1/2 h-7 w-fit -translate-y-1/2 px-2.5"
+ variant="secondary"
+ text="Verify"
+ icon={<Globe className="size-4" />}
+ onClick={() => alert("WIP")}
+ />
+ </div>
<p className="mt-1.5 text-xs text-neutral-500">
Verification may take up to 48 hours.
</p>
@@ -97,64 +106,120 @@ export function OnlinePresenceForm({
<label>
<span className="text-sm font-medium text-neutral-800">Instagram</span>
- <input
- type="text"
- className={cn(
- "mt-2 block w-full rounded-md focus:outline-none sm:text-sm",
- errors.instagram
- ? "border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500"
- : "border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:ring-neutral-500",
- )}
- placeholder="instagram.com/handle"
- {...register("instagram")}
- />
+ <div className="relative">
+ <div className="mt-2 flex rounded-md">
+ <span className="inline-flex items-center rounded-l-md border border-r-0 border-neutral-300 bg-neutral-50 px-3 text-neutral-500 sm:text-sm">
+ instagram.com/
+ </span>
+ <input
+ type="text"
+ className={cn(
+ "block w-full rounded-none rounded-r-md focus:outline-none sm:text-sm",
+ errors.instagram
+ ? "border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500"
+ : "border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:ring-neutral-500",
+ )}
+ placeholder="handle"
+ {...register("instagram")}
+ />
+ </div>
+ <Button
+ className="absolute right-1.5 top-1/2 h-7 w-fit -translate-y-1/2 px-2.5"
+ variant="secondary"
+ text="Verify"
+ icon={<Globe className="size-4" />}
+ onClick={() => alert("WIP")}
+ />
+ </div>
</label>
<label>
<span className="text-sm font-medium text-neutral-800">TikTok</span>
- <input
- type="text"
- className={cn(
- "mt-2 block w-full rounded-md focus:outline-none sm:text-sm",
- errors.tiktok
- ? "border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500"
- : "border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:ring-neutral-500",
- )}
- placeholder="tiktok.com/@handle"
- {...register("tiktok")}
- />
+ <div className="relative">
+ <div className="mt-2 flex rounded-md">
+ <span className="inline-flex items-center rounded-l-md border border-r-0 border-neutral-300 bg-neutral-50 px-3 text-neutral-500 sm:text-sm">
+ tiktok.com/@
+ </span>
+ <input
+ type="text"
+ className={cn(
+ "block w-full rounded-none rounded-r-md focus:outline-none sm:text-sm",
+ errors.tiktok
+ ? "border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500"
+ : "border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:ring-neutral-500",
+ )}
+ placeholder="handle"
+ {...register("tiktok")}
+ />
+ </div>
+ <Button
+ className="absolute right-1.5 top-1/2 h-7 w-fit -translate-y-1/2 px-2.5"
+ variant="secondary"
+ text="Verify"
+ icon={<Globe className="size-4" />}
+ onClick={() => alert("WIP")}
+ />
+ </div>
</label>
<label>
<span className="text-sm font-medium text-neutral-800">YouTube</span>
- <input
- type="text"
- className={cn(
- "mt-2 block w-full rounded-md focus:outline-none sm:text-sm",
- errors.youtube
- ? "border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500"
- : "border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:ring-neutral-500",
- )}
- placeholder="youtube.com/handle"
- {...register("youtube")}
- />
+ <div className="relative">
+ <div className="mt-2 flex rounded-md">
+ <span className="inline-flex items-center rounded-l-md border border-r-0 border-neutral-300 bg-neutral-50 px-3 text-neutral-500 sm:text-sm">
+ youtube.com/@
+ </span>
+ <input
+ type="text"
+ className={cn(
+ "block w-full rounded-none rounded-r-md focus:outline-none sm:text-sm",
+ errors.youtube
+ ? "border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500"
+ : "border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:ring-neutral-500",
+ )}
+ placeholder="handle"
+ {...register("youtube")}
+ />
+ </div>
+ <Button
+ className="absolute right-1.5 top-1/2 h-7 w-fit -translate-y-1/2 px-2.5"
+ variant="secondary"
+ text="Verify"
+ icon={<Globe className="size-4" />}
+ onClick={() => alert("WIP")}
+ />
+ </div>
</label>
<label>
<span className="text-sm font-medium text-neutral-800">
X (Twitter)
</span>
- <input
- type="text"
- className={cn(
- "mt-2 block w-full rounded-md focus:outline-none sm:text-sm",
- errors.twitter
- ? "border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500"
- : "border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:ring-neutral-500",
- )}
- placeholder="x.com/handle"
- {...register("twitter")}
- />
+ <div className="relative">
+ <div className="mt-2 flex rounded-md">
+ <span className="inline-flex items-center rounded-l-md border border-r-0 border-neutral-300 bg-neutral-50 px-3 text-neutral-500 sm:text-sm">
+ x.com/
+ </span>
+ <input
+ type="text"
+ className={cn(
+ "block w-full rounded-none rounded-r-md focus:outline-none sm:text-sm",
+ errors.twitter
+ ? "border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500"
+ : "border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:ring-neutral-500",
+ )}
+ placeholder="handle"
+ {...register("twitter")}
+ />
+ </div>
+ <Button
+ className="absolute right-1.5 top-1/2 h-7 w-fit -translate-y-1/2 px-2.5"
+ variant="secondary"
+ text="Verify"
+ icon={<Globe className="size-4" />}
+ onClick={() => alert("WIP")}
+ />
+ </div>
</label>
<Button
diff --git a/apps/web/app/partners.dub.co/(onboarding)/onboarding/online-presence/page.tsx b/apps/web/app/partners.dub.co/(onboarding)/onboarding/online-presence/page.tsx
index a92562915e..e5d1d973ed 100644
--- a/apps/web/app/partners.dub.co/(onboarding)/onboarding/online-presence/page.tsx
+++ b/apps/web/app/partners.dub.co/(onboarding)/onboarding/online-presence/page.tsx
@@ -32,27 +32,58 @@ export default function OnlinePresencePage() {
async function OnlinePresenceFormRSC() {
const { user } = await getSession();
- const partner = await prisma.partner.findFirst({
- where: {
- users: {
- some: {
- userId: user.id,
+ const [partner, application] = await Promise.all([
+ prisma.partner.findFirst({
+ where: {
+ users: {
+ some: {
+ userId: user.id,
+ },
},
},
- },
- select: {
- country: true,
- website: true,
- instagram: true,
- tiktok: true,
- youtube: true,
- twitter: true,
- },
- });
+ select: {
+ country: true,
+ website: true,
+ instagram: true,
+ tiktok: true,
+ youtube: true,
+ twitter: true,
+ },
+ }),
+ prisma.programApplication.findFirst({
+ where: {
+ enrollment: {
+ partner: {
+ users: {
+ some: {
+ userId: user.id,
+ },
+ },
+ },
+ },
+ },
+ select: {
+ website: true,
+ },
+ orderBy: {
+ createdAt: "desc",
+ },
+ }),
+ ]);
if (!partner) {
throw new Error("Partner not found");
}
- return <OnlinePresenceForm country={partner.country} partner={partner} />;
+ return (
+ <OnlinePresenceForm
+ country={partner.country}
+ partner={{
+ ...partner,
+ ...(application?.website && !partner.website
+ ? { website: application?.website }
+ : {}),
+ }}
+ />
+ );
}
diff --git a/apps/web/lib/actions/partners/update-online-presence.ts b/apps/web/lib/actions/partners/update-online-presence.ts
index ce55018bcd..7bf32be6ef 100644
--- a/apps/web/lib/actions/partners/update-online-presence.ts
+++ b/apps/web/lib/actions/partners/update-online-presence.ts
@@ -5,7 +5,7 @@ import { z } from "zod";
import { authUserActionClient } from "../safe-action";
const updateOnlinePresenceSchema = z.object({
- website: z.string().url().optional(),
+ website: z.string().url().optional().or(z.literal("")),
instagram: z.string().optional(),
tiktok: z.string().optional(),
youtube: z.string().optional(),