df1f32c23d
- 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.
25 lines
676 B
TypeScript
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})`);
|
|
}
|
|
}
|