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.

small edits

Steven Teyfcaeb73e4b86
diff --git a/components/app/links/link-card.tsx b/components/app/links/link-card.tsx
index ae84e76dae..ccc2b0f5c3 100644
--- a/components/app/links/link-card.tsx
+++ b/components/app/links/link-card.tsx
@@ -217,14 +217,17 @@ export default function LinkCard({ props }: { props: LinkProps }) {
domain
? `/api/projects/${slug}/domains/${domain}/links/${props.key}/archive`
: `/api/links/${props.key}/archive`,
- { method: 'DELETE' }
+ { method: "DELETE" },
).then(async (res) => {
setUnarchiving(false);
setOpenPopover(false);
if (res.status === 200) {
- mutate(domain
- ? `/api/projects/${slug}/domains/${domain}/links${getQueryString(router)}`
- : `/api/links${getQueryString(router)}`
+ mutate(
+ domain
+ ? `/api/projects/${slug}/domains/${domain}/links${getQueryString(
+ router,
+ )}`
+ : `/api/links${getQueryString(router)}`,
);
setShowArchiveLinkModal(false);
}
@@ -233,7 +236,13 @@ export default function LinkCard({ props }: { props: LinkProps }) {
className="w-full rounded-md p-2 text-left text-sm font-medium text-gray-500 transition-all duration-75 hover:bg-gray-100"
>
<IconMenu
- text={!archived ? 'Archive' : unarchiving ? 'Unarchiving...' : 'Remove from archive'}
+ text={
+ !archived
+ ? "Archive"
+ : unarchiving
+ ? "Unarchiving..."
+ : "Unarchive"
+ }
icon={<Archive className="h-4 w-4" />}
/>
</button>
diff --git a/components/app/modals/archive-link-modal.tsx b/components/app/modals/archive-link-modal.tsx
index 049c2e200f..af944bafad 100644
--- a/components/app/modals/archive-link-modal.tsx
+++ b/components/app/modals/archive-link-modal.tsx
@@ -68,7 +68,7 @@ function ArchiveLinkModal({
? `/api/projects/${slug}/domains/${domain}/links/${props.key}/archive`
: `/api/links/${props.key}/archive`,
{
- method: "PUT",
+ method: "POST",
headers: {
"Content-Type": "application/json",
},
diff --git a/pages/api/links/[key]/archive.ts b/pages/api/links/[key]/archive.ts
index c8d6bbdc12..b7728f454b 100644
--- a/pages/api/links/[key]/archive.ts
+++ b/pages/api/links/[key]/archive.ts
@@ -24,14 +24,14 @@ export default withUserAuth(
return res.status(403).json({ error: "Not authorized" });
}
- if (req.method === "PUT") {
+ if (req.method === "POST") {
const response = await archiveLink(domain, key);
return res.status(200).json(response);
} else if (req.method === "DELETE") {
const response = await archiveLink(domain, key, false);
return res.status(200).json(response);
} else {
- res.setHeader("Allow", ["PUT"]);
+ res.setHeader("Allow", ["POST", "DELETE"]);
return res
.status(405)
.json({ error: `Method ${req.method} Not Allowed` });
diff --git a/pages/api/projects/[slug]/domains/[domain]/links/[key]/archive.ts b/pages/api/projects/[slug]/domains/[domain]/links/[key]/archive.ts
index 824efdab78..c5ab502e40 100644
--- a/pages/api/projects/[slug]/domains/[domain]/links/[key]/archive.ts
+++ b/pages/api/projects/[slug]/domains/[domain]/links/[key]/archive.ts
@@ -9,14 +9,14 @@ export default withProjectAuth(
key: string;
};
- if (req.method === "PUT") {
+ if (req.method === "POST") {
const response = await archiveLink(domain, key);
return res.status(200).json(response);
} else if (req.method === "DELETE") {
const response = await archiveLink(domain, key, false);
return res.status(200).json(response);
} else {
- res.setHeader("Allow", ["PUT"]);
+ res.setHeader("Allow", ["POST", "DELETE"]);
return res
.status(405)
.json({ error: `Method ${req.method} Not Allowed` });