fix edit logo portofolio
This commit is contained in:
@@ -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 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user