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 "Website and socials" tab/page

Tim Wilson62c34bad8dfc
diff --git a/apps/web/app/(ee)/api/partners/online-presence/callback/route.ts b/apps/web/app/(ee)/api/partners/online-presence/callback/route.ts
index 421f8fd53a..10c6577541 100644
--- a/apps/web/app/(ee)/api/partners/online-presence/callback/route.ts
+++ b/apps/web/app/(ee)/api/partners/online-presence/callback/route.ts
@@ -141,4 +141,4 @@ export async function GET(req: Request) {
const getRedirectUrl = (source: string) =>
source === "onboarding"
? `${PARTNERS_DOMAIN}/onboarding/online-presence`
- : `${PARTNERS_DOMAIN}/settings#online-presence`;
+ : `${PARTNERS_DOMAIN}/profile/social`;
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/page-client.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/page-client.tsx
index 578c2a0ca9..1e2ec470a7 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/page-client.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/page-client.tsx
@@ -6,7 +6,6 @@ import usePartnerProfile from "@/lib/swr/use-partner-profile";
import { PartnerProps, PayoutsCount } from "@/lib/types";
import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
import { CountryCombobox } from "@/ui/partners/country-combobox";
-import { OnlinePresenceForm } from "@/ui/partners/online-presence-form";
import {
Button,
buttonVariants,
@@ -50,39 +49,6 @@ export function ProfileSettingsPageClient() {
</div>
)}
</div>
-
- <div
- className="max-w-screen-md rounded-lg border border-neutral-200 bg-white"
- id="online-presence"
- >
- <div className="border-b border-neutral-200 p-6">
- <h2 className="text-xl font-medium text-neutral-800">
- Online presence
- </h2>
- <p className="text-sm text-neutral-700">
- These improve your reputation score and rank you higher.{" "}
- </p>
- </div>
- {partner ? (
- <OnlinePresenceForm
- partner={partner}
- variant="settings"
- onSubmitSuccessful={() => {
- toast.success("Online presence updated successfully.");
- }}
- />
- ) : (
- <div className="flex h-32 w-full items-center justify-center">
- {error ? (
- <span className="text-sm text-neutral-500">
- Failed to load online presence data
- </span>
- ) : (
- <LoadingSpinner />
- )}
- </div>
- )}
- </div>
</PageWidthWrapper>
);
}
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/page.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/page.tsx
index 634b14b1c3..627c6fe530 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/page.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/page.tsx
@@ -3,10 +3,7 @@ import { ProfileSettingsPageClient } from "./page-client";
export default function ProfileSettingsPage() {
return (
- <PageContent
- title="Profile"
- // description="This partner profile is shared with program owners when you apply to their programs."
- >
+ <PageContent title="Profile">
<ProfileSettingsPageClient />
</PageContent>
);
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/social/page-client.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/social/page-client.tsx
new file mode 100644
index 0000000000..61561e2a56
--- /dev/null
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/social/page-client.tsx
@@ -0,0 +1,379 @@
+"use client";
+
+import { updatePartnerProfileAction } from "@/lib/actions/partners/update-partner-profile";
+import usePartnerPayoutsCount from "@/lib/swr/use-partner-payouts-count";
+import usePartnerProfile from "@/lib/swr/use-partner-profile";
+import { PartnerProps, PayoutsCount } from "@/lib/types";
+import { PageContent } from "@/ui/layout/page-content";
+import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
+import { CountryCombobox } from "@/ui/partners/country-combobox";
+import {
+ OnlinePresenceForm,
+ useOnlinePresenceForm,
+} from "@/ui/partners/online-presence-form";
+import {
+ Button,
+ buttonVariants,
+ DotsPattern,
+ FileUpload,
+ LoadingSpinner,
+ ToggleGroup,
+ useEnterSubmit,
+} from "@dub/ui";
+import { cn, OG_AVATAR_URL } from "@dub/utils";
+import { PartnerProfileType } from "@prisma/client";
+import { AnimatePresence, LayoutGroup, motion } from "framer-motion";
+import { useAction } from "next-safe-action/hooks";
+import { PropsWithChildren, useRef } from "react";
+import { Controller, useForm } from "react-hook-form";
+import ReactTextareaAutosize from "react-textarea-autosize";
+import { toast } from "sonner";
+
+export function ProfileSocialPageClient() {
+ const { partner, error } = usePartnerProfile();
+
+ const form = useOnlinePresenceForm({ partner });
+ const formRef = useRef<HTMLFormElement>(null);
+ const {
+ formState: { isSubmitting },
+ } = form;
+
+ return (
+ <PageContent
+ title="Website and socials"
+ controls={
+ <Button
+ text="Save changes"
+ className="h-8 w-fit px-2.5"
+ loading={isSubmitting}
+ onClick={() => formRef.current?.requestSubmit()}
+ />
+ }
+ >
+ <PageWidthWrapper className="flex flex-col gap-8">
+ <div className="relative m-1 mb-8">
+ <div
+ className="pointer-events-none absolute inset-0 rounded-2xl bg-neutral-100/50 [mask-image:linear-gradient(black,transparent_60%)]"
+ aria-hidden
+ >
+ <div className="absolute inset-4 overflow-hidden">
+ <div className="absolute inset-y-0 left-1/2 w-[1200px] -translate-x-1/2">
+ <DotsPattern className="text-neutral-200/80" />
+ </div>
+ </div>
+ </div>
+ <div className="relative mx-auto my-12 w-full max-w-[400px]">
+ {partner ? (
+ <OnlinePresenceForm
+ ref={formRef}
+ form={form}
+ partner={partner}
+ variant="settings"
+ onSubmitSuccessful={() => {
+ toast.success("Online presence updated successfully.");
+ }}
+ />
+ ) : (
+ <div className="flex h-32 w-full items-center justify-center">
+ {error ? (
+ <span className="text-sm text-neutral-500">
+ Failed to load online presence data
+ </span>
+ ) : (
+ <LoadingSpinner />
+ )}
+ </div>
+ )}
+ </div>
+ </div>
+ </PageWidthWrapper>
+ </PageContent>
+ );
+}
+
+function ProfileForm({ partner }: { partner: PartnerProps }) {
+ const {
+ register,
+ control,
+ handleSubmit,
+ setError,
+ watch,
+ setValue,
+ formState: { errors, isSubmitting },
+ } = useForm<{
+ name: string;
+ image: string | null;
+ description: string | null;
+ country: string;
+ profileType: PartnerProfileType;
+ companyName: string | null;
+ }>({
+ defaultValues: {
+ name: partner.name,
+ image: partner.image,
+ description: partner.description ?? null,
+ country: partner.country ?? "",
+ profileType: partner.profileType ?? "individual",
+ companyName: partner.companyName ?? null,
+ },
+ });
+
+ const { profileType } = watch();
+
+ const { payoutsCount } = usePartnerPayoutsCount<PayoutsCount[]>({
+ groupBy: "status",
+ });
+
+ const completedPayoutsCount =
+ payoutsCount?.find((payout) => payout.status === "completed")?.count ?? 0;
+
+ const formRef = useRef<HTMLFormElement>(null);
+ const { handleKeyDown } = useEnterSubmit(formRef);
+
+ const { executeAsync, isPending } = useAction(updatePartnerProfileAction, {
+ onSuccess: async () => {
+ toast.success("Profile updated successfully.");
+ },
+ onError({ error }) {
+ setError("root.serverError", {
+ message: error.serverError,
+ });
+
+ toast.error(error.serverError);
+ },
+ });
+
+ return (
+ <form
+ ref={formRef}
+ onSubmit={handleSubmit(async (data) => {
+ const imageChanged = data.image !== partner.image;
+
+ await executeAsync({
+ ...data,
+ image: imageChanged ? data.image : null,
+ });
+ })}
+ >
+ <div className="px-5">
+ <div className="grid grid-cols-1 items-center sm:grid-cols-2">
+ <FormRow>
+ <label className="contents">
+ <span className="text-sm font-medium text-neutral-800">
+ Display Image
+ </span>
+ <div className="flex items-center gap-5">
+ <Controller
+ control={control}
+ name="image"
+ render={({ field }) => (
+ <FileUpload
+ accept="images"
+ className="mt-2 size-14 shrink-0 rounded-full border border-neutral-300"
+ iconClassName="w-5 h-5"
+ previewClassName="size-14 rounded-full"
+ variant="plain"
+ imageSrc={
+ field.value || `${OG_AVATAR_URL}${partner?.name}`
+ }
+ readFile
+ onChange={({ src }) => field.onChange(src)}
+ content={null}
+ maxFileSizeMB={2}
+ targetResolution={{ width: 160, height: 160 }}
+ />
+ )}
+ />
+ <div>
+ <div
+ className={cn(
+ buttonVariants({ variant: "secondary" }),
+ "flex h-7 w-fit cursor-pointer items-center rounded-md border px-2 text-xs",
+ )}
+ >
+ Upload image
+ </div>
+ <p className="mt-1.5 text-xs text-neutral-500">
+ Recommended size: 160x160px
+ </p>
+ </div>
+ </div>
+ </label>
+ </FormRow>
+
+ <FormRow>
+ <label className="contents">
+ <span className="text-sm font-medium text-neutral-800">
+ Full Name
+ </span>
+ <div>
+ <input
+ type="text"
+ className={cn(
+ "mt-2 block w-full rounded-md focus:outline-none sm:text-sm",
+ errors.name
+ ? "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="Acme, Inc."
+ {...register("name", {
+ required: true,
+ })}
+ />
+ </div>
+ </label>
+ </FormRow>
+
+ <FormRow>
+ <label className="contents">
+ <span className="text-sm font-medium text-neutral-800">
+ Country
+ </span>
+ <div>
+ <Controller
+ control={control}
+ name="country"
+ rules={{ required: true }}
+ render={({ field }) => (
+ <CountryCombobox
+ value={field.value || ""}
+ onChange={field.onChange}
+ error={errors.country ? true : false}
+ disabledTooltip={
+ completedPayoutsCount > 0
+ ? "Since you've already received payouts on Dub, you cannot change your country. If you need to update your country, please contact support."
+ : undefined
+ }
+ />
+ )}
+ />
+ </div>
+ </label>
+ </FormRow>
+
+ <FormRow>
+ <label className="contents">
+ <span className="text-sm font-medium text-neutral-800">
+ Description
+ </span>
+ <div>
+ <ReactTextareaAutosize
+ className={cn(
+ "mt-2 block w-full rounded-md focus:outline-none sm:text-sm",
+ errors.name
+ ? "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="Tell us about the kind of content you create – e.g. tech, travel, fashion, etc."
+ minRows={3}
+ maxRows={10}
+ onKeyDown={handleKeyDown}
+ {...register("description")}
+ />
+ </div>
+ </label>
+ </FormRow>
+
+ <FormRow>
+ <label className="contents">
+ <span className="text-sm font-medium text-neutral-800">
+ Profile Type
+ </span>
+ <div className="w-full">
+ <LayoutGroup>
+ <div className="w-full">
+ <ToggleGroup
+ options={[
+ {
+ value: "individual",
+ label: "Individual",
+ },
+ {
+ value: "company",
+ label: "Company",
+ },
+ ]}
+ selected={profileType}
+ selectAction={(option: "individual" | "company") => {
+ if (completedPayoutsCount === 0) {
+ setValue("profileType", option);
+ }
+ }}
+ className={cn(
+ "flex w-full items-center gap-0.5 rounded-lg border-neutral-300 bg-neutral-100 p-0.5",
+ completedPayoutsCount > 0 && "cursor-not-allowed",
+ )}
+ optionClassName={cn(
+ "h-9 flex items-center justify-center rounded-lg flex-1",
+ completedPayoutsCount > 0 && "pointer-events-none",
+ )}
+ indicatorClassName="bg-white"
+ />
+ </div>
+ </LayoutGroup>
+ </div>
+ </label>
+ </FormRow>
+
+ <AnimatePresence mode="popLayout">
+ {profileType === "company" && (
+ <motion.div
+ layout
+ initial={{ opacity: 0, height: 0 }}
+ animate={{ opacity: 1, height: "auto" }}
+ exit={{ opacity: 0, height: 0 }}
+ transition={{
+ type: "spring",
+ stiffness: 300,
+ damping: 30,
+ opacity: { duration: 0.2 },
+ layout: { duration: 0.3, type: "spring" },
+ }}
+ className="contents"
+ >
+ <FormRow>
+ <label className="contents">
+ <span className="text-sm font-medium text-neutral-800">
+ Legal company name
+ </span>
+ <div>
+ <input
+ type="text"
+ className={cn(
+ "mt-2 block w-full rounded-md focus:outline-none sm:text-sm",
+ errors.companyName
+ ? "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",
+ )}
+ disabled={completedPayoutsCount > 0}
+ {...register("companyName", {
+ required: profileType === "company",
+ })}
+ />
+ </div>
+ </label>
+ </FormRow>
+ </motion.div>
+ )}
+ </AnimatePresence>
+ </div>
+ </div>
+ <div className="flex justify-end rounded-b-lg border-t border-neutral-200 bg-neutral-100 px-5 py-3.5">
+ <Button
+ type="submit"
+ text="Save changes"
+ className="h-8 w-fit px-2.5"
+ loading={isSubmitting || isPending}
+ />
+ </div>
+ </form>
+ );
+}
+
+function FormRow({ children }: PropsWithChildren) {
+ return (
+ <div className="contents [&:not(:last-child)>label>*:nth-child(even)]:border-b sm:[&:not(:last-child)>label>*]:border-b [&>label>*:first-child]:pt-5 [&>label>*:last-child]:pb-6 [&>label>*]:flex [&>label>*]:h-full [&>label>*]:items-center [&>label>*]:border-neutral-200 sm:[&>label>*]:py-5">
+ {children}
+ </div>
+ );
+}
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/social/page.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/social/page.tsx
new file mode 100644
index 0000000000..ec27179cfe
--- /dev/null
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/social/page.tsx
@@ -0,0 +1,5 @@
+import { ProfileSocialPageClient } from "./page-client";
+
+export default function ProfileSocialPage() {
+ return <ProfileSocialPageClient />;
+}
diff --git a/apps/web/ui/layout/sidebar/partners-sidebar-nav.tsx b/apps/web/ui/layout/sidebar/partners-sidebar-nav.tsx
index 71ec5b446b..5f7de281a0 100644
--- a/apps/web/ui/layout/sidebar/partners-sidebar-nav.tsx
+++ b/apps/web/ui/layout/sidebar/partners-sidebar-nav.tsx
@@ -7,6 +7,7 @@ import {
ColorPalette2,
Gauge6,
Gear2,
+ Globe,
GridIcon,
MoneyBills2,
ShieldCheck,
@@ -143,6 +144,11 @@ const NAV_AREAS: SidebarNavAreas<SidebarNavData> = {
href: "/profile",
exact: true,
},
+ {
+ name: "Website and socials",
+ icon: Globe,
+ href: "/profile/social",
+ },
// {
// name: "Payouts",
// icon: MoneyBills2,
diff --git a/apps/web/ui/partners/online-presence-form.tsx b/apps/web/ui/partners/online-presence-form.tsx
index 014f3f2853..8b8e47ed59 100644
--- a/apps/web/ui/partners/online-presence-form.tsx
+++ b/apps/web/ui/partners/online-presence-form.tsx
@@ -20,7 +20,7 @@ import { getPrettyUrl } from "@dub/utils";
import { cn } from "@dub/utils/src/functions";
import { useAction } from "next-safe-action/hooks";
import { useRouter } from "next/navigation";
-import { ReactNode, useCallback, useState } from "react";
+import { forwardRef, ReactNode, useCallback, useState } from "react";
import { FormProvider, useForm, useFormContext } from "react-hook-form";
import { toast } from "sonner";
import { mutate } from "swr";
@@ -51,12 +51,14 @@ interface OnlinePresenceFormProps {
onSubmitSuccessful?: () => void;
}
-export function OnlinePresenceForm({
- variant = "onboarding",
+/**
+ * Separate optional hook to allow for form management outside of the main component.
+ * If used, the returned form object should be passed to the main component as a prop.
+ */
+export function useOnlinePresenceForm({
partner,
- onSubmitSuccessful,
-}: OnlinePresenceFormProps) {
- const form = useForm<OnlinePresenceFormData>({
+}: Pick<OnlinePresenceFormProps, "partner">) {
+ return useForm<OnlinePresenceFormData>({
defaultValues: {
website: partner?.website ? getPrettyUrl(partner.website) : undefined,
youtube: partner?.youtube || undefined,
@@ -66,313 +68,326 @@ export function OnlinePresenceForm({
tiktok: partner?.tiktok || undefined,
},
});
+}
- const {
- register,
- setError,
- getValues,
- handleSubmit,
- reset,
- formState: { errors, isSubmitting, isSubmitSuccessful },
- } = form;
-
- const { executeAsync } = useAction(updateOnlinePresenceAction, {
- onSuccess: (result) => {
- if (!result?.data?.success)
- setError("root.serverError", {
- message: "Failed to update online presence",
- });
- else mutate("/api/partner-profile");
- },
- onError: ({ error }) => {
- toast.error(parseActionError(error, "Failed to update online presence"));
-
- reset(form.getValues(), { keepErrors: true });
- },
- });
-
- const [domainVerificationData, setDomainVerificationData] = useState<{
- domain: string;
- txtRecord: string;
- } | null>(null);
-
- const startVerification = useOAuthVerification(variant);
+type OnlinePresenceFormWithFormProps = OnlinePresenceFormProps & {
+ form?: ReturnType<typeof useOnlinePresenceForm>;
+};
- return (
- <>
- <DomainVerificationModal
- showDomainVerificationModal={domainVerificationData !== null}
- setShowDomainVerificationModal={() => setDomainVerificationData(null)}
- domain={domainVerificationData?.domain || ""}
- txtRecord={domainVerificationData?.txtRecord || ""}
- />
- <FormProvider {...form}>
- <form
- onSubmit={handleSubmit(async (data) => {
- const result = await executeAsync(data);
-
- if (result?.data?.success) onSubmitSuccessful?.();
- })}
- >
- <div
- className={cn(
- "flex w-full flex-col gap-4 text-left",
- variant === "settings" && "gap-0 divide-y divide-neutral-200 p-5",
- )}
+export const OnlinePresenceForm = forwardRef<
+ HTMLFormElement,
+ OnlinePresenceFormWithFormProps
+>(
+ (
+ {
+ form: formProp,
+ variant = "onboarding",
+ partner,
+ onSubmitSuccessful,
+ }: OnlinePresenceFormWithFormProps,
+ ref,
+ ) => {
+ const form = formProp ?? useOnlinePresenceForm({ partner });
+
+ const {
+ register,
+ setError,
+ getValues,
+ handleSubmit,
+ reset,
+ formState: { errors, isSubmitting, isSubmitSuccessful },
+ } = form;
+
+ const { executeAsync } = useAction(updateOnlinePresenceAction, {
+ onSuccess: (result) => {
+ if (!result?.data?.success)
+ setError("root.serverError", {
+ message: "Failed to update online presence",
+ });
+ else mutate("/api/partner-profile");
+ },
+ onError: ({ error }) => {
+ toast.error(
+ parseActionError(error, "Failed to update online presence"),
+ );
+
+ reset(form.getValues(), { keepErrors: true });
+ },
+ });
+
+ const [domainVerificationData, setDomainVerificationData] = useState<{
+ domain: string;
+ txtRecord: string;
+ } | null>(null);
+
+ const startVerification = useOAuthVerification(variant);
+
+ return (
+ <>
+ <DomainVerificationModal
+ showDomainVerificationModal={domainVerificationData !== null}
+ setShowDomainVerificationModal={() => setDomainVerificationData(null)}
+ domain={domainVerificationData?.domain || ""}
+ txtRecord={domainVerificationData?.txtRecord || ""}
+ />
+ <FormProvider {...form}>
+ <form
+ ref={ref}
+ onSubmit={handleSubmit(async (data) => {
+ const result = await executeAsync(data);
+
+ if (result?.data?.success) onSubmitSuccessful?.();
+ })}
>
- <FormRow
- variant={variant}
- label="Website"
- input={
- <input
- type="text"
- className={cn(
- "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="example.com"
- {...register("website")}
- />
- }
- button={
- <VerifyButton
- property="website"
- verifiedAtField="websiteVerifiedAt"
- icon={Globe}
- onClick={async () => {
- try {
- const result =
- await updateOnlinePresenceAction(getValues());
-
- if (
- !result?.data?.website ||
- !result?.data?.websiteTxtRecord
- ) {
- throw new Error(
- "Missing website or TXT record in update result",
- );
- }
-
- setDomainVerificationData({
- domain: new URL(result.data.website).hostname,
- txtRecord: result.data.websiteTxtRecord,
- });
-
- mutate("/api/partner-profile");
- } catch (e) {
- toast.error("Failed to start website verification");
- console.error("Failed to start website verification", e);
- }
-
- return false;
- }}
- />
- }
- />
-
- <FormRow
- variant={variant}
- label="YouTube"
- input={
- <div className="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>
- <span className="absolute inset-y-0 left-[6.7rem] flex items-center pl-3 text-sm text-neutral-400">
- @
- </span>
+ <div className={cn("flex w-full flex-col gap-4 text-left")}>
+ <FormRow
+ variant={variant}
+ label="Website"
+ input={
<input
type="text"
className={cn(
- "block w-full rounded-none rounded-r-md pl-7 focus:outline-none sm:text-sm",
- errors.youtube
+ "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="handle"
- onPaste={onPasteSocial}
- {...register("youtube")}
+ placeholder="example.com"
+ {...register("website")}
/>
- </div>
- }
- button={
- <VerifyButton
- property="youtube"
- verifiedAtField="youtubeVerifiedAt"
- icon={YouTube}
- onClick={() =>
- startVerification("youtube", getValues("youtube"))
- }
- />
- }
- />
-
- <FormRow
- variant={variant}
- label="X/Twitter"
- input={
- <div className="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"
- onPaste={onPasteSocial}
- {...register("twitter")}
+ }
+ button={
+ <VerifyButton
+ property="website"
+ verifiedAtField="websiteVerifiedAt"
+ icon={Globe}
+ onClick={async () => {
+ try {
+ const result =
+ await updateOnlinePresenceAction(getValues());
+
+ if (
+ !result?.data?.website ||
+ !result?.data?.websiteTxtRecord
+ ) {
+ throw new Error(
+ "Missing website or TXT record in update result",
+ );
+ }
+
+ setDomainVerificationData({
+ domain: new URL(result.data.website).hostname,
+ txtRecord: result.data.websiteTxtRecord,
+ });
+
+ mutate("/api/partner-profile");
+ } catch (e) {
+ toast.error("Failed to start website verification");
+ console.error(
+ "Failed to start website verification",
+ e,
+ );
+ }
+
+ return false;
+ }}
/>
- </div>
- }
- button={
- <VerifyButton
- property="twitter"
- verifiedAtField="twitterVerifiedAt"
- icon={Twitter}
- onClick={() =>
- startVerification("twitter", getValues("twitter"))
- }
- />
- }
- />
-
- <FormRow
- variant={variant}
- label="LinkedIn"
- input={
- <div className="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">
- linkedin.com/in
- </span>
- <input
- type="text"
- className={cn(
- "block w-full rounded-none rounded-r-md focus:outline-none sm:text-sm",
- errors.linkedin
- ? "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"
- onPaste={onPasteSocial}
- {...register("linkedin")}
+ }
+ />
+
+ <FormRow
+ variant={variant}
+ label="YouTube"
+ input={
+ <div className="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>
+ <span className="absolute inset-y-0 left-[6.7rem] flex items-center pl-3 text-sm text-neutral-400">
+ @
+ </span>
+ <input
+ type="text"
+ className={cn(
+ "block w-full rounded-none rounded-r-md pl-7 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"
+ onPaste={onPasteSocial}
+ {...register("youtube")}
+ />
+ </div>
+ }
+ button={
+ <VerifyButton
+ property="youtube"
+ verifiedAtField="youtubeVerifiedAt"
+ icon={YouTube}
+ onClick={() =>
+ startVerification("youtube", getValues("youtube"))
+ }
/>
- </div>
- }
- button={
- <VerifyButton
- property="linkedin"
- verifiedAtField="linkedinVerifiedAt"
- icon={LinkedIn}
- onClick={() =>
- startVerification("linkedin", getValues("linkedin"))
- }
- disabledTooltip="LinkedIn verification is coming soon."
- />
- }
- />
-
- <FormRow
- variant={variant}
- label="Instagram"
- input={
- <div className="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"
- onPaste={onPasteSocial}
- {...register("instagram")}
+ }
+ />
+
+ <FormRow
+ variant={variant}
+ label="X/Twitter"
+ input={
+ <div className="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"
+ onPaste={onPasteSocial}
+ {...register("twitter")}
+ />
+ </div>
+ }
+ button={
+ <VerifyButton
+ property="twitter"
+ verifiedAtField="twitterVerifiedAt"
+ icon={Twitter}
+ onClick={() =>
+ startVerification("twitter", getValues("twitter"))
+ }
/>
- </div>
- }
- button={
- <VerifyButton
- property="instagram"
- verifiedAtField="instagramVerifiedAt"
- icon={Instagram}
- onClick={() =>
- startVerification("instagram", getValues("instagram"))
- }
- disabledTooltip="Instagram verification is coming soon."
- />
- }
- />
-
- <FormRow
- variant={variant}
- label="TikTok"
- input={
- <div className="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>
- <span className="absolute inset-y-0 left-[5.7rem] flex items-center pl-3 text-sm text-neutral-400">
- @
- </span>
- <input
- type="text"
- className={cn(
- "block w-full rounded-none rounded-r-md pl-7 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"
- onPaste={onPasteSocial}
- {...register("tiktok")}
+ }
+ />
+
+ <FormRow
+ variant={variant}
+ label="LinkedIn"
+ input={
+ <div className="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">
+ linkedin.com/in
+ </span>
+ <input
+ type="text"
+ className={cn(
+ "block w-full rounded-none rounded-r-md focus:outline-none sm:text-sm",
+ errors.linkedin
+ ? "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"
+ onPaste={onPasteSocial}
+ {...register("linkedin")}
+ />
+ </div>
+ }
+ button={
+ <VerifyButton
+ property="linkedin"
+ verifiedAtField="linkedinVerifiedAt"
+ icon={LinkedIn}
+ onClick={() =>
+ startVerification("linkedin", getValues("linkedin"))
+ }
+ disabledTooltip="LinkedIn verification is coming soon."
/>
- </div>
- }
- button={
- <VerifyButton
- property="tiktok"
- verifiedAtField="tiktokVerifiedAt"
- icon={TikTok}
- onClick={() =>
- startVerification("tiktok", getValues("tiktok"))
- }
- />
- }
- />
- </div>
-
- {variant === "onboarding" ? (
- <Button
- type="submit"
- text="Continue"
- className="mt-6"
- loading={isSubmitting || isSubmitSuccessful}
- />
- ) : (
- <div className="flex justify-end rounded-b-lg border-t border-neutral-200 bg-neutral-100 px-5 py-3.5">
+ }
+ />
+
+ <FormRow
+ variant={variant}
+ label="Instagram"
+ input={
+ <div className="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"
+ onPaste={onPasteSocial}
+ {...register("instagram")}
+ />
+ </div>
+ }
+ button={
+ <VerifyButton
+ property="instagram"
+ verifiedAtField="instagramVerifiedAt"
+ icon={Instagram}
+ onClick={() =>
+ startVerification("instagram", getValues("instagram"))
+ }
+ disabledTooltip="Instagram verification is coming soon."
+ />
+ }
+ />
+
+ <FormRow
+ variant={variant}
+ label="TikTok"
+ input={
+ <div className="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>
+ <span className="absolute inset-y-0 left-[5.7rem] flex items-center pl-3 text-sm text-neutral-400">
+ @
+ </span>
+ <input
+ type="text"
+ className={cn(
+ "block w-full rounded-none rounded-r-md pl-7 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"
+ onPaste={onPasteSocial}
+ {...register("tiktok")}
+ />
+ </div>
+ }
+ button={
+ <VerifyButton
+ property="tiktok"
+ verifiedAtField="tiktokVerifiedAt"
+ icon={TikTok}
+ onClick={() =>
+ startVerification("tiktok", getValues("tiktok"))
+ }
+ />
+ }
+ />
+ </div>
+
+ {variant === "onboarding" && (
<Button
type="submit"
- text="Save changes"
- className="h-8 w-fit px-2.5"
- loading={isSubmitting}
+ text="Continue"
+ className="mt-6"
+ loading={isSubmitting || isSubmitSuccessful}
/>
- </div>
- )}
- </form>
- </FormProvider>
- </>
- );
-}
+ )}
+ </form>
+ </FormProvider>
+ </>
+ );
+ },
+);
function useOAuthVerification(source: "onboarding" | "settings") {
const router = useRouter();
@@ -479,20 +494,10 @@ function FormRow({
button: ReactNode;
}) {
return (
- <div className={cn(variant === "settings" && "py-5")}>
- <label
- className={cn(
- "flex flex-col gap-2",
- variant === "settings" && "flex-row items-center justify-between",
- )}
- >
+ <div>
+ <label className={cn("flex flex-col gap-2")}>
<span className="text-sm font-medium text-neutral-800">{label}</span>
- <div
- className={cn(
- "relative",
- variant === "settings" && "max-w-[55%] grow",
- )}
- >
+ <div className={cn("relative")}>
{input}
{button}
</div>