From 819ab4116f9113c7ac2f7765c14deb73526ee15e Mon Sep 17 00:00:00 2001 From: carlevison Date: Mon, 9 Dec 2024 16:33:27 +0000 Subject: [PATCH 1/8] Working without moderation --- app/cloudinary-video-player.tsx | 71 +++ app/config/cloudinary.ts | 4 +- app/globals.css | 79 ++- app/layout.tsx | 3 +- app/page.tsx | 165 +----- app/page_profile.tsx | 142 +++++ app/product-reviews.tsx | 130 +++++ app/types/cloudinary.d.ts | 15 + components.json | 21 + components/ui/button.tsx | 57 ++ components/ui/card.tsx | 76 +++ components/ui/textarea.tsx | 22 + lib/utils.ts | 6 + package-lock.json | 985 +++++++++++++++++++++++++++----- package.json | 9 +- tailwind.config.ts | 60 +- 16 files changed, 1549 insertions(+), 296 deletions(-) create mode 100644 app/cloudinary-video-player.tsx create mode 100644 app/page_profile.tsx create mode 100644 app/product-reviews.tsx create mode 100644 app/types/cloudinary.d.ts create mode 100644 components.json create mode 100644 components/ui/button.tsx create mode 100644 components/ui/card.tsx create mode 100644 components/ui/textarea.tsx create mode 100644 lib/utils.ts diff --git a/app/cloudinary-video-player.tsx b/app/cloudinary-video-player.tsx new file mode 100644 index 0000000..f13fb01 --- /dev/null +++ b/app/cloudinary-video-player.tsx @@ -0,0 +1,71 @@ +'use client' + +import { useEffect, useRef, useState } from "react" + +interface CloudinaryVideoPlayerProps { + publicId: string +} + +export function CloudinaryVideoPlayer({ publicId }: CloudinaryVideoPlayerProps) { + const videoRef = useRef(null) + const [isScriptLoaded, setIsScriptLoaded] = useState(false) + + useEffect(() => { + if (!window.cloudinary || !window.cloudinary.videoPlayer) { + const script = document.createElement("script") + script.src = "https://unpkg.com/cloudinary-core@latest/cloudinary-core-shrinkwrap.min.js" + script.async = true + + script.onload = () => { + const videoPlayerScript = document.createElement("script") + videoPlayerScript.src = "https://unpkg.com/cloudinary-video-player@1.9.9/dist/cld-video-player.min.js" + videoPlayerScript.async = true + videoPlayerScript.onload = () => setIsScriptLoaded(true) + videoPlayerScript.onerror = (error) => console.error("Error loading Cloudinary Video Player script:", error) + document.head.appendChild(videoPlayerScript) + } + + script.onerror = (error) => console.error("Error loading Cloudinary Core script:", error) + document.head.appendChild(script) + + const link = document.createElement("link") + link.href = "https://unpkg.com/cloudinary-video-player@1.9.9/dist/cld-video-player.min.css" + link.rel = "stylesheet" + document.head.appendChild(link) + + return () => { + document.head.removeChild(script) + const videoPlayerScript = document.querySelector('script[src="https://unpkg.com/cloudinary-video-player@1.9.9/dist/cld-video-player.min.js"]') + if (videoPlayerScript) { + document.head.removeChild(videoPlayerScript) + } + document.head.removeChild(link) + } + } else { + setIsScriptLoaded(true) + } + }, []) + + useEffect(() => { + if (isScriptLoaded && videoRef.current && window.cloudinary && window.cloudinary.videoPlayer) { + const player = window.cloudinary.videoPlayer(videoRef.current, { + cloud_name: "cld-demo-ugc", + controls: true, + }) + player.source(publicId) + + return () => { + player.dispose() + } + } + }, [isScriptLoaded, publicId]) + + return ( +