forked from Aaron/Kino-Website
add TypeScript interfaces for cart and cart items
Introduces BaseCartItem, MovieCartItem, SnackCartItem, and the CartItem discriminated union in bigConstants.ts. Replaces all any-typed cart references across CartView, CheckoutView, SnacksView, and BookingModal with the new typed interfaces. Also types users/currentUser with the existing User interface and removes the unused JSONType import. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -450,6 +450,7 @@
|
||||
|
||||
<script>
|
||||
import { cart, updateCart } from "../scripts/bigConstants";
|
||||
import type { SnackCartItem } from "../scripts/bigConstants";
|
||||
|
||||
const snacksView = document.getElementById("snacks-view");
|
||||
|
||||
@@ -471,7 +472,7 @@
|
||||
const activeOption = snackCard.querySelector(".opt-btn.active") as HTMLElement;
|
||||
const variantVal = activeOption ? activeOption.innerText : "Normal";
|
||||
|
||||
cart.push({
|
||||
const snackItem: SnackCartItem = {
|
||||
id: Date.now() + Math.random(),
|
||||
category: "snack",
|
||||
title: snackTitle,
|
||||
@@ -480,7 +481,8 @@
|
||||
type: "SNACK",
|
||||
price: priceVal,
|
||||
img: snackImg
|
||||
});
|
||||
};
|
||||
cart.push(snackItem);
|
||||
|
||||
updateCart(cart);
|
||||
window.dispatchEvent(new CustomEvent("cart-updated"));
|
||||
|
||||
Reference in New Issue
Block a user