Skip to content
Closed
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
8 changes: 7 additions & 1 deletion frontend/src/pages/Individual-product-page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { faPenToSquare, faHeart as faHeartSolid } from "@fortawesome/free-solid-svg-icons";

Check warning on line 1 in frontend/src/pages/Individual-product-page.tsx

View workflow job for this annotation

GitHub Actions / Frontend check

Member 'faHeartSolid' of the import declaration should be sorted alphabetically
import { faHeart as faHeartRegular } from "@fortawesome/free-regular-svg-icons";

Check warning on line 2 in frontend/src/pages/Individual-product-page.tsx

View workflow job for this annotation

GitHub Actions / Frontend check

`@fortawesome/free-regular-svg-icons` import should occur before import of `@fortawesome/free-solid-svg-icons`
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useContext, useEffect, useState } from "react";
Expand All @@ -19,9 +19,10 @@
}>();
const [message, setMessage] = useState("");
const [isHovered, setIsHovered] = useState(false);
const [error, setError] = useState<String>();

Check failure on line 22 in frontend/src/pages/Individual-product-page.tsx

View workflow job for this annotation

GitHub Actions / Frontend check

Don't use `String` as a type. Use string instead
const [hasPermissions, setHasPermissions] = useState<boolean>(false);
const COOLDOWN = 60 * 24 * 1000 * 60;
const [isSubmitting, setIsSubmitting] = useState(false);
useEffect(() => {
if (!message) return;
const t = setTimeout(() => setMessage(""), 3000);
Expand Down Expand Up @@ -77,12 +78,16 @@
setMessage("Please wait before sending another interest email.");
return;
}

if (isSubmitting) {
return;
}
setIsSubmitting(true);
try {
const response = await post("/api/interestEmail", { consumerId: user?.uid, productId: id });
const result = await response.json();
if (!response.ok) {
setMessage(`Error: ${result.message}`);
setIsSubmitting(false);
return;
}

Expand All @@ -97,6 +102,7 @@
}, COOLDOWN);
} catch {
setMessage("An unexpected error occurred.");
setIsSubmitting(false);
}
};
const isCooling = Boolean(cooldownEnd && Date.now() < cooldownEnd);
Expand All @@ -105,10 +111,10 @@
const totalMinutes = Math.ceil(msLeft / (1000 * 60)); // convert ms → minutes
const hoursLeft = Math.floor(totalMinutes / 60);
const minutesLeft = totalMinutes % 60;
const [tick, setTick] = useState(0);

Check failure on line 114 in frontend/src/pages/Individual-product-page.tsx

View workflow job for this annotation

GitHub Actions / Frontend check

'tick' is assigned a value but never used. Allowed unused elements of array destructuring patterns must match /^_/u
useEffect(() => {
if (!isCooling) return;
const iv = setInterval(() => setTick((t) => t + 1), 60_000); // 60 000 ms = 1 min

Check failure on line 117 in frontend/src/pages/Individual-product-page.tsx

View workflow job for this annotation

GitHub Actions / Frontend check

Irregular whitespace not allowed

Check failure on line 117 in frontend/src/pages/Individual-product-page.tsx

View workflow job for this annotation

GitHub Actions / Frontend check

Irregular whitespace not allowed

Check failure on line 117 in frontend/src/pages/Individual-product-page.tsx

View workflow job for this annotation

GitHub Actions / Frontend check

Irregular whitespace not allowed
return () => clearInterval(iv);
}, [isCooling]);
let buttonLabel = "Interested?";
Expand Down Expand Up @@ -137,7 +143,7 @@
const userRes = await get(`/api/users/${user.uid}`);
const userData = await userRes.json();
setIsSaved(userData.savedProducts.includes(id));
} catch (error) {

Check failure on line 146 in frontend/src/pages/Individual-product-page.tsx

View workflow job for this annotation

GitHub Actions / Frontend check

'error' is already declared in the upper scope on line 22 column 10
console.error("Error saving product:", error);
}
};
Expand Down Expand Up @@ -207,7 +213,7 @@
</div>
)}
{!hasPermissions && (
<div

Check failure on line 216 in frontend/src/pages/Individual-product-page.tsx

View workflow job for this annotation

GitHub Actions / Frontend check

Avoid non-native interactive elements. If using native HTML is not possible, add an appropriate role and support for tabbing, mouse, keyboard, and touch inputs to an interactive content element
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
>
Expand Down
Loading