Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion app/api/views-dataroom/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ export async function POST(request: NextRequest) {
allowDownload: true,
enableConversation: true,
teamId: true,
document: {
select: {
versions: {
where: {
id: documentVersionId,
},
select: {
file: true,
},
},
},
},
team: {
select: {
plan: true,
Expand Down Expand Up @@ -821,6 +833,11 @@ export async function POST(request: NextRequest) {
type: documentVersion.storageType,
});
}
if (documentVersion.type === "link") {
if (link.document && link.document.versions.length > 0) {
documentVersion.file = link.document.versions[0].file;
}
}
if (documentVersion.type === "sheet") {
const document = await prisma.document.findUnique({
where: { id: documentId },
Expand Down Expand Up @@ -917,7 +934,8 @@ export async function POST(request: NextRequest) {
(documentVersion.type === "pdf" ||
documentVersion.type === "image" ||
documentVersion.type === "zip" ||
documentVersion.type === "video")) ||
documentVersion.type === "video" ||
documentVersion.type === "link")) ||
(documentVersion && useAdvancedExcelViewer)
? documentVersion.file
: undefined,
Expand Down
65 changes: 43 additions & 22 deletions app/api/views/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ export async function POST(request: NextRequest) {
enableWatermark: true,
watermarkConfig: true,
teamId: true,
document: {
select: {
versions: {
where: {
id: documentVersionId,
},
select: {
file: true,
},
},
},
},
team: {
select: {
plan: true,
Expand Down Expand Up @@ -498,24 +510,24 @@ export async function POST(request: NextRequest) {
...(link.enableAgreement &&
link.agreementId &&
hasConfirmedAgreement && {
agreementResponse: {
create: {
agreementId: link.agreementId,
},
agreementResponse: {
create: {
agreementId: link.agreementId,
},
}),
},
}),
...(customFields &&
link.customFields.length > 0 && {
customFieldResponse: {
create: {
data: link.customFields.map((field) => ({
identifier: field.identifier,
label: field.label,
response: customFields[field.identifier] || "",
})),
},
customFieldResponse: {
create: {
data: link.customFields.map((field) => ({
identifier: field.identifier,
label: field.label,
response: customFields[field.identifier] || "",
})),
},
}),
},
}),
},
select: { id: true },
});
Expand Down Expand Up @@ -590,6 +602,14 @@ export async function POST(request: NextRequest) {
});
}

if (documentVersion.type === "link") {
if (link.document?.versions && link.document.versions.length > 0) {
documentVersion.file = link.document.versions[0].file;
} else {
throw new Error("Link document version not found.");
}
}

if (documentVersion.type === "sheet") {
if (useAdvancedExcelViewer) {
if (!documentVersion.file.includes("https://")) {
Expand Down Expand Up @@ -637,15 +657,16 @@ export async function POST(request: NextRequest) {
(documentVersion.type === "pdf" ||
documentVersion.type === "image" ||
documentVersion.type === "zip" ||
documentVersion.type === "video")) ||
(documentVersion && useAdvancedExcelViewer)
documentVersion.type === "video" ||
documentVersion.type === "link")) ||
(documentVersion && useAdvancedExcelViewer)
? documentVersion.file
: undefined,
pages: documentPages ? documentPages : undefined,
sheetData:
documentVersion &&
documentVersion.type === "sheet" &&
!useAdvancedExcelViewer
documentVersion.type === "sheet" &&
!useAdvancedExcelViewer
? sheetData
: undefined,
fileType: documentVersion
Expand All @@ -658,10 +679,10 @@ export async function POST(request: NextRequest) {
: undefined,
ipAddress:
link.enableWatermark &&
link.watermarkConfig &&
WatermarkConfigSchema.parse(link.watermarkConfig).text.includes(
"{{ipAddress}}",
)
link.watermarkConfig &&
WatermarkConfigSchema.parse(link.watermarkConfig).text.includes(
"{{ipAddress}}",
)
? process.env.VERCEL === "1"
? ipAddress(request)
: LOCALHOST_IP
Expand Down
16 changes: 8 additions & 8 deletions components/analytics/links-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@ import {
ChevronsUpDownIcon,
Copy,
Download,
Link2Icon,
LinkIcon,
} from "lucide-react";
import { toast } from "sonner";
import useSWR from "swr";

import { usePlan } from "@/lib/swr/use-billing";
import { cn, timeAgo } from "@/lib/utils";
import { fetcher } from "@/lib/utils";
import { downloadCSV } from "@/lib/utils/csv";

import { Button } from "@/components/ui/button";
import {
Table,
Expand All @@ -38,11 +43,6 @@ import {
} from "@/components/ui/table";
import { DataTablePagination } from "@/components/visitors/data-table-pagination";

import { usePlan } from "@/lib/swr/use-billing";
import { cn, timeAgo } from "@/lib/utils";
import { fetcher } from "@/lib/utils";
import { downloadCSV } from "@/lib/utils/csv";

import { UpgradePlanModal } from "../billing/upgrade-plan-modal";

interface Link {
Expand Down Expand Up @@ -315,7 +315,7 @@ export default function LinksTable({
<div className="flex justify-end">
<UpgradeOrExportButton />
</div>
<div className="rounded-xl border overflow-x-auto">
<div className="overflow-x-auto rounded-xl border">
<Table>
<TableHeader>
{table.getHeaderGroups().map((headerGroup) => (
Expand Down Expand Up @@ -365,7 +365,7 @@ export default function LinksTable({
<div className="flex w-full flex-col items-center justify-center gap-4 rounded-xl py-4">
<div className="hidden rounded-full sm:block">
<div className="rounded-full border border-white bg-gradient-to-t from-gray-100 p-1 md:p-3">
<Link2Icon className="size-6" />
<LinkIcon className="size-6" />
</div>
</div>
<p>
Expand Down
Loading