-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from BacPacNet/single-post
added single-post page,loaders and spinners for request
- Loading branch information
Showing
31 changed files
with
381 additions
and
161 deletions.
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
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
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 { 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, isPending } = 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 && !isPending) { | ||
return <div className="text-center">Login to view Post.</div> | ||
} | ||
if (isFetching || isPending) { | ||
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> | ||
|
||
<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
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
Oops, something went wrong.