The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fixed some type errors
Steven Tey4a097efa25af
diff --git a/components/app/custom-domain/domain-configuration.tsx b/components/app/custom-domain/domain-configuration.tsxindex b9e74beb92..05fe409e62 100644--- a/components/app/custom-domain/domain-configuration.tsx+++ b/components/app/custom-domain/domain-configuration.tsx@@ -15,10 +15,9 @@ export default function DomainConfiguration({data: { status: DomainVerificationStatusProps; response: any };}) {const [recordType, setRecordType] = useState("A");+ const { domainJson } = data.response;if (data.status === "Pending Verification") {- const { domainJson, verificationResponse } = data.response;-const txtVerification = domainJson.verification.find((x: any) => x.type === "TXT");@@ -82,7 +81,7 @@ export default function DomainConfiguration({<p className="my-5 text-sm">To configure your {recordType === "A" ? "apex domain" : "subdomain"} (<InlineSnippet>- {recordType === "A" ? "domain.com" : "links.domain.com"}+ {recordType === "A" ? domainJson.apexName : domainJson.name}</InlineSnippet>), set the following {recordType} record on your DNS provider tocontinue:diff --git a/components/app/links-container.tsx b/components/app/links-container.tsxindex 317a35582e..675e55c863 100644--- a/components/app/links-container.tsx+++ b/components/app/links-container.tsx@@ -8,22 +8,20 @@ import NoLinksPlaceholder from "@/components/app/no-links-placeholder";import { ProjectProps, LinkProps } from "@/lib/types";export default function LinksContainer({- project,exceededUsage,AddLinkButton,+ domain,}: {- project: ProjectProps;exceededUsage: boolean;AddLinkButton: () => JSX.Element;+ domain?: string;}) {const router = useRouter();const { slug } = router.query as {slug: string;};const { data: links } = useSWR<LinkProps[]>(- router.isReady &&- project &&- `/api/projects/${slug}/domains/${project.domain}/links`,+ domain ? `/api/projects/${slug}/domains/${domain}/links` : `/api/links`,fetcher);@@ -36,7 +34,7 @@ export default function LinksContainer({<LinkCardkey={props.key}props={props}- domain={project?.domain}+ domain={domain}exceededUsage={exceededUsage}/>))diff --git a/components/app/plan-usage.tsx b/components/app/plan-usage.tsxindex a4cf14e75f..515b0697f6 100644--- a/components/app/plan-usage.tsx+++ b/components/app/plan-usage.tsx@@ -43,9 +43,9 @@ export default function PlanUsage({ project }: { project: ProjectProps }) {</div></Tooltip></div>- {usage && project ? (+ {typeof usage === "number" ? (<p className="text-sm text-gray-600">- {usage} / {project.usageLimit} clicks (+ {nFormatter(usage)} / {nFormatter(project.usageLimit)} clicks ({(usage / project.usageLimit) * 100}%)</p>) : (@@ -70,7 +70,7 @@ export default function PlanUsage({ project }: { project: ProjectProps }) {<div className="p-10"><h3 className="font-medium">Number of Links</h3><div className="flex items-center mt-4">- {linkCount ? (+ {typeof linkCount === "number" ? (<p className="text-2xl font-semibold text-black">{nFormatter(linkCount)}</p>diff --git a/components/app/project-card.tsx b/components/app/project-card.tsxindex d1f73c875a..a12e2ae20d 100644--- a/components/app/project-card.tsx+++ b/components/app/project-card.tsx@@ -7,7 +7,8 @@ import {XCircleFill,Link as LinkIcon,} from "@/components/shared/icons";-import BlurImage from "../shared/blur-image";+import BlurImage from "@/components/shared/blur-image";+import Tooltip from "@/components/shared/tooltip";export default function ProjectCard({name,@@ -17,7 +18,10 @@ export default function ProjectCard({}: ProjectProps) {const { data: count, isValidating } = useSWR<number>(domainVerified && `/api/projects/${slug}/domains/${domain}/links/count`,- fetcher+ fetcher,+ {+ keepPreviousData: true,+ });return (<Link key={slug} href={`/${slug}`}>@@ -33,12 +37,20 @@ export default function ProjectCard({/><div><h2 className="text-lg font-medium text-gray-700">{name}</h2>- <div className="flex space-x-1 items-center">+ <div className="flex items-center"><p className="text-gray-500 dark:text-gray-400">{domain}</p>{domainVerified ? (- <CheckCircleFill className="w-5 h-5 text-blue-500" />+ <Tooltip content="Verified domain">+ <div className="w-8 flex justify-center">+ <CheckCircleFill className="w-5 h-5 text-blue-500" />+ </div>+ </Tooltip>) : (- <XCircleFill className="w-5 h-5 text-gray-300" />+ <Tooltip content="Unverified domain">+ <div className="w-8 flex justify-center">+ <XCircleFill className="w-5 h-5 text-gray-300" />+ </div>+ </Tooltip>)}</div></div>diff --git a/lib/upstash.ts b/lib/upstash.tsindex ee371d0669..cc8a6c9d16 100644--- a/lib/upstash.ts+++ b/lib/upstash.ts@@ -4,7 +4,6 @@ import { LOCALHOST_GEO_DATA } from "@/lib/constants";import { LinkProps } from "@/lib/types";import { customAlphabet } from "nanoid";import { getTitleFromUrl } from "@/lib/utils";-import { stripe } from "@/lib/stripe";// Initiate Redis instanceexport const redis = new Redis({diff --git a/pages/api/projects/index.ts b/pages/api/projects/index.tsindex d871981b74..db471e1d1f 100644--- a/pages/api/projects/index.ts+++ b/pages/api/projects/index.ts@@ -62,7 +62,6 @@ export default async function handler(email: session.user.email,}),]);- console.log(stripeResponse);await prisma.project.update({where: {id: project.id,diff --git a/pages/app/[slug]/index.tsx b/pages/app/[slug]/index.tsxindex 54f2399bca..e5175c4ba4 100644--- a/pages/app/[slug]/index.tsx+++ b/pages/app/[slug]/index.tsx@@ -41,8 +41,8 @@ export default function ProjectLinks() {const { AddLinkModal, AddLinkButton } = useAddLinkModal({domainVerified: project?.domainVerified,- domain: project?.domain,exceededUsage,+ domain: project?.domain,});return (@@ -57,9 +57,9 @@ export default function ProjectLinks() {</MaxWidthWrapper></div><LinksContainer- project={project}exceededUsage={exceededUsage}AddLinkButton={AddLinkButton}+ domain={project?.domain}/></AppLayout>);diff --git a/pages/app/[slug]/settings.tsx b/pages/app/[slug]/settings.tsxindex fd79779364..ff8261cec0 100644--- a/pages/app/[slug]/settings.tsx+++ b/pages/app/[slug]/settings.tsx@@ -35,7 +35,7 @@ export default function ProjectLinks() {</MaxWidthWrapper></div><MaxWidthWrapper>- <div className="my-10 grid gap-5">+ <div className="py-10 grid gap-5"><CustomDomain domain={project?.domain || ""} /><PlanUsage project={project} /></div>diff --git a/pages/app/links/index.tsx b/pages/app/links/index.tsxindex b9c5e96019..7e1079d6ec 100644--- a/pages/app/links/index.tsx+++ b/pages/app/links/index.tsx@@ -1,20 +1,13 @@import AppLayout from "components/layout/app";import MaxWidthWrapper from "@/components/shared/max-width-wrapper";-import { useRouter } from "next/router";-import useSWR from "swr";-import { fetcher } from "@/lib/utils";-import LinkCard from "@/components/app/link-card";-import LinkCardPlaceholder from "@/components/app/link-card-placeholder";-import { LinkProps } from "@/lib/types";import { useAddLinkModal } from "@/components/app/add-link-modal";-import NoLinksPlaceholder from "@/components/app/no-links-placeholder";+import LinksContainer from "@/components/app/links-container";export default function Links() {- const router = useRouter();-- const { data } = useSWR<LinkProps[]>(router.isReady && `/api/links`, fetcher);-- const { setShowAddLinkModal, AddLinkModal } = useAddLinkModal({});+ const { AddLinkModal, AddLinkButton } = useAddLinkModal({+ domainVerified: true,+ exceededUsage: false,+ });return (<AppLayout>@@ -23,30 +16,11 @@ export default function Links() {<MaxWidthWrapper><div className="flex justify-between items-center"><h1 className="text-2xl text-gray-600">My Dub.sh Links</h1>- <button- onClick={() => setShowAddLinkModal(true)}- className="font-medium text-sm text-gray-500 px-5 py-2 border rounded-md border-gray-200 dark:border-gray-600 hover:border-black dark:hover:border-white active:scale-95 transition-all duration-75"- >- Add- </button>+ <AddLinkButton /></div></MaxWidthWrapper></div>- <MaxWidthWrapper>- <div className="my-10 grid grid-cols-1 gap-3">- {data ? (- data.length > 0 ? (- data.map((props) => <LinkCard key={props.key} props={props} />)- ) : (- <NoLinksPlaceholder setShowAddLinkModal={setShowAddLinkModal} />- )- ) : (- Array.from({ length: 3 }).map((_, i) => (- <LinkCardPlaceholder key={i} />- ))- )}- </div>- </MaxWidthWrapper>+ <LinksContainer exceededUsage={false} AddLinkButton={AddLinkButton} /></AppLayout>);}