Skip to content

Commit

Permalink
photo url fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aapatni committed Mar 14, 2024
1 parent a693466 commit c2722b3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/app/src/components/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ function PriceFilter( ) {
const [isInvalid, setIsInvalid] = useState(false);
useEffect(() => {
setIsInvalid(filterMinPrice < 0 || filterMinPrice > filterMaxPrice);
console.log(filterMinPrice, filterMaxPrice);
}, [filterMinPrice, filterMaxPrice]);
return (
<Box sx={{ display: "flex", gap: 2 }}>
Expand Down
23 changes: 15 additions & 8 deletions src/app/src/components/WatchCard.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
import React, { useState, useEffect, useCallback } from "react";
import React from "react";
import {
Card,
CardMedia,
CardContent,
Typography,
Box,
Chip,
} from "@mui/material";
import watchImage from "../assets/watch.webp";

function WatchCard({ watch, onClick }) {
const getImageUrl = () => {
if (!watch["Photo_URL"] || watch["Photo_URL"] === "") {
return watchImage; // Default image when Photo_URL is null or empty
}
if (watch["Photo_URL"].includes("i.redd.it")) {
return watch["Photo_URL"];
} else if (watch["Photo_URL"].includes("preview.redd.it")) {
return watch["Photo_URL"];
} else {
return watchImage;
}
};

return (
<Card
className="watch-card"
Expand All @@ -29,11 +41,7 @@ function WatchCard({ watch, onClick }) {
maxWidth: "100%",
margin: "auto",
}}
image={
watch["Photo_URL"].includes("i.redd.it")
? watch["Photo_URL"]
: watchImage
}
image={getImageUrl()}
alt={watch.Model}
/>
<Chip
Expand All @@ -48,7 +56,6 @@ function WatchCard({ watch, onClick }) {
display: "flex",
flexDirection: "column",
alignItems: "start",
// justifyContent: "space-",
padding: "8px 12px !important"
}}
>
Expand Down
4 changes: 0 additions & 4 deletions src/app/src/components/WatchGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ function WatchGrid({ supabase }) {
const [selectedWatch, setSelectedWatch] = useState(null);

const handleOpenModal = useCallback((watch) => {
console.log("opening shit")
setModalOpen(true);
setSelectedWatch(watch);
}, []);

const handleCloseModal = useCallback(() => {
console.log("closing shit")

setModalOpen(false);
setSelectedWatch(null);
}, []);
Expand All @@ -34,7 +31,6 @@ function WatchGrid({ supabase }) {

useEffect(() => {
const fetchWatchesToRender = async () => {
console.log("entered fetch");
let { data, error } = await supabase.rpc("get_filtered_watches", {
p_brand: filterBrand,
p_min_diameter: filterMinDiameter,
Expand Down

0 comments on commit c2722b3

Please sign in to comment.