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.

isValidElement check in DynamicTooltipWrapper

Steven Tey914d5518403a
diff --git a/apps/web/scripts/payouts/backfill-completed-payout-commissions.ts b/apps/web/scripts/payouts/backfill-completed-payout-commissions.ts
deleted file mode 100644
index d2df4bba12..0000000000
--- a/apps/web/scripts/payouts/backfill-completed-payout-commissions.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-import { prisma } from "@dub/prisma";
-import { Prisma } from "@dub/prisma/client";
-import "dotenv-flow/config";
-
-const BATCH_SIZE = 500;
-const DRY_RUN = process.env.DRY_RUN !== "false"; // default to dry-run for safety
-
-// Reconciles commissions that are stuck at "processed" even though their payout
-// is already "completed" (money has moved). Run via:
-// pnpm script payouts/backfill-completed-payout-commissions
-// Set DRY_RUN=false to actually apply the updates.
-async function main() {
- const where: Prisma.CommissionWhereInput = {
- status: "processed",
- payout: {
- status: "completed",
- },
- };
-
- const total = await prisma.commission.count({ where });
- console.log(`${total} commissions to reconcile (DRY_RUN=${DRY_RUN})`);
-
- if (DRY_RUN || total === 0) {
- return;
- }
-
- let totalUpdated = 0;
- while (true) {
- const batch = await prisma.commission.findMany({
- where,
- select: { id: true },
- take: BATCH_SIZE,
- });
-
- if (batch.length === 0) {
- break;
- }
-
- const { count } = await prisma.commission.updateMany({
- where: {
- id: {
- in: batch.map((c) => c.id),
- },
- },
- data: {
- status: "paid",
- },
- });
-
- totalUpdated += count;
- console.log(`Updated ${totalUpdated}/${total}...`);
- }
-
- console.log(`Done. Updated ${totalUpdated} commissions to "paid".`);
-}
-
-main();
diff --git a/packages/ui/src/tooltip.tsx b/packages/ui/src/tooltip.tsx
index 4b8425bb5f..d7b3a327b9 100644
--- a/packages/ui/src/tooltip.tsx
+++ b/packages/ui/src/tooltip.tsx
@@ -4,7 +4,7 @@ import { cn } from "@dub/utils";
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
import { HelpCircle } from "lucide-react";
import Link from "next/link";
-import { ReactNode, useEffect, useRef, useState } from "react";
+import { isValidElement, ReactNode, useEffect, useRef, useState } from "react";
import ReactMarkdown from "react-markdown";
import { Badge } from "./badge";
import { Button, ButtonProps, buttonVariants } from "./button";
@@ -222,7 +222,9 @@ export function DynamicTooltipWrapper({
tooltipProps?: TooltipProps;
}) {
return tooltipProps ? (
- <Tooltip {...tooltipProps}>{children}</Tooltip>
+ <Tooltip {...tooltipProps}>
+ {isValidElement(children) ? children : <span>{children}</span>}
+ </Tooltip>
) : (
children
);