diff --git a/01-frontend/public/locales/de/translation.json b/01-frontend/public/locales/de/translation.json index 3ecb10b..f090ece 100644 --- a/01-frontend/public/locales/de/translation.json +++ b/01-frontend/public/locales/de/translation.json @@ -94,5 +94,6 @@ "thanksForRating": "Vielen Dank für die Bewertung!", "telephone": "Telefon", "basketEmpty": "Der Warenkorb ist leer.", - "login": "Anmelden" + "login": "Anmelden", + "total": "Insgesamt" } diff --git a/01-frontend/public/locales/en/translation.json b/01-frontend/public/locales/en/translation.json index c9371c8..06f0274 100644 --- a/01-frontend/public/locales/en/translation.json +++ b/01-frontend/public/locales/en/translation.json @@ -94,5 +94,6 @@ "thanksForRating": "Thank you for rating!", "telephone": "Telephone", "basketEmpty": "The shopping cart is empty.", - "login": "Login" + "login": "Login", + "total": "Total" } diff --git a/01-frontend/src/pages/Payment.tsx b/01-frontend/src/pages/Payment.tsx index 8baff7d..bd2eaf7 100644 --- a/01-frontend/src/pages/Payment.tsx +++ b/01-frontend/src/pages/Payment.tsx @@ -18,6 +18,7 @@ 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'; type ShippingDetails = { firstName: string; @@ -29,6 +30,10 @@ type ShippingDetails = { country: string; }; +function getDiscountedPrice(item: Item): number { + return (item.price100 / 100 * (100-item.discount100)/100); +} + export default function Payment() { @@ -102,9 +107,14 @@ export default function Payment() { {basket.map((item) => ( + +
+ {`${(item.quantity * getDiscountedPrice(item.item)).toFixed(2)} €`}
+ {item.item.discount100 > 0 ? {-item.item.discount100}% : ""} +
))} @@ -113,6 +123,11 @@ export default function Payment() { + {basket.length === 0 ? "" : +
+ {t('total') + ": " + basket.map((item) => item.quantity * getDiscountedPrice(item.item)) + .reduce((prev: number, cur: number) => prev + cur, 0).toFixed(2) + ` €`} +
} ); case 1: diff --git a/01-frontend/src/pages/pages.css b/01-frontend/src/pages/pages.css index 1cbb413..343eb4f 100644 --- a/01-frontend/src/pages/pages.css +++ b/01-frontend/src/pages/pages.css @@ -154,3 +154,10 @@ background-color: var(--background-color); color: var(--text-color); } + +.rightBound { + float: right; +} +.red { + color: #F00; +}