diff options
author | Biswakalyan Bhuyan <biswa@surgot.in> | 2024-08-01 17:49:26 +0530 |
---|---|---|
committer | Biswakalyan Bhuyan <biswa@surgot.in> | 2024-08-01 17:49:26 +0530 |
commit | bd933a5aace3ac4944bfe7f4b58b4908978b4950 (patch) | |
tree | b738f4c68d897c009ba7823d0e99f1f6b44a611d /src/components/ViewAds.jsx | |
parent | fb04271b5288e8fb5891b7d6326f4806d12b82d5 (diff) | |
download | admin-panel-bd933a5aace3ac4944bfe7f4b58b4908978b4950.tar.gz admin-panel-bd933a5aace3ac4944bfe7f4b58b4908978b4950.tar.bz2 admin-panel-bd933a5aace3ac4944bfe7f4b58b4908978b4950.zip |
merge
Diffstat (limited to 'src/components/ViewAds.jsx')
-rw-r--r-- | src/components/ViewAds.jsx | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/src/components/ViewAds.jsx b/src/components/ViewAds.jsx deleted file mode 100644 index e681989..0000000 --- a/src/components/ViewAds.jsx +++ /dev/null @@ -1,67 +0,0 @@ -import React, { useState, useEffect } from 'react'; -import { getDownloadURL, listAll, ref } from 'firebase/storage'; -import { storage } from '../firebase'; -import './ViewAds.css'; - -const ViewAds = () => { - const [urls, setUrls] = useState([]); - - useEffect(() => { - const fetchUrls = async () => { - const listRef = ref(storage, 'ads/'); - try { - const res = await listAll(listRef); - const urlsPromises = res.items.map(itemRef => getDownloadURL(itemRef)); - const urls = await Promise.all(urlsPromises); - setUrls(urls); - } catch (error) { - console.error('Error fetching URLs:', error); - } - }; - - fetchUrls(); - }, []); - - const getFileType = (url) => { - const fileExtension = url.split('?')[0].split('.').pop().toLowerCase(); - const imageExtensions = ['jpeg', 'jpg', 'gif', 'png']; - const videoExtensions = ['mp4', 'mov', 'avi', 'mkv']; - - if (imageExtensions.includes(fileExtension)) { - return 'image'; - } else if (videoExtensions.includes(fileExtension)) { - return 'video'; - } else { - return 'unsupported'; - } - }; - - return ( - <div> - <h2>Uploaded Ads</h2> - <div className="ads-container"> - {urls.map((url, index) => { - const fileType = getFileType(url); - console.log(`URL: ${url}, fileType: ${fileType}`); - - return ( - <div key={index} className="ad-item"> - {fileType === 'image' ? ( - <img src={url} alt={`Ad ${index + 1}`} style={{ maxWidth: '100%', height: 'auto' }} /> - ) : fileType === 'video' ? ( - <video controls style={{ maxWidth: '100%', height: 'auto' }}> - <source src={url} type={`video/${url.split('.').pop()}`} /> - Your browser does not support the video tag. - </video> - ) : ( - <p>Unsupported file type</p> - )} - </div> - ); - })} - </div> - </div> - ); -}; - -export default ViewAds; |