Compare commits

...

2 Commits

Author SHA1 Message Date
e7fda0497e Merge pull request 'removed the title and modified the change calcluator' (#3) from dev into main
All checks were successful
Build, Publish Docker Image, and Deploy to Kubernetes / build_and_push (push) Successful in 15s
Build, Publish Docker Image, and Deploy to Kubernetes / deploy_to_k8s (push) Successful in 11s
Reviewed-on: #3
2025-06-16 07:17:49 +00:00
Jonas Hinterdorfer
8c8d8d5732 removed the title and modified the change calcluator 2025-06-16 09:17:20 +02:00
2 changed files with 11 additions and 4 deletions

View File

@ -34,7 +34,8 @@ const ChangeCalculatorPage: React.FC = () => {
useEffect(() => {
const total = moneyItems.reduce((sum, item) => sum + item.value * item.count, 0);
setCustomerTotal(total);
setChangeAmount(Math.max(0, total - cartTotal));
// Allow negative values when customer hasn't paid enough
setChangeAmount(total - cartTotal);
}, [moneyItems, cartTotal]);
const handleDenominationClick = (index: number) => {
@ -90,7 +91,14 @@ const ChangeCalculatorPage: React.FC = () => {
</div>
<div className="total-item highlight">
<span>Restgeld:</span>
<span>{changeAmount.toFixed(2)} </span>
<span
style={{
color: changeAmount < 0 ? '#ff0000' : 'inherit',
fontWeight: changeAmount < 0 ? 'bold' : 'inherit'
}}
>
{changeAmount.toFixed(2)}
</span>
</div>
</div>

View File

@ -39,8 +39,7 @@ const HomePage: React.FC = () => {
</button>
</div>
<h2 className="section-title">{activeTab === 'food' ? 'Essen' : 'Getränke'}</h2>
<ProductList
<ProductList
products={productsData[activeTab]}
category={activeTab}
/>