diff --git a/.firebase/hosting.cHVibGlj.cache b/.firebase/hosting.cHVibGlj.cache
index 4276f3d..1fa7150 100644
--- a/.firebase/hosting.cHVibGlj.cache
+++ b/.firebase/hosting.cHVibGlj.cache
@@ -1,2 +1,2 @@
-vite.svg,1713955457734,59ec4b6085a0cb1bf712a5e48dd5f35b08e34830d49c2026c18241be04e05d5a
index.html,1718465250528,8e66b0905c08b14c069e3f9b1b867fafd21e64ef3c62bb98da65a79adcd9e3d0
+vite.svg,1713955457734,59ec4b6085a0cb1bf712a5e48dd5f35b08e34830d49c2026c18241be04e05d5a
diff --git a/firestore.rules b/firestore.rules
index d62b94b..e8f8d79 100644
--- a/firestore.rules
+++ b/firestore.rules
@@ -1,10 +1,7 @@
-rules_version = '2';
-
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
- allow read, write: if true;
- }
-
+ allow read, write: if request.auth != null;
+ }
}
}
diff --git a/src/components/Blogs.jsx b/src/components/Blogs.jsx
index 5f165ac..c33c4d5 100644
--- a/src/components/Blogs.jsx
+++ b/src/components/Blogs.jsx
@@ -1,134 +1,93 @@
+import React, { useEffect, useState } from "react";
+import { Link } from "react-router-dom";
import { db } from "../firebase";
import { onSnapshot, collection, doc, deleteDoc } from "firebase/firestore";
-import { useEffect, useState } from "react";
import Navbar from "./Navbar";
-import { Link } from "react-router-dom";
import { ToastContainer, toast } from 'react-toastify';
+import 'react-toastify/dist/ReactToastify.css'
-import 'react-toastify/dist/ReactToastify.css';
function Blogs() {
- const handleDelete = async (id) => {
- const data = doc(db, 'blog', id);
-
- toast.warn('Blog deleted successfully!', {
- position: "top-center",
- autoClose: 2000,
- hideProgressBar: false,
- closeOnClick: true,
- pauseOnHover: true,
- draggable: true,
- progress: undefined,
- theme: "dark",
- });
- setTimeout(async()=>{
- await deleteDoc(data);
- },2000)
-
- };
-
const [data, setData] = useState([]);
useEffect(() => {
const collectionRef = collection(db, "blog");
const unsubscribe = onSnapshot(collectionRef, (snapshot) => {
- setData(
- snapshot.docs.map((doc) => ({
- id: doc.id,
- ...doc.data(),
- }))
- );
+ setData(snapshot.docs.map((doc) => ({
+ id: doc.id,
+ ...doc.data(),
+ })));
});
-
+
return () => {
unsubscribe();
};
}, []);
- console.log(data);
+ const handleDelete = async (id) => {
+ const docRef = doc(db, 'blog', id);
+
+ toast.warn('Blog deleted successfully!', {
+ position: "top-center",
+ autoClose: 2000,
+ hideProgressBar: false,
+ closeOnClick: true,
+ pauseOnHover: true,
+ draggable: true,
+ progress: undefined,
+ theme: "dark",
+ });
+
+ setTimeout(async () => {
+ await deleteDoc(docRef);
+ }, 2000);
+ };
return (
<>
-
{d.short}
- +{d.short}
+- - Last updated 3 mins ago - -
+ Delete +