diff --git a/src/app/api/approve-review/route.ts b/src/app/api/review-status/approve/route.ts similarity index 100% rename from src/app/api/approve-review/route.ts rename to src/app/api/review-status/approve/route.ts diff --git a/src/app/api/disapprove-review/route.ts b/src/app/api/review-status/disapprove/route.ts similarity index 100% rename from src/app/api/disapprove-review/route.ts rename to src/app/api/review-status/disapprove/route.ts diff --git a/src/app/api/review-status/pending/route.ts b/src/app/api/review-status/pending/route.ts new file mode 100644 index 0000000..944aec8 --- /dev/null +++ b/src/app/api/review-status/pending/route.ts @@ -0,0 +1,31 @@ +import { NextResponse, type NextRequest } from 'next/server'; +import { authorize } from '~/lib/authorize'; +import * as db from '~/lib/db'; +import { setPendingReview } from '~/server/bigcommerce-api'; + +export async function POST(req: NextRequest) { + const authorized = authorize(); + + if (!authorized) { + return new NextResponse('Unauthorized', { status: 401 }); + } + + const accessToken = await db.getStoreToken(authorized.storeHash); + + if (!accessToken) { + return new NextResponse( + 'Access token not found. Try to re-install the app.', + { status: 401 } + ); + } + + const reqBody = (await req.json()) as { productId: number; reviewId: number }; + + const review = await setPendingReview({ + ...reqBody, + accessToken, + storeHash: authorized.storeHash, + }); + + return NextResponse.json(review); +} diff --git a/src/components/AIChatBubble.tsx b/src/components/AIChatBubble.tsx index cfdfc98..5bac1d3 100644 --- a/src/components/AIChatBubble.tsx +++ b/src/components/AIChatBubble.tsx @@ -7,7 +7,7 @@ interface AIChatBubbleProps { export const AIChatBubble = ({ message, hideAvatar }: AIChatBubbleProps) => { return ( -