diff options
author | Biswakalyan Bhuyan <biswa@surgot.in> | 2024-07-26 21:35:30 +0530 |
---|---|---|
committer | Biswakalyan Bhuyan <biswa@surgot.in> | 2024-07-26 21:35:30 +0530 |
commit | e9d14a0a516217da02e1ef8a6e1dc78e46116b18 (patch) | |
tree | a38d09f714856f11724d10acb77692704278a109 /src/pages | |
parent | 55aed6d7c2df0daedbdabea0d1727acb1815ce2b (diff) | |
download | admin-panel-e9d14a0a516217da02e1ef8a6e1dc78e46116b18.tar.gz admin-panel-e9d14a0a516217da02e1ef8a6e1dc78e46116b18.tar.bz2 admin-panel-e9d14a0a516217da02e1ef8a6e1dc78e46116b18.zip |
fetching the content from firebase
Diffstat (limited to 'src/pages')
-rw-r--r-- | src/pages/ManageAds.jsx | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/pages/ManageAds.jsx b/src/pages/ManageAds.jsx index 88fc3b0..8f72d0f 100644 --- a/src/pages/ManageAds.jsx +++ b/src/pages/ManageAds.jsx @@ -2,10 +2,13 @@ import React, { useState, useEffect } from 'react'; import AdCard from '../components/AdCard'; import AdForm from '../components/AdForm'; import UploadForm from '../components/UploadForm'; +import ViewAds from '../components/ViewAds'; import { fetchAds, addAd } from '../utils/api'; const ManageAds = () => { const [ads, setAds] = useState([]); + const [showUploadedAds, setShowUploadedAds] = useState(false); + const [uploadedUrls, setUploadedUrls] = useState([]); useEffect(() => { const getAds = async () => { @@ -20,9 +23,12 @@ const ManageAds = () => { setAds([...ads, ad]); }; + const toggleViewAds = () => { + setShowUploadedAds(!showUploadedAds); + }; + const handleUploadComplete = (url) => { - console.log('Uploaded file URL:', url); - // You can add logic here to save the uploaded file URL to your backend if needed + setUploadedUrls([...uploadedUrls, url]); }; return ( @@ -30,11 +36,18 @@ const ManageAds = () => { <h1>Manage Ads</h1> <AdForm onAddAd={handleAddAd} /> <UploadForm onUploadComplete={handleUploadComplete} /> - <div> - {ads.map((ad) => ( - <AdCard key={ad.id} ad={ad} /> - ))} - </div> + <button onClick={toggleViewAds}> + {showUploadedAds ? 'Hide Uploaded Ads' : 'View Uploaded Ads'} + </button> + {showUploadedAds ? ( + <ViewAds /> + ) : ( + <div> + {ads.map((ad) => ( + <AdCard key={ad.id} ad={ad} /> + ))} + </div> + )} </div> ); }; |