Skip to content

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

feat: enable delete dataroom on business

Marc Seitz6316cb3cdedb
diff --git a/components/datarooms/settings/delete-dataroooom/delete-dataroom-modal.tsx b/components/datarooms/settings/delete-dataroooom/delete-dataroom-modal.tsx
index b1d91dda..77b16397 100644
--- a/components/datarooms/settings/delete-dataroooom/delete-dataroom-modal.tsx
+++ b/components/datarooms/settings/delete-dataroooom/delete-dataroom-modal.tsx
@@ -18,7 +18,6 @@ import { Input } from "@/components/ui/input";
import { Modal } from "@/components/ui/modal";
import { useAnalytics } from "@/lib/analytics";
-import { useMediaQuery } from "@/lib/utils/use-media-query";
function DeleteDataroomModal({
dataroomId,
@@ -38,8 +37,6 @@ function DeleteDataroomModal({
const [deleting, setDeleting] = useState(false);
async function deleteDataroom() {
- const dataroomsCount = teamInfo?.teams.length ?? 1;
-
return new Promise((resolve, reject) => {
setDeleting(true);
@@ -66,8 +63,6 @@ function DeleteDataroomModal({
});
}
- const { isMobile } = useMediaQuery();
-
return (
<Modal
showModal={showDeleteDataroomModal}
diff --git a/pages/api/teams/[teamId]/datarooms/[id]/index.ts b/pages/api/teams/[teamId]/datarooms/[id]/index.ts
index e93b5ee6..66167216 100644
--- a/pages/api/teams/[teamId]/datarooms/[id]/index.ts
+++ b/pages/api/teams/[teamId]/datarooms/[id]/index.ts
@@ -134,9 +134,10 @@ export default async function handle(
user.userId === (session.user as CustomUser).id,
);
if (!isUserAdmin) {
- return res
- .status(403)
- .json({ message: "You are not permitted to perform this action" });
+ return res.status(403).json({
+ message:
+ "You are not permitted to perform this action. Only admin and managers can delete datarooms.",
+ });
}
await prisma.dataroom.delete({
diff --git a/pages/datarooms/[id]/settings/index.tsx b/pages/datarooms/[id]/settings/index.tsx
index 9cc7c17e..609d5819 100644
--- a/pages/datarooms/[id]/settings/index.tsx
+++ b/pages/datarooms/[id]/settings/index.tsx
@@ -19,7 +19,7 @@ export default function Settings() {
const teamInfo = useTeam();
const teamId = teamInfo?.currentTeam?.id;
- const { isDatarooms, isDataroomsPlus } = usePlan();
+ const { isBusiness, isDatarooms, isDataroomsPlus } = usePlan();
if (!dataroom) {
return <div>Loading...</div>;
@@ -84,7 +84,7 @@ export default function Settings() {
}
/>
<DuplicateDataroom dataroomId={dataroom.id} teamId={teamId} />
- {isDatarooms || isDataroomsPlus ? (
+ {isBusiness || isDatarooms || isDataroomsPlus ? (
<DeleteDataroom
dataroomId={dataroom.id}
dataroomName={dataroom.name}