Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

feat: enable visitors tab

Marc Seitz8d09e24b49da
diff --git a/components/Sidebar.tsx b/components/Sidebar.tsx
index bd475201..12865243 100644
--- a/components/Sidebar.tsx
+++ b/components/Sidebar.tsx
@@ -13,7 +13,6 @@ import {
PaletteIcon,
ServerIcon,
} from "lucide-react";
-import { useSession } from "next-auth/react";
import MenuIcon from "@/components/shared/icons/menu";
import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet";
@@ -22,7 +21,6 @@ import { usePlan } from "@/lib/swr/use-billing";
import useLimits from "@/lib/swr/use-limits";
import { cn, nFormatter } from "@/lib/utils";
-import Banner from "./banner";
import ProBanner from "./billing/pro-banner";
import { UpgradePlanModal } from "./billing/upgrade-plan-modal";
import ProfileMenu from "./profile-menu";
@@ -67,8 +65,7 @@ export default function Sidebar() {
export const SidebarComponent = ({ className }: { className?: string }) => {
const [showProBanner, setShowProBanner] = useState<boolean | null>(null);
- const { data: session, status } = useSession();
- const { plan: userPlan, trial: userTrial, loading } = usePlan();
+ const { plan: userPlan, trial: userTrial } = usePlan();
const isTrial = !!userTrial;
const { limits } = useLimits();
const linksLimit = limits?.links;
@@ -118,20 +115,18 @@ export const SidebarComponent = ({ className }: { className?: string }) => {
current: router.pathname.includes("datarooms"),
active: false,
disabled:
- userPlan === "business" ||
- userPlan === "datarooms" ||
- userTrial === "drtrial"
+ userPlan === "business" || userPlan === "datarooms" || isTrial
? false
: true,
},
- // {
- // name: "Visitors",
- // href: "/visitors",
- // icon: ContactIcon,
- // current: router.pathname.includes("visitors"),
- // active: false,
- // disabled: userPlan === "free" ? true : false,
- // },
+ {
+ name: "Visitors",
+ href: "/visitors",
+ icon: ContactIcon,
+ current: router.pathname.includes("visitors"),
+ active: false,
+ disabled: userPlan === "free" && !isTrial ? true : false,
+ },
{
name: "Branding",
href: "/settings/branding",
@@ -238,14 +233,35 @@ export const SidebarComponent = ({ className }: { className?: string }) => {
if (
userPlan !== "business" &&
userPlan !== "datarooms" &&
- userTrial !== "drtrial" &&
+ !isTrial &&
item.name === "Datarooms"
) {
return (
<UpgradePlanModal
key={item.name}
clickedPlan={"Business"}
- trigger={"datarooms"}
+ trigger={"sidebar_datarooms"}
+ >
+ <div className="group flex w-full items-center gap-x-2 rounded-md px-3 py-2 text-sm leading-6 text-muted-foreground hover:bg-transparent">
+ <item.icon
+ className="h-5 w-5 shrink-0"
+ aria-hidden="true"
+ />
+ {item.name}
+ </div>
+ </UpgradePlanModal>
+ );
+ }
+ if (
+ userPlan == "free" &&
+ !isTrial &&
+ item.name === "Visitors"
+ ) {
+ return (
+ <UpgradePlanModal
+ key={item.name}
+ clickedPlan={"Pro"}
+ trigger={"sidebar_visitors"}
>
<div className="group flex w-full items-center gap-x-2 rounded-md px-3 py-2 text-sm leading-6 text-muted-foreground hover:bg-transparent">
<item.icon
@@ -281,17 +297,9 @@ export const SidebarComponent = ({ className }: { className?: string }) => {
</section>
</ScrollArea>
<div className="mb-4">
- {/* if user is on trial show banner,
- * if user is pro show nothing,
+ {/*
* if user is free and showProBanner is true show pro banner
*/}
- {userPlan === "trial" && session ? (
- <Banner session={session} />
- ) : null}
- {(userPlan === "pro" ||
- userPlan === "business" ||
- userPlan === "datarooms") &&
- null}
{userPlan === "free" && showProBanner ? (
<ProBanner setShowProBanner={setShowProBanner} />
) : null}
diff --git a/components/banner.tsx b/components/banner.tsx
deleted file mode 100644
index d9f69e84..00000000
--- a/components/banner.tsx
+++ /dev/null
@@ -1,47 +0,0 @@
-import Link from "next/link";
-
-import { Session } from "next-auth";
-
-import { useDomains } from "@/lib/swr/use-domains";
-import { CustomUser } from "@/lib/types";
-import { calculateDaysLeft } from "@/lib/utils";
-
-import { Button } from "./ui/button";
-
-const cutoffDate = new Date("2023-10-12T00:00:00.000Z");
-
-export default function Banner({ session }: { session: Session | null }) {
- const { domains } = useDomains();
-
- const userDaysLeft = calculateDaysLeft(
- new Date((session?.user as CustomUser).createdAt || 0),
- );
-
- const noDomains = domains && domains.length === 0;
- const someNotVerified =
- domains && !noDomains && domains.some((domain) => !domain.verified);
- const allVerified =
- domains && !noDomains && domains.every((domain) => domain.verified);
-
- return (
- <aside className="mb-2 flex w-full flex-col justify-center rounded-lg border border-gray-700 bg-background p-4 text-foreground">
- <div className="flex space-x-2">
- <span className="text-sm font-bold">✨ Pro Trial ✨</span>
- </div>
- <p className="my-4 text-sm">
- {`You are on the Pro trial for the next ${userDaysLeft} days.`}
- </p>
- {allVerified ? (
- <p className="text-sm text-green-500">{`Your domain is verified.`}</p>
- ) : (
- <Button variant={someNotVerified ? `destructive` : `default`}>
- <Link href="/settings/domains" target="_blank">
- {someNotVerified
- ? `Please verify your domain`
- : `Connect custom domain`}
- </Link>
- </Button>
- )}
- </aside>
- );
-}