fix edit logo portofolio

This commit is contained in:
2025-02-13 11:49:39 +08:00
parent b21c17027a
commit 61c43ef72a
6 changed files with 122 additions and 21 deletions

View File

@@ -1,11 +1,11 @@
import prisma from "@/lib/prisma";
import backendLogger from "@/util/backendLogger";
import fs from "fs";
import { NextRequest, NextResponse } from "next/server";
export async function GET(
req: NextRequest,
{ params }: { params: { id: string } }
) {
export { GET, PUT };
async function GET(req: NextRequest, { params }: { params: { id: string } }) {
const get = await prisma.images.findUnique({
where: {
id: params.id,
@@ -30,3 +30,52 @@ export async function GET(
},
});
}
async function PUT(
request: NextRequest,
{ params }: { params: { id: string } }
) {
if (request.method !== "PUT") {
return NextResponse.json(
{
success: false,
message: "Method not allowed",
},
{ status: 405 }
);
}
try {
const { id } = params;
const portofolioId = id;
const { data } = await request.json();
const logoId = data;
const updatePorto = await prisma.portofolio.update({
where: {
id: portofolioId,
},
data: {
logoId: logoId,
},
});
return NextResponse.json(
{
success: true,
message: "Berhasil mengubah Logo Bisnis!",
data: updatePorto,
},
{ status: 200 } // default status: 200
);
} catch (error) {
backendLogger.error("API Error Update Logo Portofolio", error);
return NextResponse.json(
{
success: false,
message: "Internal Server Error",
},
{ status: 500 }
);
}
}