Skip to content

Commit

Permalink
Add video reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
vpodk committed Jan 28, 2024
1 parent 911d18b commit 020d725
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/app/components/search/results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,58 @@ export default function SearchResults() {
/>
</div>
</div>

<Card title="Active Ingredients">
<div>{product.key_ingredient_benefits}</div>
</Card>

<Card title="Social Media">
<div className="flex flex-col items-center">
<Videos product={product} />
</div>
</Card>
</div>
);
}

const Videos = ({ product }: { product: Product }) => {
const videos = [
product.dupe_video_reference_link_1,
product.dupe_video_reference_link_2,
product.dupe_video_reference_link_3,
].map((video) => {
if (video && video.startsWith("http")) {
try {
// "https://www.youtube.com/shorts/qwerty",
let id = video.split("/shorts/")[1];
if (!id) {
// "https://www.youtube.com/watch?v=aaa&pp=bbb"
id = new URLSearchParams(video.split("?")[1]).get("v");
}
const src = "https://www.youtube.com/embed/" + id;
return (
<iframe
className="m-6 w-3/5 min-h-96"
allowFullScreen
src={src}
></iframe>
);
} catch (ex) {}
}
return null;
});
return videos;
};

const Card = ({ title, children }: { title: string; children: any }) => (
<div className="bg-white my-4 rounded-lg">
<h4 className="font-semibold text-2xl p-4 border-b border-b-gray-300">
{title}
</h4>
<div className="p-4">{children}</div>
</div>
);

const ProductAlternatives = ({
products,
product,
Expand Down

0 comments on commit 020d725

Please sign in to comment.