forked from Aaron/Kino-Website
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>
132 lines
4.7 KiB
TypeScript
132 lines
4.7 KiB
TypeScript
export const prices: Record<string, number> = { normal: 11.0, imax: 15.0, vip: 12.0, dbox: 16.0 };
|
|
|
|
export const seatLayouts = {
|
|
"Kino 1": { rows: 6, left: 3, right: 7, vipRows: [5], dbox: [] },
|
|
"Kino 2": { rows: 7, left: 5, right: 5, vipRows: [6], dbox: [] },
|
|
"Deluxe 1": { rows: 10, left: 7, right: 8, vipRows: [9], dbox: [{ r: 4, c: 5, w: 4 }] },
|
|
IMAX: { rows: 15, left: 10, right: 10, vipRows: [], dbox: [], isImax: true }
|
|
};
|
|
|
|
export const movieCatalog = [
|
|
{ title: "Zoomania 2", genre: "Animation", duration: 108, poster: "/img/Zoomania-2.jpg", backdrop: "/img/Zoomania-2.jpg", fsk: "0", description: "Die Fortsetzung des beliebten Animationsabenteuers." },
|
|
{ title: "Der Austronaut", genre: "Sci-Fi", duration: 124, poster: "/img/derAustronaut.jpg", backdrop: "/img/derAustronaut.jpg", fsk: "12", description: "Ein einsamer Astronaut kämpft um sein Überleben." },
|
|
{ title: "Spider-Man", genre: "Action", duration: 133, poster: "/img/spidermannewday.jpg", backdrop: "/img/spidermannewday.jpg", fsk: "12", description: "Ein neues Abenteuer des freundlichen Spinnenmanns." },
|
|
{ title: "Scream VII", genre: "Horror", duration: 115, poster: "/img/screamvii.jpg", backdrop: "/img/screamvii.jpg", fsk: "18", description: "Ghostface ist zurück und gefährlicher als je zuvor." },
|
|
{ title: "Gangster Gang 2", genre: "Animation", duration: 95, poster: "/img/gangstergang2.png", backdrop: "/img/gangstergang2.png", fsk: "6", description: "Die Gangster Gang ist wieder unterwegs." }
|
|
];
|
|
|
|
export const hallRotation = ["IMAX", "Deluxe 1", "Kino 1", "Kino 2"];
|
|
|
|
export const timePatterns = [
|
|
["13:00", "15:20", "17:40", "20:00", "22:20"],
|
|
["13:00", "14:50", "17:10", "19:30", "21:50"],
|
|
["13:00", "15:10", "17:30", "19:50", "22:10"],
|
|
["13:00", "16:00", "18:20", "20:40"]
|
|
];
|
|
|
|
export const weekdayShort = ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"];
|
|
|
|
// Shared State
|
|
export const cart: CartItem[] = JSON.parse(typeof window !== 'undefined' ? (localStorage.getItem("eagleCart") || '[]') : '[]');
|
|
export let occupiedSeatsData = JSON.parse(typeof window !== 'undefined' ? (localStorage.getItem("eagleOccupied") || '{}') : '{}');
|
|
export const users: User[] = JSON.parse(typeof window !== 'undefined' ? (localStorage.getItem("eagleUsers") || '[]') : '[]');
|
|
export let currentUser: User | null = JSON.parse(typeof window !== 'undefined' ? (localStorage.getItem("currentUser") || 'null') : 'null');
|
|
|
|
export function updateCart(newCart: CartItem[]) {
|
|
cart.splice(0, cart.length, ...newCart);
|
|
if (typeof window !== 'undefined') {
|
|
localStorage.setItem("eagleCart", JSON.stringify(cart));
|
|
}
|
|
}
|
|
|
|
export function updateOccupiedSeats(newData: unknown) {
|
|
occupiedSeatsData = newData;
|
|
if (typeof window !== 'undefined') {
|
|
localStorage.setItem("eagleOccupied", JSON.stringify(occupiedSeatsData));
|
|
}
|
|
}
|
|
|
|
export function emptyCart() {
|
|
cart.length = 0;
|
|
if (typeof window !== 'undefined') {
|
|
localStorage.setItem("eagleCart", JSON.stringify(cart));
|
|
}
|
|
}
|
|
|
|
export function persistUsers() {
|
|
if (typeof window !== 'undefined') localStorage.setItem("eagleUsers", JSON.stringify(users));
|
|
}
|
|
|
|
export function persistCurrentUser(user: User | null) {
|
|
currentUser = user;
|
|
if (typeof window !== 'undefined') {
|
|
if (currentUser) localStorage.setItem("currentUser", JSON.stringify(currentUser));
|
|
else localStorage.removeItem("currentUser");
|
|
}
|
|
}
|
|
|
|
export interface BaseCartItem {
|
|
id: number;
|
|
category: "movie" | "snack";
|
|
title: string;
|
|
/** Hall name for movies; size label (e.g. "0,33L") for snacks */
|
|
hall: string;
|
|
/** Showtime for movies; flavour/variant for snacks */
|
|
time: string;
|
|
price: number;
|
|
img?: string;
|
|
}
|
|
|
|
export interface MovieCartItem extends BaseCartItem {
|
|
category: "movie";
|
|
seatId: string;
|
|
}
|
|
|
|
export interface SnackCartItem extends BaseCartItem {
|
|
category: "snack";
|
|
type: "SNACK";
|
|
}
|
|
|
|
export type CartItem = MovieCartItem | SnackCartItem;
|
|
|
|
export interface User {
|
|
firstName: string;
|
|
lastName: string;
|
|
email: string;
|
|
hashedPassword: string;
|
|
orders: unknown[];
|
|
paymentMethods: unknown[];
|
|
}
|
|
|
|
export interface MovieInterface {
|
|
id: number;
|
|
title: string;
|
|
genre: string;
|
|
duration: number;
|
|
fsk: string;
|
|
description: string;
|
|
poster: string;
|
|
backdrop: string;
|
|
rating: number;
|
|
year: string;
|
|
}
|
|
|
|
export interface ITMDBResponse {
|
|
page: number;
|
|
results: unknown[];
|
|
total_pages: number;
|
|
total_results: number;
|
|
}
|
|
|
|
export interface ITMDBMovie {
|
|
id: number;
|
|
title: string;
|
|
poster_path: string;
|
|
vote_average: number;
|
|
release_date: string;
|
|
genre_ids: number[];
|
|
runtime: number;
|
|
age_rating: string;
|
|
overview: string;
|
|
backdrop_path: string;
|
|
} |