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.

final fixes

Steven Teyefecb84a8eb7
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/success/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/success/page-client.tsx
index 0b699e6126..ebb28e855f 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/success/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/success/page-client.tsx
@@ -189,7 +189,7 @@ export function PayoutsSuccessPageClient() {
<Link
href={`/${slug}/settings/billing/invoices?type=payout`}
className={cn(
- "flex h-9 w-full items-center justify-center whitespace-nowrap rounded-lg border px-5 text-base text-sm",
+ "flex h-9 w-full items-center justify-center whitespace-nowrap rounded-lg border px-5 text-sm",
buttonVariants({ variant: "primary" }),
)}
>
diff --git a/apps/web/ui/partners/rewards/add-edit-reward-sheet.tsx b/apps/web/ui/partners/rewards/add-edit-reward-sheet.tsx
index dae1cea017..c8f264c4bf 100644
--- a/apps/web/ui/partners/rewards/add-edit-reward-sheet.tsx
+++ b/apps/web/ui/partners/rewards/add-edit-reward-sheet.tsx
@@ -21,7 +21,7 @@ import {
} from "@/lib/zod/schemas/rewards";
import { X } from "@/ui/shared/icons";
import { EventType } from "@dub/prisma/client";
-import { Button, MoneyBills2, Sheet } from "@dub/ui";
+import { Button, MoneyBills2, Sheet, TooltipContent } from "@dub/ui";
import { capitalize, cn, pluralize } from "@dub/utils";
import { useAction } from "next-safe-action/hooks";
import {
@@ -31,6 +31,7 @@ import {
SetStateAction,
useContext,
useEffect,
+ useMemo,
useRef,
useState,
} from "react";
@@ -199,9 +200,9 @@ function RewardSheetContent({
);
} catch (error) {
console.error(error);
- setError("root.logic", { message: "Invalid reward logic" });
+ setError("root.logic", { message: "Invalid reward condition" });
toast.error(
- "Invalid reward logic. Please fix the errors and try again.",
+ "Invalid reward condition. Please fix the errors and try again.",
);
return;
}
@@ -248,6 +249,17 @@ function RewardSheetContent({
const { rewardsUpgradeModal, setShowRewardsUpgradeModal } =
useRewardsUpgradeModal();
+ const showAdvancedUpsell = useMemo(() => {
+ if (
+ getValues("modifiers")?.length > 0 &&
+ !getPlanCapabilities(plan).canUseAdvancedRewardLogic
+ ) {
+ return true;
+ }
+
+ return false;
+ }, [getValues("modifiers"), plan]);
+
return (
<FormProvider {...form}>
{rewardsUpgradeModal}
@@ -407,16 +419,6 @@ function RewardSheetContent({
<Button
type="submit"
- onClick={(e) => {
- const modifiers = getValues("modifiers");
- if (
- modifiers?.length &&
- !getPlanCapabilities(plan).canUseAdvancedRewardLogic
- ) {
- setShowRewardsUpgradeModal(true);
- e.preventDefault();
- }
- }}
variant="primary"
text={reward ? "Update reward" : "Create reward"}
className="w-fit"
@@ -424,6 +426,15 @@ function RewardSheetContent({
disabled={
amount == null || isDeleting || isCreating || isUpdating
}
+ disabledTooltip={
+ showAdvancedUpsell ? (
+ <TooltipContent
+ title="Advanced reward structures are only available on the Advanced plan and above."
+ cta="Upgrade to Advanced"
+ onClick={() => setShowRewardsUpgradeModal(true)}
+ />
+ ) : undefined
+ }
/>
</div>
</div>
diff --git a/apps/web/ui/partners/rewards/rewards-logic.tsx b/apps/web/ui/partners/rewards/rewards-logic.tsx
index 50e3dea2e8..66070e100a 100644
--- a/apps/web/ui/partners/rewards/rewards-logic.tsx
+++ b/apps/web/ui/partners/rewards/rewards-logic.tsx
@@ -20,13 +20,11 @@ import {
InvoiceDollar,
MoneyBills2,
Popover,
- Tooltip,
- TooltipContent,
User,
} from "@dub/ui";
import { capitalize, cn, COUNTRIES, pluralize, truncate } from "@dub/utils";
import { Command } from "cmdk";
-import { Fragment, PropsWithChildren, useContext, useState } from "react";
+import { Fragment, useContext, useState } from "react";
import { useFieldArray, useWatch } from "react-hook-form";
import { useAddEditRewardForm } from "./add-edit-reward-sheet";
import {
@@ -37,7 +35,6 @@ import {
InlineBadgePopoverMenu,
} from "./inline-badge-popover";
import { RewardIconSquare } from "./reward-icon-square";
-import { useRewardsUpgradeModal } from "./rewards-upgrade-modal";
export function RewardsLogic({
isDefaultReward,
@@ -69,71 +66,38 @@ export function RewardsLogic({
onRemove={() => removeModifier(index)}
/>
))}
- <UpgradeTooltip>
- <Button
- className="h-8 rounded-lg"
- icon={<ArrowTurnRight2 className="size-4" />}
- text={
- <div className="flex items-center gap-2">
- <span>Add logic</span>
- {!getPlanCapabilities(plan).canUseAdvancedRewardLogic && (
- <div
- className={cn(
- "rounded-sm px-1 py-0.5 text-[0.625rem] uppercase leading-none",
- isDefaultReward
- ? "bg-violet-500/50 text-violet-400"
- : "bg-violet-50 text-violet-600",
- )}
- >
- Upgrade
- </div>
- )}
- </div>
- }
- onClick={() =>
- appendModifier({
- operator: "AND",
- conditions: [{}],
- amount: getValues("amount") || 0,
- })
- }
- variant={isDefaultReward ? "primary" : "secondary"}
- />
- </UpgradeTooltip>
+ <Button
+ className="h-8 rounded-lg"
+ icon={<ArrowTurnRight2 className="size-4" />}
+ text={
+ <div className="flex items-center gap-2">
+ <span>Add condition</span>
+ {!getPlanCapabilities(plan).canUseAdvancedRewardLogic && (
+ <div
+ className={cn(
+ "rounded-sm px-1 py-0.5 text-[0.625rem] uppercase leading-none",
+ isDefaultReward
+ ? "bg-violet-500/50 text-violet-400"
+ : "bg-violet-50 text-violet-600",
+ )}
+ >
+ Upgrade required
+ </div>
+ )}
+ </div>
+ }
+ onClick={() =>
+ appendModifier({
+ operator: "AND",
+ conditions: [{}],
+ amount: getValues("amount") || 0,
+ })
+ }
+ variant={isDefaultReward ? "primary" : "secondary"}
+ />
</div>
);
}
-
-function UpgradeTooltip({ children }: PropsWithChildren) {
- const { plan } = useWorkspace();
-
- const { rewardsUpgradeModal, setShowRewardsUpgradeModal } =
- useRewardsUpgradeModal();
-
- if (getPlanCapabilities(plan).canUseAdvancedRewardLogic) return children;
-
- return (
- <>
- {rewardsUpgradeModal}
- <Tooltip
- content={({ setOpen }) => (
- <TooltipContent
- title="Requires the Advanced plan and above."
- cta="Upgrade to Advanced"
- onClick={() => {
- setOpen(false);
- setShowRewardsUpgradeModal(true);
- }}
- />
- )}
- side="bottom"
- >
- <div>{children}</div>
- </Tooltip>
- </>
- );
-}
-
function ConditionalGroup({
index,
groupCount,
@@ -159,7 +123,7 @@ function ConditionalGroup({
<div className="flex items-center gap-1.5 text-neutral-800">
<ArrowTurnRight2 className="size-3 shrink-0" />
<span className="text-sm font-medium">
- {index === 0 ? "Reward logic" : "Additional logic"}
+ {index === 0 ? "Reward condition" : "Additional condition"}
</span>
</div>
<div className="flex items-center gap-1">
diff --git a/apps/web/ui/partners/rewards/rewards-upgrade-modal.tsx b/apps/web/ui/partners/rewards/rewards-upgrade-modal.tsx
index 0b127d55a1..6088eca6b3 100644
--- a/apps/web/ui/partners/rewards/rewards-upgrade-modal.tsx
+++ b/apps/web/ui/partners/rewards/rewards-upgrade-modal.tsx
@@ -96,7 +96,7 @@ export function RewardsUpgradeModal({
</h2>
<p className="text-content-subtle text-sm">
When you upgrade to Advanced, you&rsquo;ll get access higher payout
- limits, flexible reward logic, white-labeling support, and much
+ limits, advanced reward structures, white-labeling support, and
more.
</p>
</div>