Initial working commit
Some checks failed
Automated Container Build / build-and-push (push) Failing after 7s

This commit is contained in:
Elijah 2026-06-27 19:19:38 -07:00
parent 666ceb7325
commit b7ce314f01
105 changed files with 35510 additions and 11 deletions

View file

@ -0,0 +1,52 @@
import { prisma } from "@/lib/db";
export async function getShareLink(token: string) {
return prisma.shareLink.findUnique({
where: { id: token },
include: {
deck: {
include: {
cards: { orderBy: { sortOrder: "asc" } },
class: { select: { slug: true, name: true } },
},
},
quizSet: {
include: {
questions: {
orderBy: { sortOrder: "asc" },
include: {
options: { orderBy: { sortOrder: "asc" } },
},
},
class: { select: { slug: true, name: true } },
},
},
},
});
}
export async function getShareLinkForContent(targetType: "DECK" | "QUIZ", contentId: string) {
if (targetType === "DECK") {
return prisma.shareLink.findUnique({ where: { deckId: contentId } });
}
return prisma.shareLink.findUnique({ where: { quizSetId: contentId } });
}
export async function toggleShareLink(targetType: "DECK" | "QUIZ", contentId: string) {
const existing = await getShareLinkForContent(targetType, contentId);
if (existing) {
// Disable sharing
await prisma.shareLink.delete({ where: { id: existing.id } });
return null;
}
// Enable sharing
return prisma.shareLink.create({
data: {
targetType,
deckId: targetType === "DECK" ? contentId : null,
quizSetId: targetType === "QUIZ" ? contentId : null,
},
});
}