Update Versi 1.5.27 #32

Merged
bagasbanuna merged 1009 commits from staging into main 2025-12-17 12:22:28 +08:00
2139 changed files with 91194 additions and 24366 deletions
Showing only changes of commit 6a614191e7 - Show all commits

View File

@@ -47,45 +47,82 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
}
try {
let message;
const { id } = params;
const body = await request.json();
const { data } = body;
const { searchParams } = new URL(request.url);
const category = searchParams.get("category");
const cekEmail = await prisma.profile.findUnique({
where: {
email: data.email,
},
});
if (category === "profile") {
const cekEmail = await prisma.profile.findUnique({
where: {
email: data.email,
},
});
if (cekEmail && cekEmail.id != id)
return NextResponse.json({
success: false,
message: "Email sudah digunakan",
});
const updateData = await prisma.profile.update({
where: {
id: id,
},
data: {
name: data.name,
email: data.email,
alamat: data.alamat,
jenisKelamin: data.jenisKelamin,
},
});
if (!updateData) {
return NextResponse.json({ success: false, message: "Gagal update" });
}
if (cekEmail && cekEmail.id != id)
return NextResponse.json({
success: false,
message: "Email sudah digunakan",
message = "Berhasil edit profile";
} else if (category === "photo") {
const updateData = await prisma.profile.update({
where: {
id: id,
},
data: {
imageId: data.fileId,
},
});
const updateData = await prisma.profile.update({
where: {
id: id,
},
data: {
name: data.name,
email: data.email,
alamat: data.alamat,
jenisKelamin: data.jenisKelamin,
},
});
if (!updateData) {
return NextResponse.json({
success: false,
message: "Gagal update foto",
});
}
if (!updateData) {
return NextResponse.json({ success: false, message: "Gagal update" });
message = "Berhasil edit foto profile";
} else if (category === "background") {
const updateData = await prisma.profile.update({
where: {
id: id,
},
data: {
imageBackgroundId: data.fileId,
},
});
if (!updateData) {
return NextResponse.json({
success: false,
message: "Gagal update background",
});
}
message = "Berhasil edit background profile";
}
return NextResponse.json({
success: true,
message: "Berhasil edit profile",
message: message,
});
} catch (error) {
backendLogger.error("Error edit profile", error);
return NextResponse.json(
{
success: false,

View File

@@ -7,27 +7,15 @@ async function POST(request: Request) {
try {
const { data } = await request.json();
const existingEmail = await prisma.profile.findUnique({
where: {
email: data.email,
},
});
if (existingEmail) {
return NextResponse.json({
success: false,
message: "Email telah digunakan",
status: 400,
});
}
const create = await prisma.profile.create({
await prisma.profile.create({
data: {
userId: data.id,
name: data.name,
email: data.email,
alamat: data.alamat,
jenisKelamin: data.jenisKelamin,
imageId: data.imageId || "",
imageBackgroundId: data.imageBackgroundId || "",
},
});

View File

@@ -0,0 +1,38 @@
import { NextResponse } from "next/server";
import { prisma } from "@/lib";
export async function POST(request: Request) {
const { data } = await request.json();
const email = data;
try {
const existingEmail = await prisma.profile.findUnique({
where: {
email: email,
},
});
if (existingEmail) {
return NextResponse.json({
success: false,
message: "Email telah digunakan",
status: 400,
});
}
return NextResponse.json({
success: true,
message: "Email tidak digunakan",
status: 200,
});
} catch (error) {
console.log("error", error);
return NextResponse.json(
{
success: false,
message: "Gagal validasi email",
},
{ status: 500 }
);
}
}