Skip to content

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

fix: small changes

Marc Seitzdc42fbf90ae0
diff --git a/components/welcome/dataroom-trial.tsx b/components/welcome/dataroom-trial.tsx
index 9747e5b8..7e4057dc 100644
--- a/components/welcome/dataroom-trial.tsx
+++ b/components/welcome/dataroom-trial.tsx
@@ -74,7 +74,7 @@ export default function DataroomTrial() {
return;
}
- const { dataroomId } = await response.json(); // Assuming the API returns the created dataroom's ID
+ const { id: dataroomId } = await response.json(); // Assuming the API returns the created dataroom's ID
if (!dataroomId) {
throw new Error("No dataroom ID returned from the server");
@@ -93,7 +93,6 @@ export default function DataroomTrial() {
// Instead of redirecting to "/datarooms", we'll navigate to the dataroom-upload page
router.push(`/welcome?type=dataroom-upload&dataroomId=${dataroomId}`);
} catch (error) {
- setLoading(false);
toast.error("Error adding dataroom. Please try again.");
console.error("Error creating dataroom:", error);
} finally {
@@ -245,7 +244,7 @@ export default function DataroomTrial() {
<button className="underline">Business</button>
</UpgradePlanModal>{" "}
plan. <br /> */}
- Credit card is not required. After the trial, upgrade to{" "}
+ No credit card is required. After the trial, upgrade to{" "}
<UpgradePlanModal clickedPlan="Business">
<button className="underline">
Papermark Business or Data Rooms
diff --git a/components/welcome/dataroom-upload.tsx b/components/welcome/dataroom-upload.tsx
index 50d8dca2..171201ce 100644
--- a/components/welcome/dataroom-upload.tsx
+++ b/components/welcome/dataroom-upload.tsx
@@ -50,53 +50,8 @@ export default function DataroomUpload({ dataroomId }: DataroomUploadProps) {
DEFAULT_LINK_PROPS(LinkType.DATAROOM_LINK),
);
const teamInfo = useTeam();
-
const teamId = teamInfo?.currentTeam?.id as string;
- useEffect(() => {
- if (dataroomId && !currentLinkId) {
- fetchOrCreateDataroomLink();
- }
- }, [dataroomId, currentLinkId]);
-
- const fetchOrCreateDataroomLink = async () => {
- try {
- const linkResponse = await fetch(
- `/api/teams/${teamId}/datarooms/${dataroomId}/links`,
- );
- if (linkResponse.ok) {
- const links = await linkResponse.json();
- if (links.length > 0) {
- setCurrentLinkId(links[0].id);
- } else {
- const createLinkResponse = await fetch(
- `/api/teams/${teamId}/datarooms/${dataroomId}/links`,
- {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({ linkType: "DATAROOM_LINK" }),
- },
- );
- if (createLinkResponse.ok) {
- const newLink = await createLinkResponse.json();
- setCurrentLinkId(newLink.id);
- } else {
- const errorData = await createLinkResponse.json();
- toast.error(errorData.message || "Failed to create link.");
- }
- }
- } else {
- const errorData = await linkResponse.json();
- toast.error(errorData.message || "Failed to fetch links.");
- }
- } catch (error) {
- console.error("Error fetching or creating dataroom link:", error);
- toast.error("Failed to generate dataroom link. Please try again.");
- }
- };
-
const handleFileUpload = async (event: any) => {
event.preventDefault();
@@ -158,6 +113,24 @@ export default function DataroomUpload({ dataroomId }: DataroomUploadProps) {
dataroomId: dataroomId,
});
+ // create link to dataroom
+ const newLinkResponse = await fetch(`/api/links`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ ...linkData,
+ targetId: dataroomId,
+ linkType: "DATAROOM_LINK",
+ }),
+ });
+
+ if (newLinkResponse.ok) {
+ const link = await newLinkResponse.json();
+ setCurrentLinkId(link.id);
+ }
+
setTimeout(() => {
setCurrentDocId(document.id);
setUploading(false);
diff --git a/components/welcome/select.tsx b/components/welcome/select.tsx
index 6681d076..4c5bf37a 100644
--- a/components/welcome/select.tsx
+++ b/components/welcome/select.tsx
@@ -3,6 +3,7 @@ import { useRouter } from "next/router";
import { motion } from "framer-motion";
import {
File as DocumentIcon,
+ FileChartPieIcon,
Presentation as PresentationChartBarIcon,
} from "lucide-react";
@@ -65,13 +66,13 @@ export default function Next() {
router.push({
pathname: "/welcome",
query: {
- type: "document",
+ type: "sales-document",
},
})
}
className="flex min-h-[200px] flex-col items-center justify-center space-y-5 overflow-hidden p-5 transition-colors hover:bg-gray-200 hover:dark:bg-gray-800 md:p-10"
>
- <DocumentIcon className="pointer-events-none h-auto w-12 sm:w-12" />
+ <FileChartPieIcon className="pointer-events-none h-auto w-12 sm:w-12" />
<p>Sales document</p>
</button>
@@ -105,8 +106,11 @@ export default function Next() {
</button>
</motion.div>
- <motion.div variants={STAGGER_CHILD_VARIANTS} className="text-center">
- <button
+ <motion.div
+ variants={STAGGER_CHILD_VARIANTS}
+ className="text-center text-sm text-muted-foreground"
+ >
+ {/* <button
className="text-center text-sm text-muted-foreground underline-offset-4 transition-all hover:text-gray-800 hover:underline hover:dark:text-muted-foreground/80"
onClick={() =>
router.push({
@@ -116,10 +120,9 @@ export default function Next() {
},
})
}
- >
- You can start by sharing documents an switch to data room creation
- later.
- </button>
+ > */}
+ You can start by sharing documents and create a data room later.
+ {/* </button> */}
</motion.div>
</motion.div>
);
diff --git a/components/welcome/upload.tsx b/components/welcome/upload.tsx
index 1650379e..b3edb95e 100644
--- a/components/welcome/upload.tsx
+++ b/components/welcome/upload.tsx
@@ -195,7 +195,7 @@ export default function Upload() {
className="flex flex-col items-center space-y-10 text-center"
>
<h1 className="font-display text-3xl font-semibold text-foreground transition-colors sm:text-4xl">
- {`Upload your ${router.query.type}`}
+ {`Upload your ${router.query.type === "sales-document" ? "document" : `${router.query.type}`}`}
</h1>
</motion.div>
<motion.div variants={STAGGER_CHILD_VARIANTS}>
diff --git a/pages/api/teams/[teamId]/datarooms/trial.ts b/pages/api/teams/[teamId]/datarooms/trial.ts
index 54147f1b..c0c4a674 100644
--- a/pages/api/teams/[teamId]/datarooms/trial.ts
+++ b/pages/api/teams/[teamId]/datarooms/trial.ts
@@ -97,10 +97,7 @@ export default async function handle(
waitUntil(sendDataroomTrialWelcome({ fullName, to: email! }));
- res.status(201).json({
- ...dataroomWithCount,
- dataroomId: dataroom.id, // Add this line to include the dataroomId
- });
+ res.status(201).json(dataroomWithCount);
} catch (error) {
console.error("Request error", error);
res.status(500).json({ error: "Error creating dataroom" });
diff --git a/pages/welcome.tsx b/pages/welcome.tsx
index 64cac289..f43da961 100644
--- a/pages/welcome.tsx
+++ b/pages/welcome.tsx
@@ -65,6 +65,9 @@ export default function Welcome() {
{router.query.type === "select" && <Select key="select" />}
{router.query.type === "pitchdeck" && <Upload key="pitchdeck" />}
{router.query.type === "document" && <Upload key="document" />}
+ {router.query.type === "sales-document" && (
+ <Upload key="sales-document" />
+ )}
{router.query.type === "notion" && <NotionForm key="notion" />}
{router.query.type === "dataroom" && <Dataroom key="dataroom" />}
{router.query.type === "dataroom-trial" && (