Mobile notification & EULA route #40

Merged
bagasbanuna merged 21 commits from mobile-notification/9-jan-26 into staging 2026-01-09 17:47:41 +08:00
8 changed files with 84 additions and 8 deletions
Showing only changes of commit d84a1d84ff - Show all commits

View File

@@ -0,0 +1,54 @@
import { prisma } from "@/lib";
import { NextResponse } from "next/server";
export async function POST(req: Request) {
try {
const { nomor } = await req.json();
const user = await prisma.user.findUnique({
where: {
nomor: nomor,
},
});
if (!user)
return NextResponse.json({
success: false,
message: "User belum terdaftar",
status: 404,
});
const updateTerms = await prisma.user.update({
where: { nomor: nomor },
data: {
termsOfServiceAccepted: true,
acceptedTermsAt: new Date(),
},
});
if (!updateTerms) {
return NextResponse.json({
success: false,
message: "Gagal setujui syarat dan ketentuan",
status: 400,
});
}
return NextResponse.json(
{
success: true,
message: "Anda telah setujui syarat dan ketentuan",
},
{ status: 200 }
);
} catch (error) {
return NextResponse.json(
{
success: false,
message: "Terjadi masalah saat setujui syarat dan ketentuan",
reason: error as Error,
},
{ status: 500 }
);
}
}

View File

@@ -6,7 +6,6 @@ export async function POST(req: Request) {
try {
const codeOtp = randomOTP();
const body = await req.json();
console.log("[Masuk API]", body);
const { nomor } = body;
const user = await prisma.user.findUnique({
@@ -15,9 +14,6 @@ export async function POST(req: Request) {
},
});
console.log(["cek user", user]);
console.log(["cek nomor", nomor]);
if (!user)
return NextResponse.json({
success: false,
@@ -66,6 +62,7 @@ export async function POST(req: Request) {
success: true,
message: "Kode verifikasi terkirim",
kodeId: createOtpId.id,
isAcceptTerms: user.termsOfServiceAccepted,
},
{ status: 200 }
);