Skip to content

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

feat(dr): add dataroom trial modal

Marc Seitzd5854d2794bd
diff --git a/components/billing/upgrade-plan-modal.tsx b/components/billing/upgrade-plan-modal.tsx
index 26a83430..5a5a423c 100644
--- a/components/billing/upgrade-plan-modal.tsx
+++ b/components/billing/upgrade-plan-modal.tsx
@@ -12,6 +12,7 @@ import { useAnalytics } from "@/lib/analytics";
import React from "react";
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { CheckIcon } from "lucide-react";
+import { DataroomTrialModal } from "../datarooms/dataroom-trial-modal";
export function UpgradePlanModal({
clickedPlan,
@@ -229,13 +230,21 @@ export function UpgradePlanModal({
}}
>{`Upgrade to ${plan} ${capitalize(period)}`}</Button>
<div className="flex items-center justify-center space-x-2">
- <a
- href="https://cal.com/marcseitz/papermark"
- target="_blank"
- className="text-center text-xs text-muted-foreground underline-offset-4 transition-all hover:text-gray-800 hover:dark:text-muted-foreground/80 hover:underline"
- >
- Looking for Papermark Enterprise?
- </a>
+ {plan === "Business" ? (
+ <DataroomTrialModal>
+ <button className="text-center text-xs text-muted-foreground underline-offset-4 transition-all hover:text-gray-800 hover:dark:text-muted-foreground/80 hover:underline">
+ Looking for a dataroom trial?
+ </button>
+ </DataroomTrialModal>
+ ) : (
+ <a
+ href="https://cal.com/marcseitz/papermark"
+ target="_blank"
+ className="text-center text-xs text-muted-foreground underline-offset-4 transition-all hover:text-gray-800 hover:dark:text-muted-foreground/80 hover:underline"
+ >
+ Looking for Papermark Enterprise?
+ </a>
+ )}
</div>
</motion.div>
</div>
diff --git a/components/datarooms/dataroom-trial-modal.tsx b/components/datarooms/dataroom-trial-modal.tsx
new file mode 100644
index 00000000..ac0826fd
--- /dev/null
+++ b/components/datarooms/dataroom-trial-modal.tsx
@@ -0,0 +1,229 @@
+import { Button } from "@/components/ui/button";
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ DialogTrigger,
+} from "@/components/ui/dialog";
+import { Input } from "@/components/ui/input";
+import { Label } from "@/components/ui/label";
+import { useTeam } from "@/context/team-context";
+import { useState } from "react";
+import { toast } from "sonner";
+import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
+import { usePlan } from "@/lib/swr/use-billing";
+import { useAnalytics } from "@/lib/analytics";
+import { mutate } from "swr";
+import { log } from "@/lib/utils";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "../ui/select";
+import { PhoneInput } from "../ui/phone-input";
+import { E164Number } from "libphonenumber-js/types.cjs";
+
+export function DataroomTrialModal({
+ children,
+}: {
+ children?: React.ReactNode;
+}) {
+ const [industry, setIndustry] = useState<string>("");
+ const [companySize, setCompanySize] = useState<string>("");
+ const [name, setName] = useState<string>("");
+ const [companyName, setCompanyName] = useState<string>("");
+ const [phoneNumber, setPhoneNumber] = useState<E164Number>("");
+ const [loading, setLoading] = useState<boolean>(false);
+ const [open, setOpen] = useState<boolean>(false);
+
+ const teamInfo = useTeam();
+ const analytics = useAnalytics();
+
+ const handleSubmit = async (event: any) => {
+ event.preventDefault();
+ event.stopPropagation();
+
+ if (!name || !companyName || !industry || !companySize || !phoneNumber) {
+ toast.error("Please fill out all fields.");
+ return;
+ }
+
+ setLoading(true);
+
+ try {
+ await log({
+ message: `Dataroom Trial: ${teamInfo?.currentTeam?.id} \n\nName: ${name} \nCompany Name: ${companyName} \nIndustry: ${industry} \nCompany Size: ${companySize} \nPhone Number: ${phoneNumber}`,
+ type: "info",
+ mention: true,
+ });
+ const response = await fetch(
+ `/api/teams/${teamInfo?.currentTeam?.id}/datarooms/trial`,
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ name: "Dataroom Demo Trial",
+ }),
+ },
+ );
+
+ if (!response.ok) {
+ const { message } = await response.json();
+ setLoading(false);
+ toast.error(message);
+ return;
+ }
+
+ analytics.capture("Dataroom Trial Created", {
+ dataroomName: "Dataroom Demo Trial",
+ industry,
+ companySize,
+ });
+ toast.success("Dataroom successfully created! 🎉");
+
+ mutate(`/api/teams/${teamInfo?.currentTeam?.id}/datarooms`);
+ } catch (error) {
+ setLoading(false);
+ toast.error("Error adding dataroom. Please try again.");
+ return;
+ } finally {
+ setLoading(false);
+ setOpen(false);
+ }
+ };
+
+ return (
+ <Dialog open={open} onOpenChange={setOpen}>
+ <DialogTrigger asChild>{children}</DialogTrigger>
+ <DialogContent className="sm:max-w-[425px]">
+ <DialogHeader className="text-start">
+ <DialogTitle>Dataroom Trial for 7 days</DialogTitle>
+ <DialogDescription>No credit card required.</DialogDescription>
+ </DialogHeader>
+ <form onSubmit={handleSubmit} className="space-y-4">
+ <div className="space-y-1">
+ <Label htmlFor="name" className="opacity-80">
+ Your Full Name
+ </Label>
+ <Input
+ id="name"
+ type="text"
+ autoComplete="off"
+ data-1p-ignore
+ placeholder="John Doe"
+ className="w-full mt-1 mb-4"
+ onChange={(e) => setName(e.target.value)}
+ />
+ </div>
+ <div className="space-y-1">
+ <Label htmlFor="company-name" className="opacity-80">
+ Company Name
+ </Label>
+ <Input
+ id="company-name"
+ type="text"
+ autoComplete="off"
+ data-1p-ignore
+ placeholder="ACME Inc."
+ className="w-full mt-1 mb-4"
+ onChange={(e) => setCompanyName(e.target.value)}
+ />
+ </div>
+ <div className="space-y-1">
+ <Label className="opacity-80">Industry</Label>
+ <Select onValueChange={(value) => setIndustry(value)}>
+ <SelectTrigger>
+ <SelectValue placeholder="Select an industry" />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="finance-banking">
+ Finance and Banking
+ </SelectItem>
+ <SelectItem value="legal">Legal</SelectItem>
+ <SelectItem value="real-estate">Real Estate</SelectItem>
+ <SelectItem value="technology">Technology</SelectItem>
+ <SelectItem value="pharmaceuticals">Pharmaceuticals</SelectItem>
+ <SelectItem value="energy">Energy</SelectItem>
+ <SelectItem value="manufacturing">Manufacturing</SelectItem>
+ <SelectItem value="healthcare">Healthcare</SelectItem>
+ <SelectItem value="consulting">
+ Consulting and Professional Services
+ </SelectItem>
+ <SelectItem value="government">
+ Government and Public Sector
+ </SelectItem>
+ <SelectItem value="entertainment">
+ Entertainment and Media
+ </SelectItem>
+ <SelectItem value="other">Other</SelectItem>
+ </SelectContent>
+ </Select>
+ </div>
+ <div className="space-y-1">
+ <Label className="opacity-80">Company Size</Label>
+ <Select onValueChange={(value) => setCompanySize(value)}>
+ <SelectTrigger>
+ <SelectValue placeholder="Select a company size" />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="1">1 employee</SelectItem>
+ <SelectItem value="2-10">2-10 employees</SelectItem>
+ <SelectItem value="11-50">11-50 employees</SelectItem>
+ <SelectItem value="51-200">51-200 employees</SelectItem>
+ <SelectItem value="201-500">201-500 employees</SelectItem>
+ <SelectItem value="501-1000">501-1,000 employees</SelectItem>
+ <SelectItem value="1001-5000">1,001-5,000 employees</SelectItem>
+ <SelectItem value="5001-10000">
+ 5,001-10,000 employees
+ </SelectItem>
+ <SelectItem value="10001+">10,001+ employees</SelectItem>
+ </SelectContent>
+ </Select>
+ </div>
+ <div className="space-y-1">
+ <Label className="opacity-80">Phone Number</Label>
+ <PhoneInput
+ placeholder="+1 123 456 7890"
+ onChange={(value) => setPhoneNumber(value)}
+ defaultCountry="US"
+ />
+ </div>
+
+ <DialogFooter>
+ <div className="flex flex-col space-y-4">
+ <Button
+ type="submit"
+ className="w-full h-9"
+ disabled={
+ !phoneNumber ||
+ !companySize ||
+ !industry ||
+ !name ||
+ !companyName
+ }
+ loading={loading}
+ >
+ Access your data room
+ </Button>
+
+ <div className="text-xs text-muted-foreground">
+ After the trial, upgrade to{" "}
+ <UpgradePlanModal clickedPlan="Business">
+ <button className="underline">Papermark Business</button>
+ </UpgradePlanModal>{" "}
+ to continue using data rooms.
+ </div>
+ </div>
+ </DialogFooter>
+ </form>
+ </DialogContent>
+ </Dialog>
+ );
+}
diff --git a/pages/datarooms/index.tsx b/pages/datarooms/index.tsx
index ad1ac76f..e70553f1 100644
--- a/pages/datarooms/index.tsx
+++ b/pages/datarooms/index.tsx
@@ -1,4 +1,6 @@
+import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
import { AddDataroomModal } from "@/components/datarooms/add-dataroom-modal";
+import { DataroomTrialModal } from "@/components/datarooms/dataroom-trial-modal";
import { EmptyDataroom } from "@/components/datarooms/empty-dataroom";
import AppLayout from "@/components/layouts/app";
import { Button } from "@/components/ui/button";
@@ -10,12 +12,15 @@ import {
CardTitle,
} from "@/components/ui/card";
import { Separator } from "@/components/ui/separator";
+import { usePlan } from "@/lib/swr/use-billing";
import useDatarooms from "@/lib/swr/use-datarooms";
+import { daysLeft } from "@/lib/utils";
import { PlusIcon } from "lucide-react";
import Link from "next/link";
export default function DataroomsPage() {
const { datarooms } = useDatarooms();
+ const { plan, trial } = usePlan();
return (
<AppLayout>
@@ -30,17 +35,47 @@ export default function DataroomsPage() {
</p>
</div>
<div className="flex items-center gap-x-1">
- <AddDataroomModal>
- <Button
- className="flex-1 text-left group flex gap-x-3 items-center justify-start px-3"
- title="Add New Document"
- >
- <PlusIcon className="h-5 w-5 shrink-0" aria-hidden="true" />
- <span>Create New Dataroom</span>
- </Button>
- </AddDataroomModal>
+ {plan !== "business" && trial !== "drtrial" ? (
+ <DataroomTrialModal>
+ <Button
+ className="flex-1 text-left group flex gap-x-3 items-center justify-start px-3"
+ title="Add New Document"
+ >
+ <span>Start Data Room Trial</span>
+ </Button>
+ </DataroomTrialModal>
+ ) : datarooms && trial === "drtrial" && plan !== "business" ? (
+ <div className="flex items-center gap-x-4">
+ <div className="text-sm text-destructive ">
+ <span className="">Dataroom Trial:</span>{" "}
+ <span className="font-medium">
+ {daysLeft(new Date(datarooms[0].createdAt), 7)} days left
+ </span>
+ </div>
+ <UpgradePlanModal
+ clickedPlan={"Business"}
+ trigger={"datarooms"}
+ >
+ <Button
+ className="flex-1 text-left group flex gap-x-3 items-center justify-start px-3"
+ title="Add New Document"
+ >
+ <span>Upgrade to Create Dataroom</span>
+ </Button>
+ </UpgradePlanModal>
+ </div>
+ ) : (
+ <AddDataroomModal>
+ <Button
+ className="flex-1 text-left group flex gap-x-3 items-center justify-start px-3"
+ title="Add New Document"
+ >
+ <PlusIcon className="h-5 w-5 shrink-0" aria-hidden="true" />
+ <span>Create New Dataroom</span>
+ </Button>
+ </AddDataroomModal>
+ )}
</div>
- {/* </div> */}
</section>
<Separator className="mb-5 bg-gray-200 dark:bg-gray-800" />