Files
frontend/lib/api/review.ts
T
Thanh Quy - wolf df1f32c23d feat: enhance login, registration, and payment functionalities
- Added `credentials: "include"` to fetch requests in LoginOtpPage and RegisterPage for cookie handling.
- Introduced `eateryId` in PaymentPage to manage cart context.
- Updated ProductCardProps and ShopCardProps to include `eateryId`.
- Enhanced PaymentSummaryCard to accept `eateryId` prop.
- Modified ShopCard to set `eateryId` in cart context on click.
- Implemented menu item management in MenuItemsTab with add, edit, and delete functionalities.
- Created new API functions for handling reviews and cart operations.
- Updated GraphQL queries and mutations for menu items and cart management.
- Added loading states and error handling in ProductGrid and ReviewModal.
- Enhanced local storage management for cart and eatery ID.
2026-05-08 21:59:18 +07:00

25 lines
676 B
TypeScript

export interface SendReview {
eateryId: string;
rating: number;
comment: string;
}
export function hasAuthCookie(): boolean {
if (typeof document === "undefined") return false;
return document.cookie.split(";").some((c) => c.trim().startsWith("auth="));
}
export async function createReview(input: SendReview): Promise<void> {
const res = await fetch("/api/eatery/review", {
method: "POST",
headers: { "Content-Type": "application/json" },
credentials: "include",
body: JSON.stringify(input),
});
if (!res.ok) {
const text = await res.text().catch(() => "");
throw new Error(text || `Failed to submit review (${res.status})`);
}
}