-
Notifications
You must be signed in to change notification settings - Fork 1k
feat(ee): add publishable q&a conversations #1847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+3,476
−846
Merged
Changes from 10 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
3187d57
feat(ui): add new notification badge style
mfts 3b91a66
feat: change conversations button in dataroom navbar
mfts 8b1e6b7
feat: add new breadcrumb text
mfts cd7866c
refactor(ee): move visitor upload route
mfts ab84743
feat: update q&a tab
mfts e25f123
chore: remove unused route
mfts 4171d6f
chore: remove duplicate context component
mfts 57aa2ed
feat(ee): add dashboard faq conversations
mfts 13bc6e3
feat(ee): add viewer side conversations faq
mfts 6c63fce
feat(ee): add database entry for conversations
mfts 0a558ff
feat: several improvements to conversations
mfts d2ce48e
fix
mfts d7309cb
refactor: create common zod schema for faqs
mfts 5ed47f9
feat: upgrade packages
mfts dfb2e64
feat: improve zod parser
mfts adcab06
fix: validation
mfts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import { NextRequest, NextResponse } from "next/server"; | ||
|
||
import { verifyDataroomSession } from "@/lib/auth/dataroom-auth"; | ||
import prisma from "@/lib/prisma"; | ||
|
||
export interface VisitorFAQResponse { | ||
id: string; | ||
editedQuestion: string; | ||
answer: string; | ||
documentPageNumber?: number; | ||
documentVersionNumber?: number; | ||
createdAt: string; | ||
document?: { | ||
name: string; | ||
}; | ||
} | ||
|
||
// GET /api/faqs?linkId=xxx&dataroomId=xxx - List published FAQs for visitors | ||
export async function GET(req: NextRequest) { | ||
try { | ||
const searchParams = req.nextUrl.searchParams; | ||
const linkId = searchParams.get("linkId"); | ||
const dataroomId = searchParams.get("dataroomId"); | ||
const documentId = searchParams.get("documentId"); | ||
|
||
if (!linkId || !dataroomId) { | ||
return NextResponse.json( | ||
{ error: "linkId and dataroomId are required" }, | ||
{ status: 400 }, | ||
); | ||
} | ||
|
||
// Verify dataroom session | ||
const session = await verifyDataroomSession(req, linkId, dataroomId); | ||
if (!session) { | ||
return NextResponse.json( | ||
{ error: "Unauthorized - invalid or expired session" }, | ||
{ status: 401 }, | ||
); | ||
} | ||
|
||
// Build where clause based on visibility filters | ||
const whereClause: any = { | ||
dataroomId, | ||
status: "PUBLISHED", | ||
}; | ||
|
||
// Apply visibility filters | ||
const visibilityFilters: any[] = [ | ||
{ visibilityMode: "PUBLIC_DATAROOM" }, // Always include dataroom-wide FAQs | ||
]; | ||
|
||
if (linkId) { | ||
visibilityFilters.push({ | ||
visibilityMode: "PUBLIC_LINK", | ||
linkId: linkId, | ||
}); | ||
} | ||
|
||
if (documentId) { | ||
visibilityFilters.push({ | ||
visibilityMode: "PUBLIC_DOCUMENT", | ||
dataroomDocumentId: documentId, | ||
}); | ||
} | ||
|
||
whereClause.OR = visibilityFilters; | ||
|
||
// Fetch published FAQs | ||
const faqs = await prisma.dataroomFaqItem.findMany({ | ||
where: whereClause, | ||
select: { | ||
id: true, | ||
editedQuestion: true, | ||
answer: true, | ||
documentPageNumber: true, | ||
documentVersionNumber: true, | ||
createdAt: true, | ||
dataroomDocument: { | ||
select: { | ||
document: { | ||
select: { | ||
name: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
orderBy: { createdAt: "desc" }, | ||
}); | ||
|
||
// Format response | ||
const response: VisitorFAQResponse[] = faqs.map((faq: any) => ({ | ||
id: faq.id, | ||
editedQuestion: faq.editedQuestion, | ||
answer: faq.answer, | ||
documentPageNumber: faq.documentPageNumber || undefined, | ||
documentVersionNumber: faq.documentVersionNumber || undefined, | ||
createdAt: faq.createdAt.toISOString(), | ||
document: faq.dataroomDocument?.document | ||
? { | ||
name: faq.dataroomDocument.document.name, | ||
} | ||
: undefined, | ||
})); | ||
|
||
return NextResponse.json(response); | ||
} catch (error) { | ||
console.error("Error fetching visitor FAQs:", error); | ||
return NextResponse.json( | ||
{ error: "Internal server error" }, | ||
{ status: 500 }, | ||
); | ||
} | ||
} |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.