remove tag functionality

This commit is contained in:
daniel31x13
2023-11-03 00:09:50 -04:00
parent ae1889e757
commit b5a28f68ad
16 changed files with 123 additions and 448 deletions
@@ -0,0 +1,26 @@
import { prisma } from "@/lib/api/db";
export default async function deleteTagById(userId: number, tagId: number) {
if (!tagId)
return { response: "Please choose a valid name for the tag.", status: 401 };
const targetTag = await prisma.tag.findUnique({
where: {
id: tagId,
},
});
if (targetTag?.ownerId !== userId)
return {
response: "Permission denied.",
status: 401,
};
const updatedTag = await prisma.tag.delete({
where: {
id: tagId,
},
});
return { response: updatedTag, status: 200 };
}
@@ -1,7 +1,7 @@
import { prisma } from "@/lib/api/db";
import { Tag } from "@prisma/client";
export default async function updateTag(
export default async function updeteTagById(
userId: number,
tagId: number,
data: Tag