28
apps/hub/app/(app)/admin/changelog/action.ts
Normal file
28
apps/hub/app/(app)/admin/changelog/action.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
"use server";
|
||||
|
||||
import { prisma, Prisma, Changelog } from "@repo/db";
|
||||
|
||||
export const upsertChangelog = async (
|
||||
changelog: Prisma.ChangelogCreateInput,
|
||||
id?: Changelog["id"],
|
||||
) => {
|
||||
const newChangelog = id
|
||||
? await prisma.changelog.update({
|
||||
where: { id: id },
|
||||
data: changelog,
|
||||
})
|
||||
: await prisma.$transaction(async (prisma) => {
|
||||
const createdChangelog = await prisma.changelog.create({ data: changelog });
|
||||
|
||||
await prisma.user.updateMany({
|
||||
data: { changelogAck: false },
|
||||
});
|
||||
|
||||
return createdChangelog;
|
||||
});
|
||||
return newChangelog;
|
||||
};
|
||||
|
||||
export const deleteChangelog = async (id: Changelog["id"]) => {
|
||||
await prisma.changelog.delete({ where: { id: id } });
|
||||
};
|
||||
Reference in New Issue
Block a user