diff --git a/src/app/api/review/route.ts b/src/app/api/review/route.ts index babcd58..15ef817 100644 --- a/src/app/api/review/route.ts +++ b/src/app/api/review/route.ts @@ -6,19 +6,10 @@ export const dynamic = "force-dynamic"; export async function POST(request: Request) { try { - // const body = await request.json(); - - // const { name, brand } = body; - // if (!name || !brand) { - // return NextResponse.json( - // { error: "Missing required fields" }, - // { status: 400 }, - // ); - // } - const reviews = [ { productId: 2, + modelId: 1, content: "Laptop ini sangat ringan dan performanya cepat untuk kerja harian.", keywords: ["ringan", "cepat", "kerja"], @@ -27,6 +18,7 @@ export async function POST(request: Request) { }, { productId: 3, + modelId: 1, content: "Baterainya awet, tapi harganya cukup mahal.", keywords: ["baterai", "awet", "mahal"], sentiment: Sentiment.neutral, @@ -34,6 +26,7 @@ export async function POST(request: Request) { }, { productId: 4, + modelId: 1, content: "Performa kurang stabil dan sering panas.", keywords: ["performa", "panas", "stabil"], sentiment: Sentiment.negative, @@ -60,3 +53,38 @@ export async function POST(request: Request) { ); } } + +export async function GET() { + try { + const review = await prisma.review.findMany({ + orderBy: { + createdAt: "desc", + }, + select: { + id: true, + createdAt: true, + confidenceScore: true, + sentiment: true, + content: true, + keywords: true, + product: { + select: { + name: true, + brand: true, + }, + }, + }, + }); + + return NextResponse.json( + { + message: "Review data successfuly retrivied", + data: review, + }, + { status: 200 }, + ); + } catch (error) { + console.log(error); + return NextResponse.json({ message: "Error", data: [] }, { status: 500 }); + } +} diff --git a/src/components/dashboards/DashboardClient.tsx b/src/components/dashboards/DashboardClient.tsx index 8b43292..dc04876 100644 --- a/src/components/dashboards/DashboardClient.tsx +++ b/src/components/dashboards/DashboardClient.tsx @@ -1,4 +1,5 @@ "use client"; + import { Header } from "./Header"; import { MessageSquareText, @@ -28,7 +29,6 @@ export default function DashboardClient() { positiveCount, negativeCount, neutralCount, - filteredReviews, selectedBrand, loading, modelData, @@ -153,7 +153,7 @@ export default function DashboardClient() { onSelect={setSelectedBrand} /> - +