diff options
author | Biswakalyan Bhuyan <biswa@surgot.in> | 2024-07-26 21:21:03 +0530 |
---|---|---|
committer | Biswakalyan Bhuyan <biswa@surgot.in> | 2024-07-26 21:21:03 +0530 |
commit | 55aed6d7c2df0daedbdabea0d1727acb1815ce2b (patch) | |
tree | 42dabdc4f68bd01867cd84c4a9beaa6a14ffb9c2 /src/components/ViewAds.jsx | |
parent | 4833cc911b004b3da476863ddf27e09d93dd89c0 (diff) | |
download | admin-panel-55aed6d7c2df0daedbdabea0d1727acb1815ce2b.tar.gz admin-panel-55aed6d7c2df0daedbdabea0d1727acb1815ce2b.tar.bz2 admin-panel-55aed6d7c2df0daedbdabea0d1727acb1815ce2b.zip |
added upload feature
Diffstat (limited to 'src/components/ViewAds.jsx')
-rw-r--r-- | src/components/ViewAds.jsx | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/components/ViewAds.jsx b/src/components/ViewAds.jsx new file mode 100644 index 0000000..719d1b2 --- /dev/null +++ b/src/components/ViewAds.jsx @@ -0,0 +1,33 @@ +import React, { useEffect, useState } from 'react'; +import { ref, listAll, getDownloadURL } from 'firebase/storage'; +import { storage } from '../firebase'; + +const ViewAds = () => { + const [ads, setAds] = useState([]); + + useEffect(() => { + const fetchAds = async () => { + const adsRef = ref(storage, 'ads/'); + const adList = await listAll(adsRef); + const adUrls = await Promise.all(adList.items.map((item) => getDownloadURL(item))); + setAds(adUrls); + }; + + fetchAds(); + }, []); + + return ( + <div> + <h2>View Ads</h2> + <div> + {ads.map((url, index) => ( + <div key={index}> + <img src={url} alt={`Ad ${index + 1}`} style={{ maxWidth: '200px' }} /> + </div> + ))} + </div> + </div> + ); +}; + +export default ViewAds; |