From 50520c0195d84dbf37147f8267bcf604399ae369 Mon Sep 17 00:00:00 2001
From: Mike Velko <44818580+mikevelko@users.noreply.github.com>
Date: Sun, 25 Aug 2024 09:03:50 +0200
Subject: [PATCH] regenerated models refactor and bugfixes (#122)
---
src/app/archive/page.tsx | 3 +--
src/app/page.tsx | 15 ++++++++-------
src/components/forms/NewOrderForm/index.tsx | 9 ++++-----
src/components/sections/Cart/CartItemRow.tsx | 15 ++++++++-------
.../sections/Cart/CartProductsList/index.tsx | 11 +++++------
.../sections/Cart/ProductAmountButtons.tsx | 8 ++------
src/components/sections/Common/Size.tsx | 8 ++++++++
7 files changed, 36 insertions(+), 33 deletions(-)
create mode 100644 src/components/sections/Common/Size.tsx
diff --git a/src/app/archive/page.tsx b/src/app/archive/page.tsx
index f9087c96..9f664851 100644
--- a/src/app/archive/page.tsx
+++ b/src/app/archive/page.tsx
@@ -34,8 +34,7 @@ export default async function Page() {
{a.archive?.archiveBody?.heading}
@@ -26,16 +25,18 @@ export default function CartItemRow({
{product.productName}
{product.color}
- {/* // TO-DO map size id */}
-
{product.orderItem?.sizeId}
+
+ {product.orderItem?.sizeId && (
+
+ )}
+
- {product.id !== undefined && basicCurrencyValue && (
+ {product.orderItem?.productId !== undefined && (
diff --git a/src/components/sections/Cart/CartProductsList/index.tsx b/src/components/sections/Cart/CartProductsList/index.tsx
index 599804cb..6935f52b 100644
--- a/src/components/sections/Cart/CartProductsList/index.tsx
+++ b/src/components/sections/Cart/CartProductsList/index.tsx
@@ -1,13 +1,10 @@
+import { addCartProduct, clearCartProducts } from "@/actions/cart";
import Button from "@/components/ui/Button";
import { serviceClient } from "@/lib/api";
+import { getValidateOrderItemsInsertItems } from "@/lib/utils/cart";
import Link from "next/link";
import CartItemRow from "../CartItemRow";
-import {
- getCartProductIdAndSizeFromKey,
- getCookieCart,
- getValidateOrderItemsInsertItems,
-} from "@/lib/utils/cart";
-import { clearCartProducts, addCartProduct } from "@/actions/cart";
+import SelectedCurrency from "../TotalPrice/SelectedCurrency";
import HACK__UpdateCookieCart from "./HACK__UpdateCookieCart";
export default async function CartProductsList() {
@@ -55,6 +52,8 @@ export default async function CartProductsList() {
))}
+
total:
+
);
}
diff --git a/src/components/sections/Cart/ProductAmountButtons.tsx b/src/components/sections/Cart/ProductAmountButtons.tsx
index eaf39c34..de1d6991 100644
--- a/src/components/sections/Cart/ProductAmountButtons.tsx
+++ b/src/components/sections/Cart/ProductAmountButtons.tsx
@@ -8,17 +8,14 @@ type Props = {
id,
size,
operation,
- price,
}: {
id: number;
size: string;
- price: number;
operation: "increase" | "decrease";
}) => void;
removeProduct: ({ id, size }: { id: number; size: string }) => void;
id: number;
size: string;
- price: number;
};
export default function ProductAmountButtons({
@@ -26,7 +23,6 @@ export default function ProductAmountButtons({
removeProduct,
id,
size,
- price,
}: Props) {
// todo: check if product is in stock
@@ -38,7 +34,7 @@ export default function ProductAmountButtons({
onClick={(e: React.MouseEvent
) => {
e.preventDefault();
- changeProductAmount({ id, size, operation: "increase", price });
+ changeProductAmount({ id, size, operation: "increase" });
}}
>
[+]
@@ -48,7 +44,7 @@ export default function ProductAmountButtons({
onClick={(e: React.MouseEvent) => {
e.preventDefault();
- changeProductAmount({ id, size, operation: "decrease", price });
+ changeProductAmount({ id, size, operation: "decrease" });
}}
>
[-]
diff --git a/src/components/sections/Common/Size.tsx b/src/components/sections/Common/Size.tsx
new file mode 100644
index 00000000..5589f2cf
--- /dev/null
+++ b/src/components/sections/Common/Size.tsx
@@ -0,0 +1,8 @@
+"use client";
+import { useHeroContext } from "@/components/contexts/HeroContext";
+
+export default function Size({ sizeId }: { sizeId: number }) {
+ const { dictionary } = useHeroContext();
+
+ return <>{dictionary?.sizes?.find((size) => size.id === sizeId)?.name}>;
+}