chore: update

This commit is contained in:
TakahashiNg
2026-05-15 11:29:14 +00:00
parent 3d566e2468
commit 73fec3e85a
4 changed files with 29 additions and 22 deletions
+1 -3
View File
@@ -31,8 +31,6 @@ export default function PaymentPage() {
price: 0,
} as MenuItemEntity);
const isCustomer = user?.role === "customer";
return (
<div>
<div className="mx-auto w-full max-w-screen-2xl px-4 py-6 md:px-6 md:py-8 lg:px-8">
@@ -149,7 +147,7 @@ export default function PaymentPage() {
<PaymentSummaryCard
totalPrice={totalPrice}
isCustomer={isCustomer}
isCustomer={true}
backHref="/"
eateryId={eateryId}
/>
@@ -14,7 +14,6 @@ export default function PaymentSummaryCard({
}: PaymentSummaryCardProps) {
const [isReviewOpen, setIsReviewOpen] = useState(false);
const handlePayment = () => {
// UI-only: open review modal after "payment"
if (isCustomer) {
setIsReviewOpen(true);
}
@@ -52,22 +51,7 @@ export default function PaymentSummaryCard({
QR Code
</Button>
{isCustomer && (
<Button
style="payment"
onClick={handlePayment}
icon="fa-solid fa-star"
size="md"
variant="primary"
>
Review
</Button>
)}
<Link
href={backHref || "/"}
className={isCustomer ? "" : "col-span-2"}
>
<Link href={backHref || "/"} className={"col-span-2"}>
<Button
style="payment"
onClick={() => setIsReviewOpen(false)}
+2 -2
View File
@@ -29,10 +29,10 @@ export default function ReviewModal({
if (!isOpen) return null;
const handleSubmit = async () => {
if (!user?.id || !eateryId) return;
if (!eateryId) return;
const input: CreateReviewInput = {
reviewerId: user.id,
reviewerId: user?.id || "",
eateryId,
rating,
...(review.trim() ? { comment: review.trim() } : {}),
+25
View File
@@ -24,6 +24,7 @@ interface CartContextValue {
decreaseQty: (id: string) => void;
removeFromCart: (id: string) => void;
setQuantity: (id: string, quantity: number) => void;
removeCart: (id: string) => void;
}
const CART_ID = "cartId";
@@ -151,6 +152,29 @@ export function CartProvider({ children }: { children: React.ReactNode }) {
if (result) setCart(result.addItem);
};
const removeCart = async (id: string) => {
localStorage.removeItem(CART_ID);
const DELETE_CART = gql`
mutation deleteCart($cartId: String!) {
deleteCart(cartId: $cartId)
}
`;
const [mutateDeleteCart] = useMutation(DELETE_CART, {
client: cartClient,
});
await mutateDeleteCart({
variables: {
cartId: id,
},
});
setCartId(null);
setCart(null!);
};
const setQuantity = async (id: string, newQuantity: number) => {
if (!cartId) return;
@@ -191,6 +215,7 @@ export function CartProvider({ children }: { children: React.ReactNode }) {
decreaseQty,
removeFromCart,
setQuantity,
removeCart,
}),
[cart?.items, cart?.totalAmount, cart?.eateryId],
);