Skip to content

Commit

Permalink
Update video reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
vpodk committed Jan 28, 2024
1 parent 7c0e4e2 commit 8ac4ce4
Showing 1 changed file with 32 additions and 36 deletions.
68 changes: 32 additions & 36 deletions src/app/components/search/results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,52 +68,48 @@ export default function SearchResults() {
}

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


if (videos.length) {
return (
<Card title="Social Media">
<div className="flex flex-col items-center">
<Videos product={product} />
{videos}
</div>
</Card>
);
}
return null;
};

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((url) => {
if (url && url.startsWith("http")) {
try {
// "https://www.youtube.com/shorts/qwerty",
let videoId = url.split("/shorts/")[1];
if (!videoId) {
// "https://www.youtube.com/watch?v=aaa&pp=bbb"
videoId = new URLSearchParams(url.split("?")[1]).get("v");
}
const src = "https://www.youtube.com/embed/" + videoId;
return (
<iframe
key={videoId}
className="m-6 w-3/5 min-h-96 rounded-xl"
allowFullScreen
src={src}
></iframe>
);
} catch (ex) {}
}
return null;
});
return videos;
};

const ProductAlternatives: any = ({
products,
product,
Expand Down

0 comments on commit 8ac4ce4

Please sign in to comment.