Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/__tests__/CustomWishlistModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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" },
});

Expand Down
4 changes: 2 additions & 2 deletions src/components/CustomWishlistModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ export default function CustomWishlistModal({
/>

<label htmlFor="price" className={modalStyles.priceLabel}>
Price:
Price (RON):
</label>
<input
type="string"
type="number"
id="price"
value={price ?? ""}
onChange={(e) => setPrice(String(e.target.value))}
Expand Down
2 changes: 1 addition & 1 deletion src/components/WishlistView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ const Wishlist: React.FC<WishlistProps> = ({
></div>
</div>
<div className={styles.contributionAmount}>
${item.contribution.current} of $
RON{item.contribution.current} of RON
{item.contribution.total}
</div>
</div>
Expand Down
16 changes: 15 additions & 1 deletion src/pages/api/item-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
});
Expand Down
1 change: 0 additions & 1 deletion src/pages/wishlist-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down