From 83705d54c8fd7caaa2b1bebf2758094926f31ffe Mon Sep 17 00:00:00 2001 From: Yash Sharma Date: Sun, 13 Oct 2024 00:07:15 +0530 Subject: [PATCH] feat: preview link as --- components/links/links-table.tsx | 50 +++++++++++++++++++++++++------- pages/view/[linkId]/index.tsx | 15 ++++++++-- 2 files changed, 52 insertions(+), 13 deletions(-) diff --git a/components/links/links-table.tsx b/components/links/links-table.tsx index 052230a20..d2f5f5a18 100644 --- a/components/links/links-table.tsx +++ b/components/links/links-table.tsx @@ -47,6 +47,8 @@ import LinkSheet, { } from "./link-sheet"; import LinksVisitors from "./links-visitors"; +export type PreviewType = "QUICK_PREVIEW" | "COMPLETE_PREVIEW"; + export default function LinksTable({ targetType, links, @@ -114,7 +116,10 @@ export default function LinksTable({ }, 0); }; - const handlePreviewLink = async (link: LinkWithViews) => { + const handlePreviewLink = async ( + link: LinkWithViews, + viewAs: PreviewType, + ) => { if (link.domainId && plan === "free") { toast.error("You need to upgrade to preview this link"); return; @@ -133,7 +138,7 @@ export default function LinksTable({ } const { previewToken } = await response.json(); - const previewLink = `${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${link.id}?previewToken=${previewToken}`; + const previewLink = `${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${link.id}?previewToken=${previewToken}&viewAs=${viewAs}`; window.open(previewLink, "_blank"); }; @@ -313,15 +318,38 @@ export default function LinksTable({ )} - + + + + + + View As + + + handlePreviewLink(link, "QUICK_PREVIEW") + } + > + Quick Preview + + + handlePreviewLink( + link, + "COMPLETE_PREVIEW", + ) + } + > + Complete Preview + + +