import React, { useState, useEffect } from 'react'; import { db } from '../firebase'; import { collection, addDoc, getDocs } from 'firebase/firestore'; import './ManageAds.css'; import Navbar from '../components/Navbar'; const ManageAds = () => { const [ads, setAds] = useState([]); const [newAd, setNewAd] = useState({ title: '', description: '', imageUrl: '' }); useEffect(() => { fetchAds(); }, []); const fetchAds = async () => { const querySnapshot = await getDocs(collection(db, 'ads')); const adsData = querySnapshot.docs.map(doc => doc.data()); setAds(adsData); }; const handleAddAd = async () => { await addDoc(collection(db, 'ads'), newAd); fetchAds(); }; return (

Manage Ads

setNewAd({ ...newAd, title: e.target.value })} className="form-control" />
setNewAd({ ...newAd, description: e.target.value })} className="form-control" />
setNewAd({ ...newAd, imageUrl: e.target.value })} className="form-control" />
{ads.map((ad, index) => (
{ad.title}

{ad.description}

{ad.title}
))}
); }; export default ManageAds;