diff --git a/src/components/atoms/RenderProfileDP/index.tsx b/src/components/atoms/RenderProfileDP/index.tsx index 1ea4ae3c..4c49be8b 100644 --- a/src/components/atoms/RenderProfileDP/index.tsx +++ b/src/components/atoms/RenderProfileDP/index.tsx @@ -16,10 +16,10 @@ function ProfilePicture({ userProfileData }: Props) { return ( profile.png diff --git a/src/components/atoms/SubText/index.tsx b/src/components/atoms/SubText/index.tsx index acd57fa4..cb3d4e5b 100644 --- a/src/components/atoms/SubText/index.tsx +++ b/src/components/atoms/SubText/index.tsx @@ -6,7 +6,7 @@ interface TitleProps extends HTMLAttributes { export default function SubText({ children, className = '', ...rest }: TitleProps) { return ( -

+

{children}

) diff --git a/src/components/molecules/PostCard/index.tsx b/src/components/molecules/PostCard/index.tsx index 7d127e77..1e95f296 100644 --- a/src/components/molecules/PostCard/index.tsx +++ b/src/components/molecules/PostCard/index.tsx @@ -159,7 +159,7 @@ const PostCard = ({
- avatar.png + avatar.png

{user}

diff --git a/src/components/molecules/PostCommentBox/index.tsx b/src/components/molecules/PostCommentBox/index.tsx index f686547e..8878280b 100644 --- a/src/components/molecules/PostCommentBox/index.tsx +++ b/src/components/molecules/PostCommentBox/index.tsx @@ -32,6 +32,7 @@ import { import { IoMdCode } from 'react-icons/io' import NestedCommentModal from '../nestedCommentModal' import useDeviceType from '@/hooks/useDeviceType' +import { formatDistanceToNow } from 'date-fns' dayjs.extend(relativeTime) type Props = { @@ -314,18 +315,18 @@ const PostCommentBox = ({ showCommentSec, postID, type, data }: Props) => {

{comment?.commenterId?.firstName}

-

{comment?.commenterProfileId?.university_name}

-

{`${comment?.commenterProfileId?.study_year}nd Yr ${comment?.commenterProfileId?.degree}`}

+ {/*

{comment?.commenterProfileId?.university_name}

*/} +

{`${comment?.commenterProfileId?.study_year} year, ${comment?.commenterProfileId?.degree}`}

- {comment.createdAt && dayjs(new Date(comment?.createdAt).toString()).format('h:mm A ยท MMM D, YYYY')} + {comment.createdAt && formatDistanceToNow(comment?.createdAt as unknown as Date, { addSuffix: true })}

-
+
{comment?.content}
-
+
likePostCommentHandler(comment._id)} diff --git a/src/components/organism/Login/LoginBox.tsx b/src/components/organism/Login/LoginBox.tsx index 844dacc7..87cd3a73 100644 --- a/src/components/organism/Login/LoginBox.tsx +++ b/src/components/organism/Login/LoginBox.tsx @@ -98,14 +98,9 @@ const LoginBox = () => {
- {/*
- -

Remember device for 30 days

-
*/} - {isAxiosError(error) && error.response?.data?.message}
diff --git a/src/components/organisms/PostsContainer/index.tsx b/src/components/organisms/PostsContainer/index.tsx index 52d36a60..b4981ea8 100644 --- a/src/components/organisms/PostsContainer/index.tsx +++ b/src/components/organisms/PostsContainer/index.tsx @@ -1,5 +1,6 @@ 'use client' import Loading from '@/app/register/loading' +import Card from '@/components/atoms/Card' import PostImageSlider from '@/components/atoms/PostImageSlider' import { openImageModal } from '@/components/molecules/ImageWrapper/ImageManager' import PostCard from '@/components/molecules/PostCard' @@ -53,6 +54,7 @@ const ProfilePostContainer = ({ userId = '', containerRef }: Props) => { }, [imageCarasol]) const renderPostWithRespectToPathName = () => { + if (userSelfPosts?.length === 0) return No Post Available return userSelfPosts?.map((post: communityPostType, idx: number) => ( diff --git a/src/content/constant.ts b/src/content/constant.ts new file mode 100644 index 00000000..8da1c301 --- /dev/null +++ b/src/content/constant.ts @@ -0,0 +1,3 @@ +export const MESSAGES = { + SOMETHING_WENT_WRONG: 'Something went wrong', +} diff --git a/src/services/auth.ts b/src/services/auth.ts index 86208291..b1736d0c 100644 --- a/src/services/auth.ts +++ b/src/services/auth.ts @@ -4,6 +4,8 @@ import { client } from './api-Client' import { useUniStore } from '@/store/store' import useCookie from '@/hooks/useCookie' import { useRouter } from 'next/navigation' +import { showCustomDangerToast } from '@/components/atoms/CustomToasts/CustomToasts' +import { MESSAGES } from '@/content/constant' interface data { email: string @@ -77,6 +79,10 @@ export const useHandleLogin = () => { setCookieValue(response.tokens.access.token, response.tokens.access.expires) setRefreshCookieValue(response.tokens.refresh.token, response.tokens.refresh.expires) }, + onError: (error: any) => { + console.log(error) + showCustomDangerToast(error.response.data.message || MESSAGES.SOMETHING_WENT_WRONG) + }, }) }