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.

style changes

Steven Tey5a4c91bdf4fd
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsx
index 5611be7f7d..2db69d0853 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsx
@@ -4,6 +4,7 @@ import usePartnerAnalytics from "@/lib/swr/use-partner-analytics";
import useProgramEnrollment from "@/lib/swr/use-program-enrollment";
import { PartnerProfileLinkProps } from "@/lib/types";
import { CommentsBadge } from "@/ui/links/comments-badge";
+import { DiscountCodeBadge } from "@/ui/partners/discounts/discount-code-badge";
import {
ArrowTurnRight2,
Button,
@@ -13,7 +14,6 @@ import {
InvoiceDollar,
LinkLogo,
LoadingSpinner,
- Tag,
useCopyToClipboard,
useInViewport,
UserCheck,
@@ -155,25 +155,6 @@ export function PartnerLinkCard({ link }: { link: PartnerProfileLinkProps }) {
</div>
{link.comments && <CommentsBadge comments={link.comments} />}
-
- {link.discountCode && (
- <div className="group/discountcode relative flex h-5 w-fit items-center gap-1 rounded-lg bg-green-100 py-0 pl-1 pr-1.5 transition-colors duration-150 hover:bg-green-200">
- <Tag
- className="size-3 text-green-700"
- strokeWidth={1.5}
- />
- <div className="text-xs font-medium text-green-700 transition-colors">
- {link.discountCode}
- </div>
- <span className="flex items-center">
- <CopyButton
- value={link.discountCode}
- variant="neutral"
- className="p-0.5"
- />
- </span>
- </div>
- )}
</div>
{/* The max width implementation here is a bit hacky, we should improve in the future */}
@@ -199,7 +180,12 @@ export function PartnerLinkCard({ link }: { link: PartnerProfileLinkProps }) {
</div>
</div>
</div>
- <Controls link={link} />
+ <div className="flex items-center gap-2">
+ {link.discountCode && (
+ <DiscountCodeBadge code={link.discountCode} showTooltip />
+ )}
+ <Controls link={link} />
+ </div>
</div>
<div className="mt-4 grid grid-cols-1 gap-4 sm:grid-cols-3">
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/[partnerId]/links/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/[partnerId]/links/page-client.tsx
index 9244a5de53..b2a0fe0b1c 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/[partnerId]/links/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/[partnerId]/links/page-client.tsx
@@ -7,6 +7,7 @@ import { DiscountCodeProps, EnrolledPartnerProps } from "@/lib/types";
import { useAddDiscountCodeModal } from "@/ui/modals/add-discount-code-modal";
import { useAddPartnerLinkModal } from "@/ui/modals/add-partner-link-modal";
import { DeleteDiscountCodeModal } from "@/ui/modals/delete-discount-code-modal";
+import { DiscountCodeBadge } from "@/ui/partners/discounts/discount-code-badge";
import {
Button,
CopyButton,
@@ -27,7 +28,7 @@ export function ProgramPartnerLinksPageClient() {
const { partner, error } = usePartner({ partnerId });
return partner ? (
- <div className="space-y-8">
+ <div className="grid gap-4">
<PartnerLinks partner={partner} />
<PartnerDiscountCodes partner={partner} />
</div>
@@ -145,7 +146,9 @@ const PartnerLinks = ({ partner }: { partner: EnrolledPartnerProps }) => {
return (
<>
<div className="flex items-end justify-between gap-4">
- <h2 className="text-content-emphasis text-lg font-semibold">Links</h2>
+ <h2 className="text-content-emphasis text-lg font-semibold">
+ Referral links
+ </h2>
<Button
variant="secondary"
text="Create link"
@@ -153,9 +156,7 @@ const PartnerLinks = ({ partner }: { partner: EnrolledPartnerProps }) => {
onClick={() => setShowAddPartnerLinkModal(true)}
/>
</div>
- <div className="mt-4">
- <Table {...table} />
- </div>
+ <Table {...table} />
<AddPartnerLinkModal />
</>
);
@@ -189,21 +190,7 @@ const PartnerDiscountCodes = ({
{
id: "code",
header: "Code",
- cell: ({ row }) => (
- <div className="group/discountcode relative flex h-5 w-fit items-center gap-1 rounded-lg bg-green-100 py-0 pl-1 pr-1.5 transition-colors duration-150 hover:bg-green-200">
- <Tag className="size-3 text-green-700" strokeWidth={1.5} />
- <div className="text-xs font-medium text-green-700 transition-colors">
- {row.original.code}
- </div>
- <span className="flex items-center">
- <CopyButton
- value={row.original.code}
- variant="neutral"
- className="p-0.5"
- />
- </span>
- </div>
- ),
+ cell: ({ row }) => <DiscountCodeBadge code={row.original.code} />,
},
{
id: "shortLink",
@@ -226,14 +213,14 @@ const PartnerDiscountCodes = ({
{
id: "menu",
enableHiding: false,
- minSize: 35,
- size: 35,
- maxSize: 35,
+ minSize: 18,
+ size: 18,
+ maxSize: 18,
cell: ({ row }) => (
<Button
icon={<Trash className="size-3.5 shrink-0 text-neutral-600" />}
variant="outline"
- className="h-8 whitespace-nowrap"
+ className="size-8 whitespace-nowrap"
onClick={() => {
setSelectedDiscountCode(row.original);
setShowDeleteDiscountCodeModal(true);
@@ -295,31 +282,29 @@ const PartnerDiscountCodes = ({
/>
</div>
- <div className="mt-4">
- {loading ? (
- <div className="flex justify-center py-16">
- <LoadingSpinner />
- </div>
- ) : !error && (!discountCodes || discountCodes.length === 0) ? (
- <div className="flex flex-col items-center justify-center gap-2 rounded-lg border border-neutral-200 bg-neutral-50 py-6">
- <Tag className="mb-2 size-6 text-neutral-900" />
- <h3 className="text-content-emphasis text-sm font-semibold leading-5">
- No codes created
- </h3>
- <p className="text-content-default -mt-1 text-sm font-medium leading-5">
- Create a discount code for each link
- </p>
- </div>
- ) : error ? (
- <div className="flex justify-center py-16">
- <span className="text-content-subtle text-sm">
- Failed to load discount codes
- </span>
- </div>
- ) : (
- <Table {...table} />
- )}
- </div>
+ {loading ? (
+ <div className="flex justify-center py-16">
+ <LoadingSpinner />
+ </div>
+ ) : !error && (!discountCodes || discountCodes.length === 0) ? (
+ <div className="flex flex-col items-center justify-center gap-2 rounded-lg border border-neutral-200 bg-neutral-50 py-6">
+ <Tag className="mb-2 size-6 text-neutral-900" />
+ <h3 className="text-content-emphasis text-sm font-semibold leading-5">
+ No codes created
+ </h3>
+ <p className="text-content-default -mt-1 text-sm font-medium leading-5">
+ Create a discount code for each link
+ </p>
+ </div>
+ ) : error ? (
+ <div className="flex justify-center py-16">
+ <span className="text-content-subtle text-sm">
+ Failed to load discount codes
+ </span>
+ </div>
+ ) : (
+ <Table {...table} />
+ )}
<AddDiscountCodeModal />
diff --git a/apps/web/ui/modals/add-discount-code-modal.tsx b/apps/web/ui/modals/add-discount-code-modal.tsx
index d213e1449e..887c2ae489 100644
--- a/apps/web/ui/modals/add-discount-code-modal.tsx
+++ b/apps/web/ui/modals/add-discount-code-modal.tsx
@@ -12,7 +12,7 @@ import {
useCopyToClipboard,
useMediaQuery,
} from "@dub/ui";
-import { cn } from "@dub/utils";
+import { cn, getPrettyUrl } from "@dub/utils";
import { Tag } from "lucide-react";
import { useCallback, useMemo, useRef, useState } from "react";
import { useForm } from "react-hook-form";
@@ -64,7 +64,7 @@ const AddDiscountCodeModal = ({
if (!debouncedSearch) {
return partnerLinks.map((link) => ({
value: link.id,
- label: link.shortLink,
+ label: getPrettyUrl(link.shortLink),
}));
}
@@ -74,7 +74,7 @@ const AddDiscountCodeModal = ({
)
.map((link) => ({
value: link.id,
- label: link.shortLink,
+ label: getPrettyUrl(link.shortLink),
}));
}, [partnerLinks, debouncedSearch]);
@@ -144,7 +144,7 @@ const AddDiscountCodeModal = ({
htmlFor="code"
className="block text-sm font-medium text-neutral-700"
>
- Discount code (optional)
+ Discount code
</label>
</div>
@@ -181,7 +181,7 @@ const AddDiscountCodeModal = ({
selectedLink
? {
value: selectedLink.id,
- label: selectedLink.shortLink,
+ label: getPrettyUrl(selectedLink.shortLink),
}
: null
}
diff --git a/apps/web/ui/partners/discounts/discount-code-badge.tsx b/apps/web/ui/partners/discounts/discount-code-badge.tsx
new file mode 100644
index 0000000000..0645dcd96d
--- /dev/null
+++ b/apps/web/ui/partners/discounts/discount-code-badge.tsx
@@ -0,0 +1,56 @@
+import {
+ DynamicTooltipWrapper,
+ SimpleTooltipContent,
+ Tag,
+ useCopyToClipboard,
+} from "@dub/ui";
+import { cn } from "@dub/utils";
+import { toast } from "sonner";
+
+export function DiscountCodeBadge({
+ code,
+ showTooltip,
+}: {
+ code: string;
+ showTooltip?: boolean;
+}) {
+ const [copied, copyToClipboard] = useCopyToClipboard();
+ return (
+ <DynamicTooltipWrapper
+ tooltipProps={
+ showTooltip
+ ? {
+ content: (
+ <SimpleTooltipContent
+ title="This program supports discount code tracking. Copy the code to use it in podcasts, videos, etc."
+ cta="Learn more"
+ href="https://dub.co/help/article/dual-sided-incentives"
+ />
+ ),
+ }
+ : undefined
+ }
+ >
+ <button
+ type="button"
+ className={cn(
+ "group/discountcode relative flex w-fit cursor-copy items-center gap-1 rounded-lg bg-green-200 px-2 py-1",
+ "transition-colors duration-150 hover:bg-green-300/80",
+ copied && "cursor-default",
+ )}
+ onClick={() =>
+ copyToClipboard(code, {
+ onSuccess: () => {
+ toast.success("Copied discount code to clipboard");
+ },
+ })
+ }
+ >
+ <Tag className="size-3 text-green-700" strokeWidth={1.5} />
+ <div className="text-xs font-medium text-green-700 decoration-dotted underline-offset-2 transition-colors group-hover/discountcode:underline">
+ {code}
+ </div>
+ </button>
+ </DynamicTooltipWrapper>
+ );
+}