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 ( <> - + - {data.map((d) => { - return ( -
-
-
- -

{d.authorname}

-
-
-
-
-
+
+
+ {data.map((d) => ( +
+
+
... +
{d.authorname}
-
-
-
{d.title}
-

{d.short}

-
+
+
{d.title}
+

{d.short}

+
+ + View more + + -
-

- - Last updated 3 mins ago - -

+ Delete +
+
+ Last updated 3 mins ago +
-
- ); - })} + ))} +
+
); } diff --git a/src/components/Login.jsx b/src/components/Login.jsx index 03e7c70..d45b8fe 100644 --- a/src/components/Login.jsx +++ b/src/components/Login.jsx @@ -1,40 +1,77 @@ + import { useNavigate } from 'react-router-dom'; import { signInWithPopup, GoogleAuthProvider } from 'firebase/auth'; import { auth } from '../firebase'; function Login() { - const navigate=useNavigate(); + const navigate = useNavigate(); + const handleGoogle = async (e) => { e.preventDefault(); try { const provider = new GoogleAuthProvider(); const result = await signInWithPopup(auth, provider); console.log(result); - navigate('/blogs') + navigate('/blogs'); } catch (error) { console.log(error); } } return ( -
- +
+
); } +const styles = { + container: { + display: 'flex', + justifyContent: 'center', + alignItems: 'center', + height: '100vh', + }, + button: { + display: 'flex', + alignItems: 'center', + backgroundColor: 'white', + padding: '10px 20px', + border: '2px solid #0b131b', + borderRadius: '8px', + cursor: 'pointer', + boxShadow: '0 4px 6px rgba(0, 0, 0, 0.1)', + transition: 'all 0.3s ease', + }, + iconContainer: { + width: '30px', + marginRight: '10px', + }, + icon: { + width: '100%', + }, + textContainer: { + display: 'flex', + alignItems: 'center', + }, + text: { + fontWeight: 'bold', + background: 'linear-gradient(90deg, #0b131b, #010f1b)', + WebkitBackgroundClip: 'text', + WebkitTextFillColor: 'transparent', + margin: 0, + }, +}; + export default Login; diff --git a/src/index.css b/src/index.css index e5ec2ef..cb1c139 100644 --- a/src/index.css +++ b/src/index.css @@ -14,4 +14,61 @@ overflow-x: hidden; .navi .btn:hover{ font-size: larger; -} \ No newline at end of file +} +/* Blogs.css */ +.card-header { + background-color: #f8f9fa; + border-bottom: 1px solid #e9ecef; +} + +.author-img { + height: 40px; + width: 40px; +} + +.author-name { + font-size: 1rem; + font-weight: bold; +} + +.card-title { + font-size: 1.25rem; + font-weight: bold; +} + +.card-footer { + font-size: 0.875rem; +} + +.card-body { + padding: 1rem; +} + +.card-img-top { + height: 200px; + object-fit: cover; +} + +.card { + border-radius: 0.5rem; + overflow: hidden; +} + +.btn-primary, .btn-danger { + flex-grow: 1; + margin: 0 0.25rem; +} + +@media (max-width: 768px) { + .card-img-top { + height: 150px; + } + + .card-title { + font-size: 1rem; + } + + .card-footer { + font-size: 0.75rem; + } +}