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 copy tag + fix keychecks

Steven Tey57cbb89dbdd9
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/tags/tag-card.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/tags/tag-card.tsx
index 06fc745a6a..aabe1e7939 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/tags/tag-card.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/tags/tag-card.tsx
@@ -6,7 +6,12 @@ import TagBadge from "@/ui/links/tag-badge";
import { useAddEditTagModal } from "@/ui/modals/add-edit-tag-modal";
import { Delete, ThreeDots } from "@/ui/shared/icons";
import { Button, CardList, Popover } from "@dub/ui";
-import { LoadingSpinner, PenWriting } from "@dub/ui/src/icons";
+import {
+ CircleCheck,
+ Copy,
+ LoadingSpinner,
+ PenWriting,
+} from "@dub/ui/src/icons";
import { cn, nFormatter } from "@dub/utils";
import Link from "next/link";
import { useState } from "react";
@@ -31,6 +36,15 @@ export function TagCard({
props: tag,
});
+ const [copiedTagId, setCopiedTagId] = useState(false);
+
+ const copyTagId = () => {
+ navigator.clipboard.writeText(tag.id);
+ setCopiedTagId(true);
+ toast.success("Tag ID copied!");
+ setTimeout(() => setCopiedTagId(false), 3000);
+ };
+
const handleDelete = async () => {
setProcessing(true);
fetch(`/api/tags/${tag.id}?workspaceId=${id}`, {
@@ -97,6 +111,20 @@ export function TagCard({
shortcut="E"
className="h-9 px-2 font-medium"
/>
+ <Button
+ text="Copy Tag ID"
+ variant="outline"
+ onClick={() => copyTagId()}
+ icon={
+ copiedTagId ? (
+ <CircleCheck className="h-4 w-4" />
+ ) : (
+ <Copy className="h-4 w-4" />
+ )
+ }
+ shortcut="I"
+ className="h-9 px-2 font-medium"
+ />
<Button
text="Delete"
variant="danger-outline"
diff --git a/apps/web/lib/api/links/utils.ts b/apps/web/lib/api/links/utils.ts
index 26a1f62630..26d5135cd4 100644
--- a/apps/web/lib/api/links/utils.ts
+++ b/apps/web/lib/api/links/utils.ts
@@ -45,20 +45,13 @@ export async function keyChecks({
key: string;
workspace?: Pick<WorkspaceProps, "plan">;
}): Promise<{ error: string | null; code?: DubApiError["code"] }> {
- if (key.length === 0 || key === "_root") {
- if (workspace?.plan === "free") {
- return {
- error:
- "You can only set a redirect for your root domain on a Pro plan and above. Upgrade to Pro to unlock this feature.",
- code: "forbidden",
- };
- } else {
- return {
- error:
- "To set a redirect for your root domain, navigate to your Domains tab and click 'Edit' on the domain you want to update.",
- code: "unprocessable_entity",
- };
- }
+ console.log({ domain, key });
+ if ((key.length === 0 || key === "_root") && workspace?.plan === "free") {
+ return {
+ error:
+ "You can only set a redirect for your root domain on a Pro plan and above. Upgrade to Pro to unlock this feature.",
+ code: "forbidden",
+ };
}
const link = await checkIfKeyExists(domain, key);