Skip to content

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

feat(onboarding): add dataroom flow and trial

Marc Seitzd0d525c68eb0
diff --git a/components/welcome/dataroom-trial.tsx b/components/welcome/dataroom-trial.tsx
new file mode 100644
index 00000000..c3cd8c55
--- /dev/null
+++ b/components/welcome/dataroom-trial.tsx
@@ -0,0 +1,248 @@
+import { useRouter } from "next/router";
+import { motion } from "framer-motion";
+import { File as DocumentIcon, ServerIcon } from "lucide-react";
+import { STAGGER_CHILD_VARIANTS } from "@/lib/constants";
+import { Button } from "@/components/ui/button";
+import { DataroomTrialModal } from "@/components/datarooms/dataroom-trial-modal";
+import { Label } from "@/components/ui/label";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@/components/ui/select";
+import { PhoneInput } from "@/components/ui/phone-input";
+import { useTeam } from "@/context/team-context";
+import { useAnalytics } from "@/lib/analytics";
+import { mutate } from "swr";
+import { toast } from "sonner";
+import { useState } from "react";
+import { log } from "@/lib/utils";
+import { E164Number } from "libphonenumber-js/types.cjs";
+import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
+import { Input } from "../ui/input";
+
+export default function DataroomTrial() {
+ const teamInfo = useTeam();
+ const analytics = useAnalytics();
+ const router = useRouter();
+
+ 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 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! 🎉");
+
+ await mutate(`/api/teams/${teamInfo?.currentTeam?.id}/datarooms`);
+ router.push("/datarooms");
+ } catch (error) {
+ setLoading(false);
+ toast.error("Error adding dataroom. Please try again.");
+ return;
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ return (
+ <motion.div
+ className="z-10 mx-5 flex flex-col items-center space-y-10 text-center sm:mx-auto"
+ variants={{
+ hidden: { opacity: 0, scale: 0.95 },
+ show: {
+ opacity: 1,
+ scale: 1,
+ transition: {
+ staggerChildren: 0.2,
+ },
+ },
+ }}
+ initial="hidden"
+ animate="show"
+ exit="hidden"
+ transition={{ duration: 0.3, type: "spring" }}
+ >
+ <motion.div
+ variants={STAGGER_CHILD_VARIANTS}
+ className="flex flex-col items-center space-y-10 text-center"
+ >
+ <p className="text-2xl font-bold tracking-tighter text-foreground">
+ Papermark
+ </p>
+ <h1 className="font-display max-w-lg text-3xl font-semibold transition-colors sm:text-4xl">
+ Try data rooms for 7 days!
+ </h1>
+ </motion.div>
+ <motion.div
+ variants={STAGGER_CHILD_VARIANTS}
+ className="mt-24 mx-auto max-w-md w-full text-left"
+ >
+ <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>
+
+ <div className="text-center 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">
+ {/* Data rooms are available on our{" "}
+ <UpgradePlanModal clickedPlan="Business">
+ <button className="underline">Business</button>
+ </UpgradePlanModal>{" "}
+ plan. <br /> */}
+ After the trial, upgrade to{" "}
+ <UpgradePlanModal clickedPlan="Business">
+ <button className="underline">Papermark Business</button>
+ </UpgradePlanModal>{" "}
+ to continue using data rooms.
+ </div>
+ </div>
+ </form>
+ </motion.div>
+ </motion.div>
+ );
+}
diff --git a/components/welcome/dataroom.tsx b/components/welcome/dataroom.tsx
new file mode 100644
index 00000000..38d71ddf
--- /dev/null
+++ b/components/welcome/dataroom.tsx
@@ -0,0 +1,84 @@
+import { useRouter } from "next/router";
+import { motion } from "framer-motion";
+import { File as DocumentIcon, ServerIcon } from "lucide-react";
+import { STAGGER_CHILD_VARIANTS } from "@/lib/constants";
+import { Button } from "../ui/button";
+import { DataroomTrialModal } from "../datarooms/dataroom-trial-modal";
+
+export default function Dataroom() {
+ const router = useRouter();
+ return (
+ <motion.div
+ className="z-10 mx-5 flex flex-col items-center space-y-10 text-center sm:mx-auto"
+ variants={{
+ hidden: { opacity: 0, scale: 0.95 },
+ show: {
+ opacity: 1,
+ scale: 1,
+ transition: {
+ staggerChildren: 0.2,
+ },
+ },
+ }}
+ initial="hidden"
+ animate="show"
+ exit="hidden"
+ transition={{ duration: 0.3, type: "spring" }}
+ >
+ <motion.div
+ variants={STAGGER_CHILD_VARIANTS}
+ className="flex flex-col items-center space-y-10 text-center"
+ >
+ <p className="text-2xl font-bold tracking-tighter text-foreground">
+ Papermark
+ </p>
+ <h1 className="font-display max-w-md text-3xl font-semibold transition-colors sm:text-4xl">
+ Data rooms are here!
+ </h1>
+ </motion.div>
+ <motion.div
+ variants={STAGGER_CHILD_VARIANTS}
+ className="mt-24 mx-auto w-full"
+ >
+ <video
+ width="100%"
+ id="video1"
+ style={{ borderRadius: "6px" }}
+ aria-hidden="true"
+ playsInline
+ autoPlay
+ muted
+ loop
+ controls
+ >
+ <source
+ src="https://assets.papermark.io/short-video.mp4"
+ type="video/mp4"
+ />
+ </video>
+ </motion.div>
+ <motion.div
+ variants={STAGGER_CHILD_VARIANTS}
+ className="flex flex-col items-center space-y-4 text-center mt-10"
+ >
+ <Button
+ className="px-10 font-medium text-base"
+ onClick={() =>
+ router.push({
+ pathname: "/welcome",
+ query: {
+ type: "dataroom-trial",
+ },
+ })
+ }
+ >
+ Get a data room trial
+ </Button>
+ <span className="text-xs text-muted-foreground">
+ Data rooms are available on our `Business` plan. <br />
+ You receive a 7-day trial.
+ </span>
+ </motion.div>
+ </motion.div>
+ );
+}
diff --git a/components/welcome/next.tsx b/components/welcome/next.tsx
index 3a592fe8..962919ce 100644
--- a/components/welcome/next.tsx
+++ b/components/welcome/next.tsx
@@ -85,6 +85,22 @@ export default function Next() {
<p>Notion Page</p>
</button>
</motion.div>
+
+ <motion.div variants={STAGGER_CHILD_VARIANTS} className="text-center">
+ <button
+ className="text-center text-sm text-muted-foreground underline-offset-4 transition-all hover:text-gray-800 hover:dark:text-muted-foreground/80 hover:underline"
+ onClick={() =>
+ router.push({
+ pathname: "/welcome",
+ query: {
+ type: "dataroom",
+ },
+ })
+ }
+ >
+ Looking to create and share a full dataroom?
+ </button>
+ </motion.div>
</motion.div>
);
}
diff --git a/pages/api/teams/[teamId]/datarooms/trial.ts b/pages/api/teams/[teamId]/datarooms/trial.ts
new file mode 100644
index 00000000..d4b4fb83
--- /dev/null
+++ b/pages/api/teams/[teamId]/datarooms/trial.ts
@@ -0,0 +1,88 @@
+import { NextApiRequest, NextApiResponse } from "next";
+import { getServerSession } from "next-auth/next";
+import prisma from "@/lib/prisma";
+import { authOptions } from "@/pages/api/auth/[...nextauth]";
+import { CustomUser } from "@/lib/types";
+import { newId } from "@/lib/id-helper";
+
+export default async function handle(
+ req: NextApiRequest,
+ res: NextApiResponse,
+) {
+ if (req.method === "POST") {
+ // POST /api/teams/:teamId/datarooms/trial
+ const session = await getServerSession(req, res, authOptions);
+ if (!session) {
+ res.status(401).end("Unauthorized");
+ return;
+ }
+
+ const userId = (session.user as CustomUser).id;
+
+ const { teamId } = req.query as { teamId: string };
+ const { name } = req.body as { name: string };
+
+ try {
+ const team = await prisma.team.findUnique({
+ where: {
+ id: teamId,
+ users: {
+ some: {
+ userId: userId,
+ },
+ },
+ },
+ select: {
+ id: true,
+ plan: true,
+ _count: {
+ select: {
+ datarooms: true,
+ },
+ },
+ },
+ });
+
+ if (!team) {
+ return res.status(401).end("Unauthorized");
+ }
+
+ if (team.plan.includes("drtrial") || team._count.datarooms > 0) {
+ return res
+ .status(400)
+ .json({ message: "Trial data room already exists" });
+ }
+
+ await prisma.team.update({
+ where: { id: teamId },
+ data: {
+ plan: `${team.plan}+drtrial`,
+ },
+ });
+
+ const pId = newId("dataroom");
+
+ const dataroom = await prisma.dataroom.create({
+ data: {
+ name: name,
+ teamId: teamId,
+ pId: pId,
+ },
+ });
+
+ const dataroomWithCount = {
+ ...dataroom,
+ _count: { documents: 0 },
+ };
+
+ res.status(201).json(dataroomWithCount);
+ } catch (error) {
+ console.error("Request error", error);
+ res.status(500).json({ error: "Error creating dataroom" });
+ }
+ } else {
+ // We only allow POST requests
+ res.setHeader("Allow", ["POST"]);
+ return res.status(405).end(`Method ${req.method} Not Allowed`);
+ }
+}
diff --git a/pages/welcome.tsx b/pages/welcome.tsx
index 7783bb3b..72c522b0 100644
--- a/pages/welcome.tsx
+++ b/pages/welcome.tsx
@@ -6,6 +6,8 @@ import { ArrowLeft as ArrowLeftIcon } from "lucide-react";
import { AnimatePresence } from "framer-motion";
import NotionForm from "@/components/welcome/notion-form";
import { Button } from "@/components/ui/button";
+import Dataroom from "@/components/welcome/dataroom";
+import DataroomTrial from "@/components/welcome/dataroom-trial";
export default function Welcome() {
const router = useRouter();
@@ -49,6 +51,10 @@ export default function Welcome() {
{router.query.type === "pitchdeck" && <Upload key="pitchdeck" />}
{router.query.type === "document" && <Upload key="document" />}
{router.query.type === "notion" && <NotionForm key="notion" />}
+ {router.query.type === "dataroom" && <Dataroom key="dataroom" />}
+ {router.query.type === "dataroom-trial" && (
+ <DataroomTrial key="dataroom-trial" />
+ )}
</AnimatePresence>
</div>
);