Set image value in Item to list, to support more images in the future

Set all pages to Typescript
This commit is contained in:
Michał Gdula 2024-05-05 11:12:01 +01:00
parent 7d8d19a6e9
commit 9dce9235d6
16 changed files with 63 additions and 59 deletions

View file

@ -127,13 +127,12 @@ export async function postVerifyCart(
const newCartData: Record<string, CartItem> = {};
Object.entries(currentCartData).forEach(([key, value]) => {
Object.entries(currentCartData).forEach(([uuid, currentData]) => {
verifiedItems.forEach((verifiedItem: Item) => {
if (verifiedItem.uuid === key) {
console.log(verifiedItem, key);
newCartData[key] = {
uuid: value.uuid,
amount: value.amount,
if (verifiedItem.uuid === uuid) {
console.log(verifiedItem, uuid);
newCartData[uuid] = {
amount: currentData.amount,
data: verifiedItem,
};
}

View file

@ -7,65 +7,65 @@ const TestData: Item[] = [
name: "Bar of Soap",
price: 69.99,
labels: [Labels.vegan, Labels.spicy],
detail: "Example",
description: "Example",
},
{
uuid: "sock",
name: "Sock",
price: 21,
labels: [Labels.vegan, Labels.fish, Labels.nut, Labels.spicy],
detail: "Example",
description: "Example",
},
{
uuid: "brick",
name: "Brick",
price: 0,
labels: [Labels.spicy],
detail: "Example",
description: "Example",
},
{
uuid: "toast",
name: "Toast",
price: 4382749832743,
labels: [Labels.gluten],
detail: "Example",
description: "Example",
},
{
uuid: "water",
name: "water",
price: 1,
labels: [Labels.fish],
detail: "Example",
description: "Example",
},
{
uuid: "mouldy_bread",
name: "half eaten mouldy bread",
price: -99,
labels: [Labels.nut],
detail: "Example",
description: "Example",
},
{
uuid: "gwagwa",
name: "GwaGwa",
price: 69,
labels: [Labels.nut],
image: "/dab.jpg",
images: ["/dab.jpg"],
},
{
uuid: "hogmelon",
name: "Hogermellon",
price: 1111,
labels: [Labels.fish],
image: "/wathog.jpg",
detail: "Example",
images: ["/wathog.jpg"],
description: "Example",
},
{
uuid: "bluhog",
name: "Blue HOGGGGG",
price: 0,
labels: [Labels.nut, Labels.gluten, Labels.spicy],
image: "/sonichog.jpg",
detail: "Example",
images: ["/sonichog.jpg"],
description: "Example",
},
];

View file

@ -10,15 +10,13 @@ export interface Item {
uuid: string;
name: string;
price: number;
detail?: string;
labels: Labels[];
image?: string;
description?: string;
images?: string[];
}
// UUID is stored in both Item and CartItem, this isn't the best, I don't like it
// But it's the simplest way of doing this shit
export interface CartItem {
uuid: string;
amount: number;
data: Item;
}