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.

remove /onboarding/verify

Kiran Kf87777fcf97c
diff --git a/apps/web/app/partners.dub.co/(onboarding)/onboarding/verify/page.tsx b/apps/web/app/partners.dub.co/(onboarding)/onboarding/verify/page.tsx
deleted file mode 100644
index eb1e5e5c7d..0000000000
--- a/apps/web/app/partners.dub.co/(onboarding)/onboarding/verify/page.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-import { ConnectedDots4 } from "@dub/ui/src/icons";
-import { VerificationForm } from "./verification-form";
-
-export default function OnboardingVerify() {
- return (
- <div className="mx-auto my-10 flex w-full max-w-sm flex-col items-center md:mt-14">
- <div className="animate-slide-up-fade flex size-10 items-center justify-center rounded-full border border-neutral-200 bg-white 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]">
- Verify your phone number
- </h1>
- <div className="animate-slide-up-fade mt-8 w-full [--offset:10px] [animation-delay:500ms] [animation-duration:1s] [animation-fill-mode:both]">
- <VerificationForm />
- </div>
- </div>
- );
-}
diff --git a/apps/web/app/partners.dub.co/(onboarding)/onboarding/verify/verification-form.tsx b/apps/web/app/partners.dub.co/(onboarding)/onboarding/verify/verification-form.tsx
deleted file mode 100644
index ce5a693fe6..0000000000
--- a/apps/web/app/partners.dub.co/(onboarding)/onboarding/verify/verification-form.tsx
+++ /dev/null
@@ -1,143 +0,0 @@
-"use client";
-
-import { resendVerificationCodeAction } from "@/lib/actions/partners/resend-verification-code";
-import { verifyPartnerAction } from "@/lib/actions/partners/verify-partner";
-import useDotsUser from "@/lib/swr/use-dots-user";
-import useRefreshSession from "@/lib/swr/use-refresh-session";
-import { Button, LoadingSpinner, useMediaQuery } from "@dub/ui";
-import { MobilePhone } from "@dub/ui/src/icons";
-import { cn } from "@dub/utils/src/functions";
-import { OTPInput } from "input-otp";
-import { useAction } from "next-safe-action/hooks";
-import { useRouter } from "next/navigation";
-import { useForm } from "react-hook-form";
-import { toast } from "sonner";
-
-export function VerificationForm() {
- const router = useRouter();
- const { isMobile } = useMediaQuery();
-
- useRefreshSession("defaultPartnerId");
-
- const {
- handleSubmit,
- reset,
- getValues,
- setValue,
- formState: { errors, isSubmitting, isSubmitSuccessful },
- } = useForm<{ code: string }>();
-
- const { executeAsync, isExecuting } = useAction(verifyPartnerAction, {
- onSuccess: () => {
- router.push("/programs");
- },
- onError: ({ error, input }) => {
- toast.error(error.serverError);
- reset(input);
- },
- });
-
- return (
- <div className="grid gap-2">
- <form
- onSubmit={handleSubmit((data) => executeAsync(data))}
- className="grid gap-4 text-left"
- >
- <label>
- <span className="text-sm font-medium text-gray-800">
- Verification code
- </span>
- <OTPInput
- maxLength={6}
- autoFocus={!isMobile}
- containerClassName="mt-2 group flex items-center justify-center"
- required
- value={getValues("code")}
- onChange={(code) => {
- reset({ code });
- setValue("code", code);
- }}
- render={({ slots }) => (
- <div className="flex items-center">
- {slots.map(({ char, isActive, hasFakeCaret }, idx) => (
- <div
- key={idx}
- className={cn(
- "relative flex h-16 w-[3.25rem] items-center justify-center text-xl sm:h-20 sm:w-16",
- "border-y border-r border-gray-200 bg-white first:rounded-l-lg first:border-l last:rounded-r-lg",
- "ring-0 transition-all",
- isActive &&
- "z-10 border border-gray-500 ring-2 ring-gray-200",
- errors.code && "border-red-500 ring-red-200",
- )}
- >
- {char}
- {hasFakeCaret && (
- <div className="animate-caret-blink pointer-events-none absolute inset-0 flex items-center justify-center">
- <div className="h-5 w-px bg-black" />
- </div>
- )}
- </div>
- ))}
- </div>
- )}
- onComplete={handleSubmit((data) => executeAsync(data))}
- />
- {errors.code && (
- <p className="mt-2 text-center text-sm text-red-500">
- Invalid code. Please try again.
- </p>
- )}
- </label>
-
- <Button
- type="submit"
- text="Submit code"
- loading={isExecuting || isSubmitting || isSubmitSuccessful}
- />
- </form>
- <ResendCode />
- </div>
- );
-}
-
-function ResendCode() {
- const { dotsUser } = useDotsUser();
- const { executeAsync, isExecuting } = useAction(
- resendVerificationCodeAction,
- {
- onSuccess: () => {
- toast.success("Code resent successfully");
- },
- },
- );
- return (
- <div className="flex items-center justify-between">
- {!dotsUser ? (
- <div className="h-4 w-20 animate-pulse rounded-md bg-gray-200" />
- ) : (
- <div className="flex items-center gap-1 text-sm text-gray-400">
- <MobilePhone className="size-4" />+
- {dotsUser?.phone_number.country_code}
- {dotsUser?.phone_number.phone_number}
- </div>
- )}
- <button
- className={cn(
- "flex w-fit items-center gap-2 text-sm text-gray-400 hover:text-gray-600",
- isExecuting && "cursor-not-allowed opacity-50",
- )}
- onClick={() => executeAsync()}
- disabled={isExecuting}
- >
- <LoadingSpinner
- className={cn(
- "size-3 transition-opacity",
- !isExecuting && "opacity-0",
- )}
- />
- Resend code
- </button>
- </div>
- );
-}
diff --git a/apps/web/lib/actions/partners/resend-verification-code.ts b/apps/web/lib/actions/partners/resend-verification-code.ts
deleted file mode 100644
index 85cd2ede62..0000000000
--- a/apps/web/lib/actions/partners/resend-verification-code.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-"use server";
-
-import { sendVerificationToken } from "@/lib/dots/send-verification-token";
-import { authPartnerActionClient } from "../safe-action";
-
-// Resend verification code
-export const resendVerificationCodeAction = authPartnerActionClient.action(
- async ({ ctx }) => {
- const { partner } = ctx;
-
- if (!partner.dotsUserId) {
- throw new Error("Partner does not have a Dots user ID");
- }
-
- await sendVerificationToken({
- dotsUserId: partner.dotsUserId,
- });
-
- return {
- success: true,
- };
- },
-);
diff --git a/apps/web/lib/actions/partners/verify-partner.ts b/apps/web/lib/actions/partners/verify-partner.ts
deleted file mode 100644
index bb888d47cf..0000000000
--- a/apps/web/lib/actions/partners/verify-partner.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-"use server";
-
-import { verifyUserWithToken } from "@/lib/dots/verify-user-with-token";
-import z from "@/lib/zod";
-import { authPartnerActionClient } from "../safe-action";
-
-// Verify partner phone number
-export const verifyPartnerAction = authPartnerActionClient
- .schema(z.object({ code: z.string() }))
- .action(async ({ ctx, parsedInput }) => {
- const { partner } = ctx;
- const { code } = parsedInput;
-
- if (!partner.dotsUserId) {
- throw new Error("Partner does not have a Dots user ID.");
- }
-
- try {
- await verifyUserWithToken({
- dotsUserId: partner.dotsUserId,
- token: code,
- });
- } catch (error) {
- throw new Error("Invalid code. Please try again.");
- }
-
- return {
- partnerId: partner.id,
- };
- });