From 0b97888031c2daf1bfd892437341d033bd80a4c9 Mon Sep 17 00:00:00 2001 From: austinkelsay Date: Mon, 25 Nov 2024 17:13:01 -0600 Subject: [PATCH] fix video froms for cndition where we are serving free cdn video --- src/components/forms/CombinedResourceForm.js | 4 ++++ src/components/forms/VideoForm.js | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/components/forms/CombinedResourceForm.js b/src/components/forms/CombinedResourceForm.js index c3de223..d1fe238 100644 --- a/src/components/forms/CombinedResourceForm.js +++ b/src/components/forms/CombinedResourceForm.js @@ -20,6 +20,8 @@ const MDEditor = dynamic( { ssr: false } ); +const CDN_ENDPOINT = process.env.NEXT_PUBLIC_CDN_ENDPOINT; + const CombinedResourceForm = ({ draft = null, isPublished = false }) => { const [title, setTitle] = useState(draft?.title || ''); const [summary, setSummary] = useState(draft?.summary || ''); @@ -57,6 +59,8 @@ const CombinedResourceForm = ({ draft = null, isPublished = false }) => { } else if (url.includes('vimeo.com')) { const videoId = url.split('/').pop(); embedCode = `
`; + } else if (price && !price > 0 && (url.includes('.mp4') || url.includes('.mov') || url.includes('.avi') || url.includes('.wmv') || url.includes('.flv') || url.includes('.webm'))) { + embedCode = `
`; } else if (url.includes('.mp4') || url.includes('.mov') || url.includes('.avi') || url.includes('.wmv') || url.includes('.flv') || url.includes('.webm')) { const baseUrl = process.env.NEXT_PUBLIC_API_URL || "http://localhost:3000"; embedCode = `
`; diff --git a/src/components/forms/VideoForm.js b/src/components/forms/VideoForm.js index 05a081a..903033a 100644 --- a/src/components/forms/VideoForm.js +++ b/src/components/forms/VideoForm.js @@ -12,6 +12,8 @@ import 'primeicons/primeicons.css'; import { Tooltip } from 'primereact/tooltip'; import 'primereact/resources/primereact.min.css'; +const CDN_ENDPOINT = process.env.NEXT_PUBLIC_CDN_ENDPOINT; + // todo need to handle case where published video is being edited and not just draft const VideoForm = ({ draft = null }) => { const [title, setTitle] = useState(draft?.title || ''); @@ -61,6 +63,9 @@ const VideoForm = ({ draft = null }) => { const videoId = videoUrl.split('/').pop(); embedCode = `
`; } + else if (price && !price > 0 && (videoUrl.includes('.mp4') || videoUrl.includes('.mov') || videoUrl.includes('.avi') || videoUrl.includes('.wmv') || videoUrl.includes('.flv') || videoUrl.includes('.webm'))) { + embedCode = `
`; + } else if (videoUrl.includes('.mp4') || videoUrl.includes('.mov') || videoUrl.includes('.avi') || videoUrl.includes('.wmv') || videoUrl.includes('.flv') || videoUrl.includes('.webm')) { const baseUrl = process.env.NEXT_PUBLIC_API_URL || "http://localhost:3000"; const videoEmbed = `
`;