Skip to content

Commit

Permalink
Fix single post bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tanish35 committed Oct 13, 2024
1 parent b87ba31 commit 0d20912
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion frontend/src/components/SinglePost.jsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -12,6 +12,7 @@ import {
Spinner,
Center,
VStack,
useToast,
} from "@chakra-ui/react";
import { gsap } from "gsap";
import axios from "axios";
Expand All @@ -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 () => {
Expand Down Expand Up @@ -72,6 +74,12 @@ const SinglePost = () => {
}

if (!userDetails) {
toast({
title: "Please login to view this page",
status: "error",
duration: 5000,
isClosable: true,
});
return <Navigate to="/login" />;
}
if (userDetails.username === null) {
Expand Down

0 comments on commit 0d20912

Please sign in to comment.