-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added single-post page,loaders and spinners for request #78
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b64d6df
added single-post page,loaders and spinners for request
Aamil13 3edcbf3
changed the api endpoint to /post
Aamil13 43c8268
refactored and added type
Aamil13 6546dfc
removed query destructuring and following/follower slice, moved sec-N…
Aamil13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
export default function Loading() { | ||
// You can add any UI inside Loading, including a Skeleton. | ||
return <div>dsdsdsdsdsd</div> | ||
return ( | ||
<div className="h-screen flex items-center justify-center"> | ||
<div className="flex justify-center items-center"> | ||
<svg width={50} height={50} viewBox="0 0 50 50" xmlns="http://www.w3.org/2000/svg" className="animate-spin"> | ||
<circle cx="25" cy="25" r="20" fill="none" stroke="#6647FF" strokeWidth="5" strokeLinecap="round" strokeDasharray="80, 200" /> | ||
</svg> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
'use client' | ||
import Post from '@/components/Timeline/Post' | ||
import { useGetPost } from '@/services/community-university' | ||
import { useParams, useSearchParams } from 'next/navigation' | ||
import Modal from '@/components/Timeline/Modal' | ||
import ConnectionsModal from '@/components/Timeline/Modals/ConnectionsModal' | ||
import PollModal from '@/components/Timeline/Modals/PollModal' | ||
|
||
import React, { useState } from 'react' | ||
import { ModalContentType } from '@/types/global' | ||
import Navbar from '@/components/Timeline/Navbar' | ||
import { PostType } from '@/types/constants' | ||
import { useUniStore } from '@/store/store' | ||
import PostSkeleton from '@/components/Timeline/PostSkeleton' | ||
import useCookie from '@/hooks/useCookie' | ||
const UserPost = () => { | ||
const { id } = useParams<{ id: string }>() | ||
const searchParams = useSearchParams() | ||
const Type = searchParams.get('isType') | ||
const [isModalOpen, setIsModalOpen] = useState(false) | ||
const [modalContentType, setModalContentType] = useState<ModalContentType>() | ||
const { data, isFetching } = useGetPost(id, Type) | ||
const item = data?.post | ||
const [cookieValue] = useCookie('uni_user_token') | ||
const { userProfileData } = useUniStore() | ||
const modalContent = (modalContentType: string) => { | ||
switch (modalContentType) { | ||
case 'ConnectionsModal': | ||
return <ConnectionsModal /> | ||
case 'PollModal': | ||
return <PollModal /> | ||
default: | ||
return null | ||
} | ||
} | ||
|
||
const PostHolder = () => { | ||
if (!cookieValue) { | ||
return <div className="text-center">Login to view Post.</div> | ||
} | ||
if (isFetching) { | ||
return <PostSkeleton /> | ||
} | ||
return ( | ||
<Post | ||
isType={String(Type)} | ||
isSinglePost={true} | ||
user={item?.user_id?.firstName + ' ' + item?.user_id?.lastName} | ||
adminId={item?.user_id?._id} | ||
university={item?.user_id?.university_name} | ||
year={item?.user_id?.study_year + ' Yr. ' + ' ' + item?.user_id?.degree} | ||
text={item?.content} | ||
date={item?.createdAt} | ||
avatar={item?.user_id?.profile_dp?.imageUrl} | ||
likes={item?.likeCount} | ||
comments={item?.comments.length} | ||
postID={item?._id} | ||
reposts={2} | ||
shares={1} | ||
userComments={item?.comments} | ||
setModalContentType={setModalContentType} | ||
setIsModalOpen={setIsModalOpen} | ||
isUniversity={true} | ||
profileDp={userProfileData?.profile_dp?.imageUrl} | ||
media={item?.imageUrl} | ||
type={String(Type) == 'userPost' ? PostType.Timeline : PostType.Community} | ||
/> | ||
) | ||
} | ||
|
||
return ( | ||
<div> | ||
<Modal isOpen={isModalOpen} onClose={() => setIsModalOpen(false)}> | ||
{modalContentType && modalContent(modalContentType)} | ||
</Modal> | ||
<Navbar /> | ||
|
||
<div className="border-2 border-neutral-300 rounded-md w-3/4 mx-auto mt-6"> | ||
<PostHolder /> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default UserPost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,6 +117,7 @@ const Timeline = () => { | |
setIsModalOpen={setIsModalOpen} | ||
postID={post._id} | ||
type={PostType.Timeline} | ||
isType={'communityId' in post ? 'CommunityPost' : 'userPost'} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's have "CommunityPost" & "userPost" as a constant enum |
||
/> | ||
) | ||
}) | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remove this navbar from here and keep this at top level based on isUserLoggedIn