Login to view Post.
+ }
+ if (isFetching || isPending) {
+ return
{
const [hover, setHover] = useState(false)
const [activeItem, setActiveItem] = useState('')
const [, , deleteCookie] = useCookie('uni_user_token')
- const { userProfileData, userData, resetUserData, resetUserProfileData, resetUserFollowingData } = useUniStore()
+ const { userProfileData, userData, resetUserData, resetUserProfileData } = useUniStore()
const router = useRouter()
const { data: notificationData } = useGetNotification()
@@ -62,7 +62,6 @@ const Navbar: React.FC = () => {
deleteCookie()
resetUserData()
resetUserProfileData()
- resetUserFollowingData()
setIsLogin(false)
router.push('/login')
}
diff --git a/src/components/Timeline/Navbar.tsx b/src/components/Timeline/Navbar.tsx
index dc293d70..7619615b 100644
--- a/src/components/Timeline/Navbar.tsx
+++ b/src/components/Timeline/Navbar.tsx
@@ -3,6 +3,7 @@ import React from 'react'
import { CommunityNavbarLinks } from '@/types/constants'
import { useRouter, usePathname } from 'next/navigation'
import { useUniStore } from '@/store/store'
+import useCookie from '@/hooks/useCookie'
const Navbar: React.FC = () => {
// const tabs = ['Timeline', 'Profile', 'Notifications', 'Messages', 'Connections', 'University Community', 'Chatbot']
@@ -11,7 +12,11 @@ const Navbar: React.FC = () => {
const id = userData?.id
const path = usePathname()
const activeTab = path.split('/').pop()
+ const [cookieValue] = useCookie('uni_user_token')
+ if (!cookieValue) {
+ return
+ }
return (
diff --git a/src/components/Timeline/Post.tsx b/src/components/Timeline/Post.tsx
index 9caf7598..851a5206 100644
--- a/src/components/Timeline/Post.tsx
+++ b/src/components/Timeline/Post.tsx
@@ -9,6 +9,7 @@ import { FaBookmark } from 'react-icons/fa6'
// import { MdOutlineImage } from 'react-icons/md'
import { MdGifBox, MdOutlineBookmarkBorder } from 'react-icons/md'
import { HiReply, HiOutlineBell, HiOutlineFlag } from 'react-icons/hi'
+import { MdOutlineOpenInNew } from 'react-icons/md'
import { BiRepost } from 'react-icons/bi'
import { ModalContentType } from '@/types/global'
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/Popover'
@@ -31,6 +32,8 @@ import dayjs from 'dayjs'
import relativeTime from 'dayjs/plugin/relativeTime'
import { replaceImage } from '@/services/uploadImage'
import { PostCommentData, PostType } from '@/types/constants'
+import Link from 'next/link'
+import { Spinner } from '../spinner/Spinner'
dayjs.extend(relativeTime)
@@ -57,13 +60,20 @@ interface PostProps {
media?: []
saved?: boolean
isUniversity?: boolean
- postID?: string
+ postID: string
profileDp?: string
adminId: string
type: PostType
+ isType: string
+ isSinglePost?: boolean
}
-const PostOptions = () => {
+interface PostOptionType {
+ postID: string
+ isType: string
+}
+
+const PostOptions = ({ postID, isType }: PostOptionType) => {
return (
@@ -71,6 +81,12 @@ const PostOptions = () => {
+
Save Post
@@ -156,15 +172,18 @@ const Post: React.FC
= ({
profileDp,
adminId,
type,
+ isType,
+ isSinglePost,
}) => {
const { mutate: LikeUnlikeGroupPost } = useLikeUnilikeGroupPost()
const { mutate: LikeUnlikeTimelinePost } = useLikeUnlikeTimelinePost()
- const { mutate: CreateGroupPostComment } = useCreateGroupPostComment()
+ const { mutate: CreateGroupPostComment, isPending: CreateGroupPostCommentLoading } = useCreateGroupPostComment(isSinglePost ? isSinglePost : false)
const { mutate: likeGroupPostComment } = useLikeUnlikeGroupPostComment()
- const { mutate: CreateUserPostComment } = useCreateUserPostComment()
+ const { mutate: CreateUserPostComment, isPending: CreateUserPostCommentLoading } = useCreateUserPostComment(isSinglePost ? isSinglePost : false)
const { mutate: likeUserPostComment } = useLikeUnlikeUserPostComment()
const [comment, setComment] = useState('')
const [ImageValue, setImageValue] = useState(null)
+ const [isLoading, setIsLoading] = useState(false)
const [showCommentSec, setShowCommentsec] = useState(false)
const { userData } = useUniStore()
@@ -174,6 +193,7 @@ const Post: React.FC = ({
if (comment.length <= 1) {
return console.log('Please type something to comment!')
}
+ setIsLoading(true)
if (ImageValue) {
const imagedata: any = await replaceImage(ImageValue, '')
@@ -202,6 +222,9 @@ const Post: React.FC = ({
CreateGroupPostComment(data)
}
}
+ setIsLoading(false)
+ setImageValue(null)
+ setComment('')
}
const LikeUnlikeHandler = (postId: string) => {
@@ -251,7 +274,7 @@ const Post: React.FC = ({
{/* media div */}
@@ -334,9 +357,9 @@ const Post: React.FC
= ({
- {comment.length > 1 && (
+ {comment?.length > 1 && (
handlePostComment()} className="text-white bg-primary px-3 my-[2px] sm:px-3 sm:py-2 rounded-full text-sm">
- Post
+ {CreateGroupPostCommentLoading || CreateUserPostCommentLoading || isLoading ? : Post
}
)}
@@ -349,10 +372,10 @@ const Post: React.FC = ({
)}
- {userComments.length && showCommentSec ?
Most Relevant / Most Recent
: ''}
+ {userComments?.length && showCommentSec ?
Most Relevant / Most Recent
: ''}
{/* Comments Section */}
- {userComments.map((comment: any) => (
+ {userComments?.map((comment: any) => (
{/* Comment Info */}
@@ -401,7 +424,7 @@ const Post: React.FC
= ({
))}
- {userComments.length > 5 && showCommentSec ? View More Comments : ''}
+ {userComments?.length > 5 && showCommentSec ? View More Comments : ''}
diff --git a/src/components/Timeline/PostInput.tsx b/src/components/Timeline/PostInput.tsx
index 89ea0547..d4e3607d 100644
--- a/src/components/Timeline/PostInput.tsx
+++ b/src/components/Timeline/PostInput.tsx
@@ -13,6 +13,7 @@ import { useCreateGroupPost } from '@/services/community-university'
import { replaceImage } from '@/services/uploadImage'
import { useCreateUserPost } from '@/services/community-timeline'
import { CommunityPostData, PostInputData, PostInputType } from '@/types/constants'
+import { Spinner } from '../spinner/Spinner'
interface PostInputProps {
setModalContentType: React.Dispatch
>
setIsModalOpen: React.Dispatch>
@@ -24,8 +25,10 @@ interface PostInputProps {
const PostInput: React.FC = ({ setIsModalOpen, setModalContentType, idToPost, profileDp, type }) => {
const [inputValue, setInputValue] = useState('')
const [ImageValue, setImageValue] = useState([])
- const { mutate: CreateGroupPost } = useCreateGroupPost()
+ const [isLoading, setIsLoading] = useState(false)
+ const { mutate: CreateGroupPost, isPending } = useCreateGroupPost()
const { mutate: CreateTimelinePost } = useCreateUserPost()
+
const handleEmojiClick = (emojiData: any) => {
setInputValue((prevValue) => prevValue + emojiData.emoji)
}
@@ -44,6 +47,8 @@ const PostInput: React.FC = ({ setIsModalOpen, setModalContentTy
return console.log('Please type something to post!')
}
+ setIsLoading(true)
+
if (ImageValue) {
const imagedata = await processImages(ImageValue)
const data: PostInputData = {
@@ -74,6 +79,8 @@ const PostInput: React.FC = ({ setIsModalOpen, setModalContentTy
CreateTimelinePost(data)
}
}
+
+ setIsLoading(false)
}
return (
@@ -89,8 +96,12 @@ const PostInput: React.FC = ({ setIsModalOpen, setModalContentTy
value={inputValue}
onChange={(e) => setInputValue(e.target.value)}
/>
- handleGroupPost()} className="text-white bg-primary px-3 my-[2px] sm:px-3 sm:py-2 rounded-full text-sm">
- Post
+ handleGroupPost()}
+ className="text-white bg-primary px-3 my-[2px] sm:px-3 sm:py-2 rounded-full text-sm"
+ >
+ {isLoading || isPending ? : Post
}
{ImageValue && (
diff --git a/src/components/communityProfile/CommunityProfileContainer.tsx b/src/components/communityProfile/CommunityProfileContainer.tsx
index 5f75cf14..96d6da04 100644
--- a/src/components/communityProfile/CommunityProfileContainer.tsx
+++ b/src/components/communityProfile/CommunityProfileContainer.tsx
@@ -58,6 +58,8 @@ const CommunityProfileContainer = () => {