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 the program importers from program onboarding flow

Kiran Kffc1d4fd01ea
diff --git a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/overview/page-client.tsx b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/overview/page-client.tsx
index e326fa5f29..7b211795b3 100644
--- a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/overview/page-client.tsx
+++ b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/overview/page-client.tsx
@@ -5,7 +5,7 @@ import { getLinkStructureOptions } from "@/lib/partners/get-link-structure-optio
import useWorkspace from "@/lib/swr/use-workspace";
import { ProgramData } from "@/lib/types";
import { ProgramRewardDescription } from "@/ui/partners/program-reward-description";
-import { EventType, RewardStructure } from "@dub/prisma/client";
+import { RewardStructure } from "@dub/prisma/client";
import { Button } from "@dub/ui";
import { Pencil } from "lucide-react";
import { useAction } from "next-safe-action/hooks";
@@ -41,53 +41,21 @@ export function PageClient() {
};
const isValid = useMemo(() => {
- const {
- name,
- url,
- domain,
- logo,
- programType,
- type,
- amount,
- rewardful,
- tolt,
- partnerstack,
- } = data;
+ const { name, url, domain, logo } = data;
if (!name || !url || !domain || !logo) {
return false;
}
- if (programType === "new" && (!amount || !type)) {
- return false;
- }
-
- if (programType === "import" && !rewardful && !tolt && !partnerstack) {
- return false;
- }
-
return true;
}, [data]);
- const reward = data.rewardful
- ? {
- type:
- data.rewardful.reward_type === "amount"
- ? ("flat" as const)
- : ("percentage" as const),
- amount:
- data.rewardful.reward_type === "amount"
- ? data.rewardful.commission_amount_cents ?? 0
- : data.rewardful.commission_percent ?? 0,
- maxDuration: data.rewardful.max_commission_period_months,
- event: "sale" as EventType,
- }
- : {
- type: (data.type ?? "flat") as RewardStructure,
- amount: data.amount ?? 0,
- maxDuration: data.maxDuration ?? 0,
- event: data.defaultRewardType,
- };
+ const reward = {
+ type: (data.type ?? "flat") as RewardStructure,
+ amount: data.amount ?? 0,
+ maxDuration: data.maxDuration ?? 0,
+ event: data.defaultRewardType,
+ };
const SECTIONS = [
{
diff --git a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/partners/form.tsx b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/partners/form.tsx
index b7850a3a08..0a9cadf9a8 100644
--- a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/partners/form.tsx
+++ b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/partners/form.tsx
@@ -1,7 +1,6 @@
"use client";
import { onboardProgramAction } from "@/lib/actions/partners/onboard-program";
-import { PROGRAM_IMPORT_SOURCES } from "@/lib/partners/constants";
import useWorkspace from "@/lib/swr/use-workspace";
import { ProgramData } from "@/lib/types";
import { Button, Input } from "@dub/ui";
@@ -38,8 +37,6 @@ export function Form() {
control,
});
- const [rewardful, tolt] = watch(["rewardful", "tolt"]);
-
const { executeAsync, isPending } = useAction(onboardProgramAction, {
onSuccess: () => {
router.push(`/${workspaceSlug}/program/new/support`);
@@ -65,99 +62,64 @@ export function Form() {
const buttonDisabled = isSubmitting || isPending || loading || hasSubmitted;
- const isImporting = rewardful || tolt;
- const importSource = isImporting
- ? rewardful
- ? PROGRAM_IMPORT_SOURCES[0]
- : PROGRAM_IMPORT_SOURCES[1]
- : null;
-
return (
- <div className="space-y-6">
- {importSource && (
- <div className="space-y-3">
- <p className="text-sm text-neutral-600">
- Invite new partners in addition to those being imported.
- </p>
-
- <div className="mt-10 flex items-center justify-between rounded-lg border border-neutral-200 bg-neutral-50 px-4 py-3">
- <div className="flex items-center gap-2">
- <div className="flex size-5 items-center justify-center rounded-full bg-blue-600">
- <img
- src={importSource.image}
- alt={importSource.value}
- className="size-5"
- />
- </div>
- <span className="text-sm font-medium text-neutral-800">
- Affiliates importing
- </span>
- </div>
- <span className="text-sm text-neutral-600">
- {rewardful?.affiliates || tolt?.affiliates || 0}
+ <form onSubmit={handleSubmit(onSubmit)} className="grid gap-2">
+ <div className="flex flex-col gap-4">
+ {fields.map((field, index) => (
+ <div key={field.id} className="flex flex-col gap-1">
+ <span className="mb-1.5 block text-sm font-medium text-neutral-800">
+ Email
</span>
- </div>
- </div>
- )}
-
- <form onSubmit={handleSubmit(onSubmit)} className="grid gap-2">
- <div className="flex flex-col gap-4">
- {fields.map((field, index) => (
- <div key={field.id} className="flex flex-col gap-1">
- <span className="mb-1.5 block text-sm font-medium text-neutral-800">
- Email
- </span>
- <div className="relative w-full">
- <Input
- {...register(`partners.${index}.email`)}
- type="email"
- placeholder="[email protected]"
- className={cn("max-w-none", fields.length > 1 && "mr-12")}
+ <div className="relative w-full">
+ <Input
+ {...register(`partners.${index}.email`)}
+ type="email"
+ placeholder="[email protected]"
+ className={cn("max-w-none", fields.length > 1 && "mr-12")}
+ />
+ {fields.length > 1 && (
+ <Button
+ type="button"
+ variant="secondary"
+ icon={<Trash className="size-3.5 text-neutral-600" />}
+ onClick={() => remove(index)}
+ aria-label="Remove partner"
+ className="absolute right-2 top-1/2 h-auto w-auto -translate-y-1/2 p-2.5"
/>
- {fields.length > 1 && (
- <Button
- type="button"
- variant="secondary"
- icon={<Trash className="size-3.5 text-neutral-600" />}
- onClick={() => remove(index)}
- aria-label="Remove partner"
- className="absolute right-2 top-1/2 h-auto w-auto -translate-y-1/2 p-2.5"
- />
- )}
- </div>
+ )}
</div>
- ))}
-
- <div className="mb-4">
- <Button
- text="Add partner"
- variant="secondary"
- icon={<Plus className="size-4" />}
- className="w-fit"
- onClick={() => {
- if (fields.length < MAX_PARTNERS) {
- append({ email: "" });
- }
- }}
- disabled={fields.length >= MAX_PARTNERS}
- />
</div>
-
- {fields.length >= MAX_PARTNERS && (
- <p className="text-sm text-neutral-600">
- You can add up to {MAX_PARTNERS} partners at a time
- </p>
- )}
+ ))}
+
+ <div className="mb-4">
+ <Button
+ text="Add partner"
+ variant="secondary"
+ icon={<Plus className="size-4" />}
+ className="w-fit"
+ onClick={() => {
+ if (fields.length < MAX_PARTNERS) {
+ append({ email: "" });
+ }
+ }}
+ disabled={fields.length >= MAX_PARTNERS}
+ />
</div>
- <Button
- text="Continue"
- className="mt-6 w-full"
- loading={isSubmitting || isPending || hasSubmitted}
- disabled={buttonDisabled}
- type="submit"
- />
- </form>
- </div>
+ {fields.length >= MAX_PARTNERS && (
+ <p className="text-sm text-neutral-600">
+ You can add up to {MAX_PARTNERS} partners at a time
+ </p>
+ )}
+ </div>
+
+ <Button
+ text="Continue"
+ className="mt-6 w-full"
+ loading={isSubmitting || isPending || hasSubmitted}
+ disabled={buttonDisabled}
+ type="submit"
+ />
+ </form>
);
}
diff --git a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/form.tsx b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/form.tsx
index 553b393b80..2d91a456ce 100644
--- a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/form.tsx
+++ b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/form.tsx
@@ -2,51 +2,17 @@
import { onboardProgramAction } from "@/lib/actions/partners/onboard-program";
import { handleMoneyInputChange, handleMoneyKeyDown } from "@/lib/form-utils";
-import { PROGRAM_IMPORT_SOURCES } from "@/lib/partners/constants";
import useWorkspace from "@/lib/swr/use-workspace";
import { ProgramData } from "@/lib/types";
import { RECURRING_MAX_DURATIONS } from "@/lib/zod/schemas/misc";
import { COMMISSION_TYPES } from "@/lib/zod/schemas/rewards";
-import {
- Button,
- CircleCheckFill,
- InputSelect,
- InputSelectItemProps,
-} from "@dub/ui";
+import { Button, CircleCheckFill } from "@dub/ui";
import { cn } from "@dub/utils";
import { useAction } from "next-safe-action/hooks";
-import Link from "next/link";
import { useRouter } from "next/navigation";
-import { useEffect, useMemo, useState } from "react";
-import {
- useFormContext,
- UseFormRegister,
- UseFormSetValue,
- UseFormWatch,
-} from "react-hook-form";
+import { useEffect, useState } from "react";
+import { useFormContext } from "react-hook-form";
import { toast } from "sonner";
-import { ImportPartnerStackForm } from "./import-partnerstack-form";
-import { ImportRewardfulForm } from "./import-rewardful-form";
-import { ImportToltForm } from "./import-tolt-form";
-
-type FormProps = {
- register: UseFormRegister<ProgramData>;
- watch: UseFormWatch<ProgramData>;
- setValue: UseFormSetValue<ProgramData>;
-};
-
-export const PROGRAM_TYPES = [
- {
- value: "new",
- label: "New program",
- description: "Start a brand-new program",
- },
- {
- value: "import",
- label: "Import program",
- description: "Migrate an existing program",
- },
-] as const;
const DEFAULT_REWARD_TYPES = [
{
@@ -61,8 +27,6 @@ const DEFAULT_REWARD_TYPES = [
},
] as const;
-type ImportSource = (typeof PROGRAM_IMPORT_SOURCES)[number];
-
export function Form() {
const router = useRouter();
const [hasSubmitted, setHasSubmitted] = useState(false);
@@ -73,28 +37,23 @@ export function Form() {
handleSubmit,
watch,
setValue,
- getValues,
formState: { isSubmitting },
} = useFormContext<ProgramData>();
- const [programType, importSource, amount, type, defaultRewardType] = watch([
- "programType",
- "importSource",
+ const [amount, type, defaultRewardType, maxDuration] = watch([
"amount",
"type",
"defaultRewardType",
+ "maxDuration",
]);
+ const [commissionStructure, setCommissionStructure] = useState<
+ "one-off" | "recurring"
+ >("recurring");
+
useEffect(() => {
- if (programType === "new") {
- setValue("rewardful", null);
- setValue("tolt", null);
- } else if (programType === "import") {
- setValue("type", null);
- setValue("amount", null);
- setValue("maxDuration", null);
- }
- }, [programType]);
+ setCommissionStructure(maxDuration === 0 ? "one-off" : "recurring");
+ }, [maxDuration]);
const { executeAsync, isPending } = useAction(onboardProgramAction, {
onSuccess: () => {
@@ -122,248 +81,28 @@ export function Form() {
});
};
- const selectedSource = useMemo(() => {
- return PROGRAM_IMPORT_SOURCES.find((source) => source.id === importSource);
- }, [importSource]);
-
- const renderImportForm = () => {
- const isPendingAction = isSubmitting || isPending || hasSubmitted;
-
- switch (selectedSource?.id) {
- case "rewardful":
- return (
- <ImportRewardfulForm
- register={register}
- watch={watch}
- setValue={setValue}
- onSuccess={() => onSubmit(getValues())}
- isPending={isPendingAction}
- />
- );
- case "tolt":
- return (
- <ImportToltForm
- watch={watch}
- setValue={setValue}
- onSuccess={() => onSubmit(getValues())}
- isPending={isPendingAction}
- />
- );
- case "partnerstack":
- return (
- <ImportPartnerStackForm
- watch={watch}
- setValue={setValue}
- onSuccess={() => onSubmit(getValues())}
- isPending={isPendingAction}
- />
- );
- default:
- return null;
- }
- };
-
- const buttonDisabled =
- programType === "new" && (!amount || !type || !defaultRewardType);
+ const buttonDisabled = !amount || !type || !defaultRewardType;
return (
<form onSubmit={handleSubmit(onSubmit)} className="space-y-10">
- <div className="space-y-6">
- <div className="space-y-1">
- <h2 className="text-base font-medium text-neutral-900">
- Reward creation
- </h2>
- <p className="text-sm text-neutral-600">
- Create a brand new reward or import an existing program.
- </p>
- </div>
-
- <div className="grid grid-cols-1 gap-3 lg:grid-cols-2">
- {PROGRAM_TYPES.map((type) => {
- const isSelected = programType === type.value;
-
- return (
- <label
- key={type.value}
- className={cn(
- "relative flex w-full cursor-pointer items-start gap-0.5 rounded-md border border-neutral-200 bg-white p-3 text-neutral-600 hover:bg-neutral-50",
- "transition-all duration-150",
- isSelected &&
- "border-black bg-neutral-50 text-neutral-900 ring-1 ring-black",
- )}
- >
- <input
- type="radio"
- {...register("programType")}
- value={type.value}
- className="hidden"
- />
- <div className="flex grow flex-col text-sm">
- <span className="font-medium">{type.label}</span>
- <span>{type.description}</span>
- </div>
- <CircleCheckFill
- className={cn(
- "-mr-px -mt-px flex size-4 scale-75 items-center justify-center rounded-full opacity-0 transition-[transform,opacity] duration-150",
- isSelected && "scale-100 opacity-100",
- )}
- />
- </label>
- );
- })}
- </div>
- </div>
-
- {programType === "new" ? (
- <NewProgramForm register={register} watch={watch} setValue={setValue} />
- ) : (
- <div>
- <div className="mb-6">
- <label className="text-sm font-medium text-neutral-800">
- Import source
- </label>
- <div className="relative mt-2">
- <InputSelect
- items={
- PROGRAM_IMPORT_SOURCES as unknown as InputSelectItemProps[]
- }
- selectedItem={selectedSource ?? null}
- setSelectedItem={(item: ImportSource) => {
- if (item) {
- setValue("importSource", item.id, {
- shouldDirty: true,
- });
- }
- }}
- className="w-full"
- inputAttrs={{
- placeholder: "Select import source",
- }}
- />
- </div>
-
- {selectedSource && (
- <Link
- href={selectedSource.helpUrl}
- className="mt-2 text-xs font-normal leading-[1.1] text-neutral-600 underline decoration-solid decoration-auto underline-offset-auto"
- target="_blank"
- rel="noopener noreferrer"
- >
- See what data is migrated
- </Link>
- )}
- </div>
-
- {renderImportForm()}
- </div>
- )}
-
- {programType === "new" && (
- <Button
- text="Continue"
- className="w-full"
- loading={isSubmitting || isPending}
- disabled={buttonDisabled || hasSubmitted}
- type="submit"
- />
- )}
- </form>
- );
-}
-
-const NewProgramForm = ({ register, watch, setValue }: FormProps) => {
- const [type, maxDuration, defaultRewardType] = watch([
- "type",
- "maxDuration",
- "defaultRewardType",
- ]);
-
- const [commissionStructure, setCommissionStructure] = useState<
- "one-off" | "recurring"
- >("recurring");
-
- useEffect(() => {
- setCommissionStructure(maxDuration === 0 ? "one-off" : "recurring");
- }, [maxDuration]);
-
- return (
- <div className="flex flex-col gap-10">
- <div className="grid grid-cols-1 gap-6">
- <div>
- <h2 className="text-base font-medium text-neutral-900">
- Reward type
- </h2>
- <p className="mt-1 text-sm font-normal text-neutral-600">
- Set the default reward type for all your affiliates
- </p>
- </div>
-
- <div className="grid grid-cols-1 gap-3 lg:grid-cols-2">
- {DEFAULT_REWARD_TYPES.map(({ key, label, description }) => {
- const isSelected = key === defaultRewardType;
-
- return (
- <label
- key={key}
- className={cn(
- "relative flex w-full cursor-pointer items-start gap-0.5 rounded-md border border-neutral-200 bg-white p-3 text-neutral-600 hover:bg-neutral-50",
- "transition-all duration-150",
- isSelected &&
- "border-black bg-neutral-50 text-neutral-900 ring-1 ring-black",
- )}
- >
- <input
- type="radio"
- value={key}
- className="hidden"
- checked={isSelected}
- onChange={() => {
- setValue("defaultRewardType", key, { shouldDirty: true });
-
- if (key === "lead") {
- setValue("type", "flat", { shouldDirty: true });
- setValue("maxDuration", 0, { shouldDirty: true });
- }
- }}
- />
- <div className="flex grow flex-col text-sm">
- <span className="text-sm font-semibold text-neutral-900">
- {label}
- </span>
- <span className="text-sm font-normal text-neutral-600">
- {description}
- </span>
- </div>
- <CircleCheckFill
- className={cn(
- "-mr-px -mt-px flex size-4 scale-75 items-center justify-center rounded-full opacity-0 transition-[transform,opacity] duration-150",
- isSelected && "scale-100 opacity-100",
- )}
- />
- </label>
- );
- })}
- </div>
- </div>
-
- {defaultRewardType === "sale" && (
+ <div className="flex flex-col gap-10">
<div className="grid grid-cols-1 gap-6">
<div>
<h2 className="text-base font-medium text-neutral-900">
- Commission structure
+ Reward type
</h2>
<p className="mt-1 text-sm font-normal text-neutral-600">
- Set how the affiliate will get rewarded
+ Set the default reward type for all your affiliates
</p>
</div>
<div className="grid grid-cols-1 gap-3 lg:grid-cols-2">
- {COMMISSION_TYPES.map(({ value, label, description }) => {
- const isSelected = value === commissionStructure;
+ {DEFAULT_REWARD_TYPES.map(({ key, label, description }) => {
+ const isSelected = key === defaultRewardType;
return (
<label
- key={value}
+ key={key}
className={cn(
"relative flex w-full cursor-pointer items-start gap-0.5 rounded-md border border-neutral-200 bg-white p-3 text-neutral-600 hover:bg-neutral-50",
"transition-all duration-150",
@@ -373,20 +112,15 @@ const NewProgramForm = ({ register, watch, setValue }: FormProps) => {
>
<input
type="radio"
- value={value}
+ value={key}
className="hidden"
checked={isSelected}
- onChange={(e) => {
- if (value === "one-off") {
- setCommissionStructure("one-off");
- setValue("maxDuration", 0, { shouldValidate: true });
- }
+ onChange={() => {
+ setValue("defaultRewardType", key, { shouldDirty: true });
- if (value === "recurring") {
- setCommissionStructure("recurring");
- setValue("maxDuration", 12, {
- shouldValidate: true,
- });
+ if (key === "lead") {
+ setValue("type", "flat", { shouldDirty: true });
+ setValue("maxDuration", 0, { shouldDirty: true });
}
}}
/>
@@ -408,93 +142,166 @@ const NewProgramForm = ({ register, watch, setValue }: FormProps) => {
);
})}
</div>
+ </div>
+
+ {defaultRewardType === "sale" && (
+ <div className="grid grid-cols-1 gap-6">
+ <div>
+ <h2 className="text-base font-medium text-neutral-900">
+ Commission structure
+ </h2>
+ <p className="mt-1 text-sm font-normal text-neutral-600">
+ Set how the affiliate will get rewarded
+ </p>
+ </div>
+
+ <div className="grid grid-cols-1 gap-3 lg:grid-cols-2">
+ {COMMISSION_TYPES.map(({ value, label, description }) => {
+ const isSelected = value === commissionStructure;
+
+ return (
+ <label
+ key={value}
+ className={cn(
+ "relative flex w-full cursor-pointer items-start gap-0.5 rounded-md border border-neutral-200 bg-white p-3 text-neutral-600 hover:bg-neutral-50",
+ "transition-all duration-150",
+ isSelected &&
+ "border-black bg-neutral-50 text-neutral-900 ring-1 ring-black",
+ )}
+ >
+ <input
+ type="radio"
+ value={value}
+ className="hidden"
+ checked={isSelected}
+ onChange={(e) => {
+ if (value === "one-off") {
+ setCommissionStructure("one-off");
+ setValue("maxDuration", 0, { shouldValidate: true });
+ }
+
+ if (value === "recurring") {
+ setCommissionStructure("recurring");
+ setValue("maxDuration", 12, {
+ shouldValidate: true,
+ });
+ }
+ }}
+ />
+ <div className="flex grow flex-col text-sm">
+ <span className="text-sm font-semibold text-neutral-900">
+ {label}
+ </span>
+ <span className="text-sm font-normal text-neutral-600">
+ {description}
+ </span>
+ </div>
+ <CircleCheckFill
+ className={cn(
+ "-mr-px -mt-px flex size-4 scale-75 items-center justify-center rounded-full opacity-0 transition-[transform,opacity] duration-150",
+ isSelected && "scale-100 opacity-100",
+ )}
+ />
+ </label>
+ );
+ })}
+ </div>
+
+ {commissionStructure === "recurring" && (
+ <div>
+ <label className="text-sm font-medium text-neutral-800">
+ Duration
+ </label>
+ <select
+ {...register("maxDuration", {
+ setValueAs: (v) => {
+ if (v === "" || v === null) {
+ return null;
+ }
+
+ return parseInt(v);
+ },
+ })}
+ className="mt-2 block w-full rounded-md border border-neutral-300 bg-white py-2 pl-3 pr-10 text-sm text-neutral-900 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500"
+ >
+ {RECURRING_MAX_DURATIONS.filter(
+ (v) => v !== 0 && v !== 1, // filter out one-time and 1-month intervals (we only use 1-month for discounts)
+ ).map((duration) => (
+ <option
+ key={duration}
+ value={duration}
+ selected={duration === 12}
+ >
+ {duration} {duration === 1 ? "month" : "months"}
+ </option>
+ ))}
+ <option value="">Lifetime</option>
+ </select>
+ </div>
+ )}
+ </div>
+ )}
- {commissionStructure === "recurring" && (
+ <div className="grid grid-cols-1 gap-6">
+ <div>
+ <h2 className="text-base font-medium text-neutral-900">Payout</h2>
+ <p className="mt-1 text-sm font-normal text-neutral-600">
+ Set how much the affiliate will get rewarded
+ </p>
+ </div>
+
+ {defaultRewardType === "sale" && (
<div>
<label className="text-sm font-medium text-neutral-800">
- Duration
+ Payout model
</label>
<select
- {...register("maxDuration", {
- setValueAs: (v) => {
- if (v === "" || v === null) {
- return null;
- }
-
- return parseInt(v);
- },
- })}
+ {...register("type")}
className="mt-2 block w-full rounded-md border border-neutral-300 bg-white py-2 pl-3 pr-10 text-sm text-neutral-900 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500"
>
- {RECURRING_MAX_DURATIONS.filter(
- (v) => v !== 0 && v !== 1, // filter out one-time and 1-month intervals (we only use 1-month for discounts)
- ).map((duration) => (
- <option
- key={duration}
- value={duration}
- selected={duration === 12}
- >
- {duration} {duration === 1 ? "month" : "months"}
- </option>
- ))}
- <option value="">Lifetime</option>
+ <option value="flat">Flat</option>
+ <option value="percentage">Percentage</option>
</select>
</div>
)}
- </div>
- )}
- <div className="grid grid-cols-1 gap-6">
- <div>
- <h2 className="text-base font-medium text-neutral-900">Payout</h2>
- <p className="mt-1 text-sm font-normal text-neutral-600">
- Set how much the affiliate will get rewarded
- </p>
- </div>
-
- {defaultRewardType === "sale" && (
<div>
<label className="text-sm font-medium text-neutral-800">
- Payout model
+ Amount {defaultRewardType != "sale" ? "per lead" : ""}
</label>
- <select
- {...register("type")}
- className="mt-2 block w-full rounded-md border border-neutral-300 bg-white py-2 pl-3 pr-10 text-sm text-neutral-900 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500"
- >
- <option value="flat">Flat</option>
- <option value="percentage">Percentage</option>
- </select>
- </div>
- )}
-
- <div>
- <label className="text-sm font-medium text-neutral-800">
- Amount {defaultRewardType != "sale" ? "per lead" : ""}
- </label>
- <div className="relative mt-2 rounded-md shadow-sm">
- <span className="absolute inset-y-0 left-0 flex items-center pl-3 text-sm text-neutral-400">
- {type === "flat" && "$"}
- </span>
- <input
- className={cn(
- "block w-full rounded-md border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",
- type === "flat" ? "pl-6 pr-12" : "pr-7",
- )}
- {...register("amount", {
- required: true,
- valueAsNumber: true,
- min: 0,
- max: type === "flat" ? 1000 : 100,
- onChange: handleMoneyInputChange,
- })}
- onKeyDown={handleMoneyKeyDown}
- />
- <span className="absolute inset-y-0 right-0 flex items-center pr-3 text-sm text-neutral-400">
- {type === "flat" ? "USD" : "%"}
- </span>
+ <div className="relative mt-2 rounded-md shadow-sm">
+ <span className="absolute inset-y-0 left-0 flex items-center pl-3 text-sm text-neutral-400">
+ {type === "flat" && "$"}
+ </span>
+ <input
+ className={cn(
+ "block w-full rounded-md border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",
+ type === "flat" ? "pl-6 pr-12" : "pr-7",
+ )}
+ {...register("amount", {
+ required: true,
+ valueAsNumber: true,
+ min: 0,
+ max: type === "flat" ? 1000 : 100,
+ onChange: handleMoneyInputChange,
+ })}
+ onKeyDown={handleMoneyKeyDown}
+ />
+ <span className="absolute inset-y-0 right-0 flex items-center pr-3 text-sm text-neutral-400">
+ {type === "flat" ? "USD" : "%"}
+ </span>
+ </div>
</div>
</div>
</div>
- </div>
+
+ <Button
+ text="Continue"
+ className="w-full"
+ loading={isSubmitting || isPending}
+ disabled={buttonDisabled || hasSubmitted}
+ type="submit"
+ />
+ </form>
);
-};
+}
diff --git a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/import-partnerstack-form.tsx b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/import-partnerstack-form.tsx
deleted file mode 100644
index b38199581b..0000000000
--- a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/import-partnerstack-form.tsx
+++ /dev/null
@@ -1,108 +0,0 @@
-"use client";
-
-import { setPartnerStackTokenAction } from "@/lib/actions/partners/set-partnerstack-token";
-import useWorkspace from "@/lib/swr/use-workspace";
-import { ProgramData } from "@/lib/types";
-import { Button, Input } from "@dub/ui";
-import { useAction } from "next-safe-action/hooks";
-import Link from "next/link";
-import { useState } from "react";
-import { UseFormSetValue, UseFormWatch } from "react-hook-form";
-import { toast } from "sonner";
-
-export const ImportPartnerStackForm = ({
- watch,
- setValue,
- onSuccess,
- isPending,
-}: {
- watch: UseFormWatch<ProgramData>;
- setValue: UseFormSetValue<ProgramData>;
- onSuccess: () => void;
- isPending: boolean;
-}) => {
- const { id: workspaceId } = useWorkspace();
- const [publicKey, setPublicKey] = useState("");
- const [secretKey, setSecretKey] = useState("");
-
- const partnerStack = watch("partnerstack");
-
- const { executeAsync, isPending: isSettingPartnerStackToken } = useAction(
- setPartnerStackTokenAction,
- {
- onSuccess: ({ data }) => {
- setValue("partnerstack", {
- publicKey: data?.publicKey,
- maskedSecretKey: data?.maskedSecretKey,
- });
- onSuccess();
- toast.success("PartnerStack credentials saved successfully!");
- },
- onError: ({ error }) => {
- toast.error(error.serverError);
- },
- },
- );
-
- const onSubmit = async () => {
- if (!workspaceId || !publicKey || !secretKey) {
- toast.error("Please fill in all required fields.");
- return;
- }
-
- await executeAsync({
- workspaceId,
- publicKey,
- secretKey,
- });
- };
-
- return (
- <div className="space-y-6">
- <div>
- <label className="text-sm font-medium text-neutral-800">
- PartnerStack Public Key
- </label>
- <Input
- type="password"
- placeholder="Public key"
- className="mt-2 max-w-full"
- value={publicKey || partnerStack?.publicKey || ""}
- onChange={(e) => setPublicKey(e.target.value)}
- />
- <div className="mt-2 text-xs font-normal leading-[1.1] text-neutral-600">
- Find your PartnerStack API keys in your{" "}
- <Link
- href="https://app.partnerstack.com/settings/integrations"
- className="underline decoration-solid decoration-auto underline-offset-auto"
- target="_blank"
- rel="noopener noreferrer"
- >
- Settings
- </Link>
- </div>
- </div>
-
- <div>
- <label className="text-sm font-medium text-neutral-800">
- PartnerStack Secret Key
- </label>
- <Input
- type="password"
- placeholder="Secret key"
- className="mt-2 max-w-full"
- value={secretKey || partnerStack?.maskedSecretKey || ""}
- onChange={(e) => setSecretKey(e.target.value)}
- />
- </div>
-
- <Button
- text="Continue"
- className="w-full"
- disabled={!publicKey || !secretKey}
- loading={isSettingPartnerStackToken || isPending}
- onClick={onSubmit}
- />
- </div>
- );
-};
diff --git a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/import-rewardful-form.tsx b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/import-rewardful-form.tsx
deleted file mode 100644
index f7bb4bbeb4..0000000000
--- a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/import-rewardful-form.tsx
+++ /dev/null
@@ -1,193 +0,0 @@
-"use client";
-
-import { setRewardfulTokenAction } from "@/lib/actions/partners/set-rewardful-token";
-import { RewardfulCampaign } from "@/lib/rewardful/types";
-import { useRewardfulCampaigns } from "@/lib/swr/use-rewardful-campaigns";
-import useWorkspace from "@/lib/swr/use-workspace";
-import { ProgramData } from "@/lib/types";
-import { Button, Input } from "@dub/ui";
-import { capitalize } from "@dub/utils";
-import { ChevronDown } from "lucide-react";
-import { useAction } from "next-safe-action/hooks";
-import Link from "next/link";
-import { useCallback, useEffect, useState } from "react";
-import {
- UseFormRegister,
- UseFormSetValue,
- UseFormWatch,
-} from "react-hook-form";
-import { toast } from "sonner";
-
-export const ImportRewardfulForm = ({
- register,
- watch,
- setValue,
- onSuccess,
- isPending,
-}: {
- register: UseFormRegister<ProgramData>;
- watch: UseFormWatch<ProgramData>;
- setValue: UseFormSetValue<ProgramData>;
- onSuccess: () => void;
- isPending: boolean;
-}) => {
- const { id: workspaceId } = useWorkspace();
- const [token, setToken] = useState("");
-
- const rewardful = watch("rewardful");
-
- const {
- executeAsync: setRewardfulToken,
- isPending: isSettingRewardfulToken,
- } = useAction(setRewardfulTokenAction, {
- onSuccess: ({ data }) => {
- setValue("rewardful.maskedToken", data?.maskedToken);
- },
- onError: ({ error }) => {
- toast.error(error.serverError);
- },
- });
-
- const { campaigns, loading: isLoadingCampaigns } = useRewardfulCampaigns({
- enabled: !!rewardful?.maskedToken,
- });
-
- const selectedCampaign = campaigns?.find(
- (campaign) => campaign.id === rewardful?.id,
- );
-
- useEffect(() => {
- if (selectedCampaign) {
- setValue("rewardful", {
- ...rewardful,
- ...selectedCampaign,
- });
- }
- }, [selectedCampaign, setValue]);
-
- const formatCommission = useCallback((campaign: RewardfulCampaign) => {
- return campaign.reward_type === "percent"
- ? `${campaign.commission_percent}%`
- : `$${(campaign.commission_amount_cents / 100).toFixed(2)}`;
- }, []);
-
- return (
- <div className="space-y-6">
- <div>
- <label className="text-sm font-medium text-neutral-800">
- Rewardful API secret
- </label>
- <Input
- type="password"
- placeholder="API token"
- className="mt-2 max-w-full"
- value={token || rewardful?.maskedToken || ""}
- onChange={(e) => setToken(e.target.value)}
- />
- <div className="mt-2 text-xs font-normal leading-[1.1] text-neutral-600">
- Find your Rewardful API secret on your{" "}
- <Link
- href="https://app.getrewardful.com/company/edit"
- className="underline decoration-solid decoration-auto underline-offset-auto"
- target="_blank"
- rel="noopener noreferrer"
- >
- Company settings page
- </Link>
- </div>
- </div>
-
- {rewardful?.maskedToken && (
- <div>
- <label className="text-sm font-medium text-neutral-800">
- Campaign to import
- </label>
- <div className="relative mt-2">
- {isLoadingCampaigns ? (
- <div className="h-10 w-full animate-pulse rounded-md bg-neutral-200" />
- ) : (
- <>
- <select
- {...register("rewardful.id")}
- className="block w-full appearance-none rounded-md border border-neutral-200 bg-white px-3 py-2 pr-8 text-sm text-neutral-900 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500"
- >
- <option value="">Select a campaign</option>
- {campaigns?.map(({ id, name }) => (
- <option key={id} value={id}>
- {name}
- </option>
- ))}
- </select>
- <ChevronDown className="absolute right-3 top-1/2 size-4 -translate-y-1/2 text-neutral-400" />
- </>
- )}
- </div>
- <Link
- href="https://dub.co/help/article/migrating-from-rewardful#migrating-multiple-campaigns"
- className="mt-2 text-xs font-normal leading-[1.1] text-neutral-600 underline decoration-solid decoration-auto underline-offset-auto"
- target="_blank"
- rel="noopener noreferrer"
- >
- Want to migrate more than one campaign?
- </Link>
- </div>
- )}
-
- {selectedCampaign && (
- <div className="space-y-6">
- <div className="grid grid-cols-2 gap-6 rounded-lg border border-neutral-300 bg-neutral-50 p-6">
- <div>
- <div className="text-sm text-neutral-500">Type</div>
- <div className="text-sm font-medium text-neutral-800">
- {capitalize(selectedCampaign.reward_type)}
- </div>
- </div>
- <div>
- <div className="text-sm text-neutral-500">Duration</div>
- <div className="text-sm font-medium text-neutral-800">
- {selectedCampaign.max_commission_period_months} months
- </div>
- </div>
- <div>
- <div className="text-sm text-neutral-500">Commission</div>
- <div className="text-sm font-medium text-neutral-800">
- {formatCommission(selectedCampaign)}
- </div>
- </div>
- <div>
- <div className="text-sm text-neutral-500">Affiliates</div>
- <div className="text-sm font-medium text-neutral-800">
- {selectedCampaign.affiliates}
- </div>
- </div>
- </div>
-
- <Button
- type="button"
- text="Continue"
- className="w-full"
- onClick={onSuccess}
- loading={isPending}
- />
- </div>
- )}
-
- {!rewardful?.id && (
- <Button
- text="Fetch campaigns"
- className="w-full"
- disabled={isSettingRewardfulToken || !token}
- loading={isSettingRewardfulToken}
- onClick={async () => {
- if (!workspaceId) return;
-
- await setRewardfulToken({
- workspaceId,
- token,
- });
- }}
- />
- )}
- </div>
- );
-};
diff --git a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/import-tolt-form.tsx b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/import-tolt-form.tsx
deleted file mode 100644
index e1afe900a9..0000000000
--- a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/import-tolt-form.tsx
+++ /dev/null
@@ -1,215 +0,0 @@
-"use client";
-
-import { setToltTokenAction } from "@/lib/actions/partners/set-tolt-token";
-import useWorkspace from "@/lib/swr/use-workspace";
-import { ToltProgram } from "@/lib/tolt/types";
-import { ProgramData } from "@/lib/types";
-import { Button, Input } from "@dub/ui";
-import { useAction } from "next-safe-action/hooks";
-import Link from "next/link";
-import { useEffect, useState } from "react";
-import { UseFormSetValue, UseFormWatch } from "react-hook-form";
-import { toast } from "sonner";
-
-type Step = "set-token" | "program-info";
-
-export const ImportToltForm = ({
- watch,
- setValue,
- onSuccess,
- isPending,
-}: {
- watch: UseFormWatch<ProgramData>;
- setValue: UseFormSetValue<ProgramData>;
- onSuccess: () => void;
- isPending: boolean;
-}) => {
- const [step, setStep] = useState<Step>("set-token");
- const [toltProgram, setToltProgram] = useState<ToltProgram | null>(null);
-
- const tolt = watch("tolt");
-
- useEffect(() => {
- if (tolt) {
- setToltProgram(tolt);
- setStep("program-info");
- }
- }, [tolt]);
-
- return (
- <>
- {step === "set-token" ? (
- <ToltTokenForm
- setStep={setStep}
- setToltProgram={setToltProgram}
- setValue={setValue}
- />
- ) : (
- <ToltProgramInfo
- toltProgram={toltProgram}
- onSuccess={onSuccess}
- isPending={isPending}
- />
- )}
- </>
- );
-};
-
-function ToltTokenForm({
- setStep,
- setToltProgram,
- setValue,
-}: {
- setStep: (step: Step) => void;
- setToltProgram: (program: ToltProgram | null) => void;
- setValue: UseFormSetValue<ProgramData>;
-}) {
- const [token, setToken] = useState("");
- const { id: workspaceId } = useWorkspace();
- const [toltProgramId, setToltProgramId] = useState("");
-
- const { executeAsync, isPending } = useAction(setToltTokenAction, {
- onSuccess: ({ data }) => {
- if (data?.program) {
- setToltProgram(data.program);
-
- setValue("tolt", {
- ...data.program,
- });
-
- setStep("program-info");
- }
- },
- onError: ({ error }) => {
- toast.error(error.serverError);
- },
- });
-
- const handleFetchProgram = async () => {
- if (!workspaceId || !token || !toltProgramId) {
- return;
- }
-
- await executeAsync({
- workspaceId,
- toltProgramId,
- token,
- });
- };
-
- return (
- <div className="space-y-6">
- <div>
- <label className="text-sm font-medium text-neutral-800">
- Tolt API Key
- </label>
- <Input
- type="password"
- placeholder="API token"
- className="mt-2 max-w-full"
- value={token}
- onChange={(e) => setToken(e.target.value)}
- />
- <div className="mt-2 text-xs font-normal leading-[1.1] text-neutral-600">
- You can find your Tolt API key on your{" "}
- <Link
- href="https://app.tolt.io/settings?tab=integrations"
- className="underline decoration-solid decoration-auto underline-offset-auto"
- target="_blank"
- rel="noopener noreferrer"
- >
- Integrations tab
- </Link>
- </div>
- </div>
-
- <div>
- <label className="text-sm font-medium text-neutral-800">
- Tolt Program ID
- </label>
- <Input
- type="text"
- placeholder="Program ID"
- className="mt-2 max-w-full"
- value={toltProgramId}
- onChange={(e) => setToltProgramId(e.target.value)}
- />
- <div className="mt-2 text-xs font-normal leading-[1.1] text-neutral-600">
- You can find your program ID in your{" "}
- <Link
- href="https://app.tolt.io/program-settings?page=general-settings"
- className="underline decoration-solid decoration-auto underline-offset-auto"
- target="_blank"
- rel="noopener noreferrer"
- >
- General settings tab
- </Link>
- </div>
- </div>
-
- <Button
- text={isPending ? "Fetching program..." : "Fetch program"}
- className="w-full"
- disabled={!token || !toltProgramId}
- loading={isPending}
- onClick={handleFetchProgram}
- />
- </div>
- );
-}
-
-function ToltProgramInfo({
- toltProgram,
- onSuccess,
- isPending,
-}: {
- toltProgram: ToltProgram | null;
- onSuccess: () => void;
- isPending: boolean;
-}) {
- if (!toltProgram) {
- return null;
- }
-
- return (
- <div className="space-y-6">
- <div>
- <h4 className="mb-3 text-sm font-medium text-neutral-700">
- Program Information
- </h4>
- <dl className="grid grid-cols-2 gap-3 rounded-md border border-neutral-200 bg-white p-4 text-xs">
- <div>
- <dt className="text-neutral-500">Name</dt>
- <dd className="font-medium text-neutral-700">{toltProgram.name}</dd>
- </div>
- <div>
- <dt className="text-neutral-500">Subdomain</dt>
- <dd className="font-medium text-neutral-700">
- {toltProgram.subdomain}
- </dd>
- </div>
- <div>
- <dt className="text-neutral-500">Payout Term</dt>
- <dd className="font-medium text-neutral-700">
- {toltProgram.payout_term} days
- </dd>
- </div>
- <div>
- <dt className="text-neutral-500">Total Partners</dt>
- <dd className="font-medium text-neutral-700">
- {toltProgram.affiliates?.toLocaleString() || "0"}
- </dd>
- </div>
- </dl>
- </div>
-
- <Button
- type="button"
- text="Continue"
- className="w-full"
- onClick={onSuccess}
- loading={isPending}
- />
- </div>
- );
-}
diff --git a/apps/web/app/(ee)/app.dub.co/(new-program)/form-wrapper.tsx b/apps/web/app/(ee)/app.dub.co/(new-program)/form-wrapper.tsx
index 8ff8b097de..ca234cc588 100644
--- a/apps/web/app/(ee)/app.dub.co/(new-program)/form-wrapper.tsx
+++ b/apps/web/app/(ee)/app.dub.co/(new-program)/form-wrapper.tsx
@@ -11,7 +11,6 @@ export function FormWrapper({ children }: { children: React.ReactNode }) {
const methods = useForm<ProgramData>({
defaultValues: {
linkStructure: "short",
- programType: "new",
defaultRewardType: "sale",
type: "percentage",
amount: null,
@@ -23,7 +22,6 @@ export function FormWrapper({ children }: { children: React.ReactNode }) {
...programOnboarding,
linkStructure: programOnboarding.linkStructure ?? "short",
defaultRewardType: programOnboarding.defaultRewardType ?? "sale",
- programType: programOnboarding.programType ?? "new",
type: programOnboarding.type ?? "percentage",
amount:
programOnboarding.type === "flat" && programOnboarding.amount
diff --git a/apps/web/app/(ee)/app.dub.co/(new-program)/header.tsx b/apps/web/app/(ee)/app.dub.co/(new-program)/header.tsx
index ec9e6209b8..bb1ab19e6d 100644
--- a/apps/web/app/(ee)/app.dub.co/(new-program)/header.tsx
+++ b/apps/web/app/(ee)/app.dub.co/(new-program)/header.tsx
@@ -38,21 +38,10 @@ export function ProgramOnboardingHeader() {
data = {
...data,
url: data.url === "" ? null : data.url,
-
partners:
data?.partners?.filter(
(partner) => partner.email !== "" && partner.key !== "",
) ?? null,
-
- ...(data.programType === "new" && {
- rewardful: null,
- }),
-
- ...(data.programType === "import" && {
- type: null,
- amount: null,
- maxDuration: null,
- }),
};
const currentPath = pathname.replace(`/${workspaceSlug}`, "");
diff --git a/apps/web/lib/actions/partners/create-program.ts b/apps/web/lib/actions/partners/create-program.ts
index e83a69296f..45dbaedf6a 100644
--- a/apps/web/lib/actions/partners/create-program.ts
+++ b/apps/web/lib/actions/partners/create-program.ts
@@ -3,10 +3,7 @@ import { createId } from "@/lib/api/create-id";
import { getDomainOrThrow } from "@/lib/api/domains/get-domain-or-throw";
import { createAndEnrollPartner } from "@/lib/api/partners/create-and-enroll-partner";
import { createPartnerLink } from "@/lib/api/partners/create-partner-link";
-import { partnerStackImporter } from "@/lib/partnerstack/importer";
-import { rewardfulImporter } from "@/lib/rewardful/importer";
import { isStored, storage } from "@/lib/storage";
-import { toltImporter } from "@/lib/tolt/importer";
import { WorkspaceProps } from "@/lib/types";
import { DEFAULT_PARTNER_GROUP } from "@/lib/zod/schemas/groups";
import { programDataSchema } from "@/lib/zod/schemas/program-onboarding";
@@ -46,14 +43,11 @@ export const createProgram = async ({
amount,
maxDuration,
partners,
- rewardful,
- tolt,
linkStructure,
supportEmail,
helpUrl,
termsUrl,
logo: uploadedLogo,
- importSource,
} = programDataSchema.parse(store.programOnboarding);
await getDomainOrThrow({ workspace, domain });
@@ -175,32 +169,6 @@ export const createProgram = async ({
return programData;
});
- // Start the import process if the import source is set
- if (importSource === "rewardful" && rewardful?.id) {
- await rewardfulImporter.queue({
- importId: createId({ prefix: "import_" }),
- userId: user.id,
- programId: program.id,
- campaignId: rewardful.id,
- action: "import-campaign",
- });
- } else if (importSource === "tolt" && tolt?.id) {
- await toltImporter.queue({
- importId: createId({ prefix: "import_" }),
- userId: user.id,
- programId: program.id,
- toltProgramId: tolt.id,
- action: "import-partners",
- });
- } else if (importSource === "partnerstack") {
- await partnerStackImporter.queue({
- importId: createId({ prefix: "import_" }),
- userId: user.id,
- programId: program.id,
- action: "import-groups",
- });
- }
-
waitUntil(
Promise.allSettled([
// invite partners
diff --git a/apps/web/lib/actions/partners/set-partnerstack-token.ts b/apps/web/lib/actions/partners/set-partnerstack-token.ts
deleted file mode 100644
index d05f54568b..0000000000
--- a/apps/web/lib/actions/partners/set-partnerstack-token.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-"use server";
-
-import { PartnerStackApi } from "@/lib/partnerstack/api";
-import { partnerStackImporter } from "@/lib/partnerstack/importer";
-import { partnerStackCredentialsSchema } from "@/lib/partnerstack/schemas";
-import { z } from "zod";
-import { authActionClient } from "../safe-action";
-
-const schema = partnerStackCredentialsSchema.extend({
- workspaceId: z.string(),
-});
-
-export const setPartnerStackTokenAction = authActionClient
- .schema(schema)
- .action(async ({ parsedInput, ctx }) => {
- const { workspace } = ctx;
- const { publicKey, secretKey } = parsedInput;
-
- const partnerStackApi = new PartnerStackApi({
- publicKey,
- secretKey,
- });
-
- await partnerStackApi.testConnection();
-
- await partnerStackImporter.setCredentials(workspace.id, {
- publicKey,
- secretKey,
- });
-
- return {
- publicKey,
- maskedSecretKey: secretKey.slice(0, 3) + "*".repeat(secretKey.length - 3),
- };
- });
diff --git a/apps/web/lib/zod/schemas/program-onboarding.ts b/apps/web/lib/zod/schemas/program-onboarding.ts
index 35202a1ac0..982d995e54 100644
--- a/apps/web/lib/zod/schemas/program-onboarding.ts
+++ b/apps/web/lib/zod/schemas/program-onboarding.ts
@@ -1,4 +1,3 @@
-import { ToltProgramSchema } from "@/lib/tolt/schemas";
import { PartnerLinkStructure, RewardStructure } from "@dub/prisma/client";
import { z } from "zod";
import { maxDurationSchema } from "./misc";
@@ -16,40 +15,12 @@ export const programInfoSchema = z.object({
});
// Configure rewards
-export const programRewardSchema = z
- .object({
- programType: z.enum(["new", "import"]),
- importSource: z.enum(["rewardful", "tolt", "partnerstack"]).nullish(),
- rewardful: z
- .object({
- maskedToken: z.string().nullish(),
- id: z.string(),
- affiliates: z.number(),
- commission_amount_cents: z.number().nullable(),
- max_commission_period_months: z.number().nullable(),
- reward_type: z.enum(["amount", "percent"]),
- commission_percent: z.number().nullable(),
- })
- .nullish(),
- tolt: ToltProgramSchema.extend({
- id: z.string(),
- affiliates: z.number(),
- }).nullish(),
- partnerstack: z
- .object({
- publicKey: z.string().nullish(),
- maskedSecretKey: z.string().nullish(),
- })
- .nullish(),
- })
- .merge(
- z.object({
- defaultRewardType: z.enum(["lead", "sale"]).default("lead"),
- type: z.nativeEnum(RewardStructure).nullish(),
- amount: z.number().min(0).nullish(),
- maxDuration: maxDurationSchema,
- }),
- );
+export const programRewardSchema = z.object({
+ defaultRewardType: z.enum(["lead", "sale"]).default("lead"),
+ type: z.nativeEnum(RewardStructure).nullish(),
+ amount: z.number().min(0).nullish(),
+ maxDuration: maxDurationSchema,
+});
// Invite partners
export const programInvitePartnersSchema = z.object({