Fix Tim Mathias Wall coding

This commit is contained in:
FlorianSpeicher
2025-06-11 15:14:54 +02:00
parent 9b1f900aef
commit 8ff98defa3
2 changed files with 5 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
import React, { createContext, useContext, useState } from 'react';
import Item from '../components/Item';
interface BasketItem {
export interface BasketItem {
item: Item;
quantity: number;
}

View File

@@ -14,11 +14,12 @@ import {
TextField,
Typography
} from '@mui/material';
import { TFunction } from 'i18next';
import React, { useState } from 'react';
import { useTranslation } from "react-i18next";
import { useNavigate } from 'react-router-dom';
import { useBasket } from '../helper/BasketProvider';
import Item from '../components/Item';
import { BasketItem, useBasket } from '../helper/BasketProvider';
type ShippingDetails = {
firstName: string;
@@ -34,7 +35,7 @@ function getDiscountedPrice(item: Item): number {
return (item.price100 / 100 * (100-item.discount100)/100);
}
function generateBasket(t: any, basket: any[]) {
function generateBasket(t: TFunction<"translation", undefined>, basket: BasketItem[]) {
return basket.length === 0 ? (
<Typography color="error" sx={{ my: 2 }}>
{t('basketEmpty')}
@@ -58,7 +59,7 @@ function generateBasket(t: any, basket: any[]) {
)
}
function generateTotal(t: any, basket: any[]) {
function generateTotal(t: TFunction<"translation", undefined>, basket: BasketItem[]) {
return basket.length === 0 ? "" :
<div className='rightBound'>
{t('total') + ": " + basket.map((item) => item.quantity * getDiscountedPrice(item.item))