From 0d20912b91f13d7b2cf1f13b01a32ce3627e511b Mon Sep 17 00:00:00 2001 From: tanish35 Date: Sun, 13 Oct 2024 18:48:27 +0530 Subject: [PATCH] Fix single post bug --- frontend/src/components/SinglePost.jsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/SinglePost.jsx b/frontend/src/components/SinglePost.jsx index 8f166a2..a00f890 100644 --- a/frontend/src/components/SinglePost.jsx +++ b/frontend/src/components/SinglePost.jsx @@ -1,7 +1,7 @@ import React, { useEffect, useState } from "react"; import { GrLike } from "react-icons/gr"; import { AiFillLike } from "react-icons/ai"; -import { useParams } from "react-router-dom"; +import { useParams, Navigate } from "react-router-dom"; import { Box, Heading, @@ -12,6 +12,7 @@ import { Spinner, Center, VStack, + useToast, } from "@chakra-ui/react"; import { gsap } from "gsap"; import axios from "axios"; @@ -29,6 +30,7 @@ const SinglePost = () => { // Refs for the animations const likeButtonRef = React.useRef(null); const likeFloodRef = React.useRef(null); + const toast = useToast(); useEffect(() => { const fetchPost = async () => { @@ -72,6 +74,12 @@ const SinglePost = () => { } if (!userDetails) { + toast({ + title: "Please login to view this page", + status: "error", + duration: 5000, + isClosable: true, + }); return ; } if (userDetails.username === null) {