From d84a1d84ffd630269a4ba3a4e7cacb7827ca8931 Mon Sep 17 00:00:00 2001 From: bagasbanuna Date: Fri, 9 Jan 2026 17:45:44 +0800 Subject: [PATCH] Fix route untuk penambahan fitur EULA Fix: - modified: src/app/api/auth/mobile-login/route.ts Add: - src/app/api/auth/mobile-eula/ ### No Issue --- src/app/api/auth/mobile-eula/route.tsx | 54 ++++++++++++++++++++++++++ src/app/api/auth/mobile-login/route.ts | 5 +-- 2 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 src/app/api/auth/mobile-eula/route.tsx diff --git a/src/app/api/auth/mobile-eula/route.tsx b/src/app/api/auth/mobile-eula/route.tsx new file mode 100644 index 00000000..9c5285c3 --- /dev/null +++ b/src/app/api/auth/mobile-eula/route.tsx @@ -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 } + ); + } +} diff --git a/src/app/api/auth/mobile-login/route.ts b/src/app/api/auth/mobile-login/route.ts index 62767dd3..7bcf5bd1 100644 --- a/src/app/api/auth/mobile-login/route.ts +++ b/src/app/api/auth/mobile-login/route.ts @@ -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 } );