diff --git a/src/__tests__/CustomWishlistModal.test.tsx b/src/__tests__/CustomWishlistModal.test.tsx index 94132dd..600e820 100644 --- a/src/__tests__/CustomWishlistModal.test.tsx +++ b/src/__tests__/CustomWishlistModal.test.tsx @@ -25,7 +25,7 @@ describe("CustomWishlistModal", () => { expect(screen.getByLabelText(/Add the name/i)).toBeInTheDocument(); expect(screen.getByLabelText(/Add the description/i)).toBeInTheDocument(); - expect(screen.getByLabelText(/Price:/i)).toBeInTheDocument(); + expect(screen.getByLabelText(/Price \(RON\):/i)).toBeInTheDocument(); expect(screen.getByLabelText(/Add a note/i)).toBeInTheDocument(); expect(screen.getByLabelText(/Quantity:/i)).toBeInTheDocument(); expect(screen.getByLabelText(/Priority:/i)).toBeInTheDocument(); @@ -55,7 +55,7 @@ describe("CustomWishlistModal", () => { target: { value: "A useful item" }, }); - fireEvent.change(screen.getByLabelText(/Price:/i), { + fireEvent.change(screen.getByLabelText(/Price \(RON\):/i), { target: { value: "49.99" }, }); diff --git a/src/components/CustomWishlistModal.tsx b/src/components/CustomWishlistModal.tsx index c18f150..bf21a1c 100644 --- a/src/components/CustomWishlistModal.tsx +++ b/src/components/CustomWishlistModal.tsx @@ -118,10 +118,10 @@ export default function CustomWishlistModal({ /> setPrice(String(e.target.value))} diff --git a/src/components/WishlistView.tsx b/src/components/WishlistView.tsx index 69b534d..5a7d2cd 100644 --- a/src/components/WishlistView.tsx +++ b/src/components/WishlistView.tsx @@ -318,7 +318,7 @@ const Wishlist: React.FC = ({ >
- ${item.contribution.current} of $ + RON{item.contribution.current} of RON {item.contribution.total}
diff --git a/src/pages/api/item-create.ts b/src/pages/api/item-create.ts index 62878e6..28ae201 100644 --- a/src/pages/api/item-create.ts +++ b/src/pages/api/item-create.ts @@ -34,7 +34,21 @@ export default async function handler( description: description, imagesUrl: photo, imagesKey: key, - price: stripCurrency(price), + price: (() => { + if (null === price) { + return null; + } + + if (typeof price === "string" && price.trim().endsWith("USD")) { + const numericPart = price.trim().slice(0, -3).trim(); + const value = parseFloat(numericPart); + if (!isNaN(value)) { + return value * 4.4; + } + } + + return Number(stripCurrency(price)); + })(), retailerId: retailer, }, }); diff --git a/src/pages/wishlist-create.tsx b/src/pages/wishlist-create.tsx index 51855db..c0e9f9d 100644 --- a/src/pages/wishlist-create.tsx +++ b/src/pages/wishlist-create.tsx @@ -18,7 +18,6 @@ import styles from "../styles/WishlistPage.module.css"; import buttonStyles from "../styles/Button.module.css"; import loadingStyles from "../styles/wishlistcomponent.module.css"; import "./../styles/globals.css"; -import ebayLogo from "./../../public/illustrations/ebay-logo.png"; type ItemCreateResponse = { itemId: number;