latest changes
This commit is contained in:
1 parent
56cd6fd058
commit
1de72863db
40 files changed
+3837
-568
No files matched your search
@@ -10,7 +10,7 @@ async function uniqueSlug(title: string): Promise<string> {
|
||||
const base = slugify(title);
|
||||
let slug = base;
|
||||
let n = 2;
|
||||
while (await prisma.websiteArticles.findUnique({ where: { slug } })) {
|
||||
while (await prisma.websiteArticles.findUnique({ where: { slug }, select: { id: true } })) {
|
||||
slug = `${base}-${n++}`;
|
||||
}
|
||||
return slug;
|
||||
@@ -32,7 +32,7 @@ export async function createArticle(formData: FormData): Promise<void> {
|
||||
shortStory: shortStory.slice(0, 255),
|
||||
fullStory,
|
||||
image: image.slice(0, 255),
|
||||
userId: String(staff.id),
|
||||
userId: staff.id,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
@@ -59,6 +59,9 @@ export async function updateArticle(formData: FormData): Promise<void> {
|
||||
|
||||
export async function deleteArticle(formData: FormData): Promise<void> {
|
||||
await requireStaff();
|
||||
await prisma.websiteArticles.delete({ where: { id: BigInt(String(formData.get("id"))) } });
|
||||
const id = BigInt(String(formData.get("id")));
|
||||
await prisma.websiteArticleReactions.deleteMany({ where: { articleId: id } });
|
||||
await prisma.websiteArticleComments.deleteMany({ where: { articleId: id } });
|
||||
await prisma.websiteArticles.delete({ where: { id } });
|
||||
redirect("/admin/articles");
|
||||
}
|
||||
Reference in new issue
Block a user