feat: admin stiker
deskrispi: - feature update status sticker
This commit is contained in:
39
src/app/api/sticker/[id]/activation/route.ts
Normal file
39
src/app/api/sticker/[id]/activation/route.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { prisma } from "@/lib";
|
||||
|
||||
export { PUT };
|
||||
|
||||
async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
const method = request.method;
|
||||
if (method !== "PUT") {
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Method not allowed" },
|
||||
{ status: 405 }
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
const { id } = params;
|
||||
const data = await request.json();
|
||||
|
||||
const sticker = await prisma.sticker.update({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
data: {
|
||||
isActive: data.isActive,
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json(
|
||||
{ success: true, message: "Success update data sticker", data: sticker },
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Error update data sticker", error);
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Error update data sticker" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ async function GET(request: Request) {
|
||||
try {
|
||||
const sticker = await prisma.sticker.findMany({
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
createdAt: "desc",
|
||||
},
|
||||
include: {
|
||||
MasterEmotions: true,
|
||||
|
||||
Reference in New Issue
Block a user