feat: consolidate constants and shared state into bigConstants.ts
This commit is contained in:
95
src/scripts/bigConstants.ts
Normal file
95
src/scripts/bigConstants.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
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 let cart: any[] = JSON.parse(typeof window !== 'undefined' ? (localStorage.getItem("eagleCart") || '[]') : '[]');
|
||||
export let occupiedSeatsData = JSON.parse(typeof window !== 'undefined' ? (localStorage.getItem("eagleOccupied") || '{}') : '{}');
|
||||
export let users: any[] = JSON.parse(typeof window !== 'undefined' ? (localStorage.getItem("eagleUsers") || '[]') : '[]');
|
||||
export let currentUser: any = JSON.parse(typeof window !== 'undefined' ? (localStorage.getItem("currentUser") || 'null') : 'null');
|
||||
|
||||
export function updateCart(newCart: any[]) {
|
||||
cart.splice(0, cart.length, ...newCart);
|
||||
if (typeof window !== 'undefined') {
|
||||
localStorage.setItem("eagleCart", JSON.stringify(cart));
|
||||
}
|
||||
}
|
||||
|
||||
export function updateOccupiedSeats(newData: any) {
|
||||
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: any) {
|
||||
currentUser = user;
|
||||
if (typeof window !== 'undefined') {
|
||||
if (currentUser) localStorage.setItem("currentUser", JSON.stringify(currentUser));
|
||||
else localStorage.removeItem("currentUser");
|
||||
}
|
||||
}
|
||||
|
||||
export interface User {
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
email: string;
|
||||
hashedPassword: string;
|
||||
orders: any[];
|
||||
paymentMethods: any[];
|
||||
}
|
||||
|
||||
export interface MovieCatalog {
|
||||
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: any[];
|
||||
total_pages: number;
|
||||
total_results: number;
|
||||
}
|
||||
Reference in New Issue
Block a user