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:
Jannis Heydemann
2026-05-06 08:25:16 +02:00
parent e6fee6e4e1
commit 06606131ef
5 changed files with 97 additions and 58 deletions

View File

@@ -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"));