import React, { useState, useEffect } from 'react'; import { db } from '../firebase'; import { collection, addDoc, getDocs } from 'firebase/firestore'; 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 (
{ad.description}