diff --git a/src/app/(withLayout)/community/[communityId]/[groupId]/page.tsx b/src/app/(withLayout)/community/[communityId]/[groupId]/page.tsx index 663d906..620a9bd 100644 --- a/src/app/(withLayout)/community/[communityId]/[groupId]/page.tsx +++ b/src/app/(withLayout)/community/[communityId]/[groupId]/page.tsx @@ -18,7 +18,7 @@ export default function Page({ params }: { params: { communityId: string; groupI isGroupAdmin={isGroupAdmin} setIsGroupAdmin={setIsGroupAdmin} /> - {isGroupAdmin && } + ) diff --git a/src/app/(withLayout)/communityGroup/[group_id]/page.tsx b/src/app/(withLayout)/communityGroup/[group_id]/page.tsx deleted file mode 100644 index 36ef33b..0000000 --- a/src/app/(withLayout)/communityGroup/[group_id]/page.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import React from 'react' - -export default function CommunityGroup() { - return
CommunityGroup
-} diff --git a/src/app/(withLayout)/messages/old_page.tsx b/src/app/(withLayout)/messages/old_page.tsx deleted file mode 100644 index d496749..0000000 --- a/src/app/(withLayout)/messages/old_page.tsx +++ /dev/null @@ -1,49 +0,0 @@ -'use client' -import MessageSideBar from '@/components/messages/MessageSideBar' -import UserMessageContainer from '@/components/messages/UserMessageContainer' -import { useUpdateMessageIsSeen } from '@/services/Messages' -import { useUniStore } from '@/store/store' -import { Chat } from '@/types/constants' -import React, { useEffect, useState } from 'react' - -const ChatScreen = () => { - const [selectedChat, setSelectedChat] = useState(undefined) - - const { userData } = useUniStore() - const userName = selectedChat?.users?.find((item) => item?.userId._id !== userData.id) - - const { mutate: updateIsSeen } = useUpdateMessageIsSeen() - const [isRequest, setIsRequest] = useState(true) - - const updateMessageSeen = () => { - const isRead = selectedChat?.latestMessage?.readByUsers?.includes(userData.id || '') - - if (!isRead && isRead !== undefined && selectedChat) { - updateIsSeen({ chatId: selectedChat?._id, messageId: selectedChat?.latestMessage?._id, data: { readByUserId: userData.id } }) - } - } - - useEffect(() => { - updateMessageSeen() - }, [selectedChat]) - - return ( -
-
- - {selectedChat?._id && ( - - )} -
-
- ) -} - -export default ChatScreen diff --git a/src/app/(withLayout)/profile/[...id]/page.tsx b/src/app/(withLayout)/profile/[...id]/page.tsx index 66316f2..da121d7 100644 --- a/src/app/(withLayout)/profile/[...id]/page.tsx +++ b/src/app/(withLayout)/profile/[...id]/page.tsx @@ -1,19 +1,14 @@ 'use client' -import Spinner from '@/components/atoms/spinner' import { openModal } from '@/components/molecules/Modal/ModalManager' import ProfilePostContainer from '@/components/organisms/PostsContainer' -import PostContainer from '@/components/organisms/PostsContainer' import { UserProfileCard } from '@/components/organisms/ProfileCard' -import Modal from '@/components/Timeline/Modal' import ConnectionsModal from '@/components/Timeline/Modals/ConnectionsModal' import EditProfileModal from '@/components/Timeline/Modals/EditProfileModal' -import ProfileCard from '@/components/Timeline/ProfileCard' import { Skeleton } from '@/components/ui/Skeleton' import { useCheckSelfProfile } from '@/lib/utils' import { useGetUserData } from '@/services/user' -import { PostType } from '@/types/constants' import { ModalContentType } from '@/types/global' -import React, { useEffect, useRef, useState } from 'react' +import React, { useRef, useState } from 'react' export default function Profile({ params }: { params: { id: string } }) { const userId = params.id[0] diff --git a/src/app/(withLayout)/profile/page.tsx b/src/app/(withLayout)/profile/page.tsx deleted file mode 100644 index 7ef575f..0000000 --- a/src/app/(withLayout)/profile/page.tsx +++ /dev/null @@ -1,64 +0,0 @@ -'use client' - -import PostContainer from '@/components/organisms/PostsContainer' -import { UserProfileCard } from '@/components/organisms/ProfileCard' -import TimelinePostContainer from '@/components/organisms/TimelinePostContainer' -import Modal from '@/components/Timeline/Modal' -import ConnectionsModal from '@/components/Timeline/Modals/ConnectionsModal' -import EditProfileModal from '@/components/Timeline/Modals/EditProfileModal' -import ProfileCard from '@/components/Timeline/ProfileCard' -import { useUniStore } from '@/store/store' -import { PostType } from '@/types/constants' -import { ModalContentType } from '@/types/global' -import React, { useState } from 'react' - -export default function Profile() { - const [isModalOpen, setIsModalOpen] = useState(false) - const [modalContentType, setModalContentType] = useState() - const { userData, userProfileData } = useUniStore() - const modalContent = (modalContentType: string) => { - switch (modalContentType) { - case 'EditProfileModal': - return - case 'ConnectionsModal': - return - default: - return null - } - } - const { bio, university_name, university_id, followers, following, study_year, major, phone_number, dob, degree, country } = userProfileData - const { firstName, lastName, email } = userData - return ( -
- {/* setIsModalOpen(false)}> - {modalContentType && modalContent(modalContentType)} - */} - {/* - {modalContentType && modalContent(modalContentType)} - */} - {/* */} - -
- ) -} diff --git a/src/app/post/[id]/page.tsx b/src/app/post/[id]/page.tsx index b07d3b8..b855584 100644 --- a/src/app/post/[id]/page.tsx +++ b/src/app/post/[id]/page.tsx @@ -27,9 +27,9 @@ const SinglePost = () => { currImageIndex: null, }) - if (Object.keys(data).length === 0) { - return
Not Allowed
- } + // if (!data || Object.keys(data).length === 0) { + // return
Not Allowed
+ // } if (isError) { return
Not Allowed
diff --git a/src/components/Navbar/Navbar.tsx b/src/components/Navbar/Navbar.tsx index de6b1bf..21a327a 100644 --- a/src/components/Navbar/Navbar.tsx +++ b/src/components/Navbar/Navbar.tsx @@ -43,7 +43,7 @@ const Navbar: React.FC = () => { const [hover, setHover] = useState(false) const [activeItem, setActiveItem] = useState('') const [, , deleteCookie] = useCookie('uni_user_token') - const { userProfileData, userData, resetUserData, resetUserProfileData } = useUniStore() + const { userProfileData, userData, resetUserData } = useUniStore() const router = useRouter() const { refetch: refetchNotification } = useGetNotification(3, false) const { data: notificationData } = useGetNotification(3, false) @@ -67,7 +67,6 @@ const Navbar: React.FC = () => { const handleLogout = () => { deleteCookie() resetUserData() - resetUserProfileData() setIsLogin(false) router.push('/login') } diff --git a/src/components/Timeline/Modals/EditProfileModal.tsx b/src/components/Timeline/Modals/EditProfileModal.tsx index 4ca66bc..02970c2 100644 --- a/src/components/Timeline/Modals/EditProfileModal.tsx +++ b/src/components/Timeline/Modals/EditProfileModal.tsx @@ -51,11 +51,11 @@ const EditProfileModal = () => { formState: { errors }, } = useForm({ defaultValues: { - first_name: userData.firstName, - last_name: userData.lastName, + first_name: userData?.firstName, + last_name: userData?.lastName, bio: userProfileData?.bio, phone_number: userProfileData?.phone_number, - gender: userData.gender, + gender: userData?.gender, dob: userProfileData?.dob ? new Date(userProfileData?.dob).toISOString().split('T')[0] : '', country: userProfileData?.country, city: userProfileData?.city, diff --git a/src/components/Timeline/ProfileCard.tsx b/src/components/Timeline/ProfileCard.tsx index 844e2eb..c8c4d93 100644 --- a/src/components/Timeline/ProfileCard.tsx +++ b/src/components/Timeline/ProfileCard.tsx @@ -142,7 +142,7 @@ const ProfileCard: React.FC = ({
Profile = ({
-

{userData.firstName}

+

{userData?.firstName}

{userProfileData?.bio}

{!isUserProfile && }
@@ -180,7 +180,7 @@ const ProfileCard: React.FC = ({ /> - + pathname.includes(path)) || pathname === '/' - const { userProfileData, resetUserProfileData } = useUniStore() - const [, , deleteCookie] = useCookie('uni_user_token') + const { userProfileData, userData } = useUniStore() + + const { handleLogout } = useLogout() const [isLogin, setIsLogin] = useState(undefined) const { data: notificationData } = useGetNotification(3, true) const { data: messageNotificationData } = useGetMessageNotification(3, true) const notifications = notificationData?.pages.flatMap((page) => page.notifications) || [] const messageNotifications = messageNotificationData?.pages.flatMap((page) => page.message) || [] const isUserLoggedIn = useCallback(() => { - setIsLogin(!!userProfileData.users_id) + setIsLogin(!!userProfileData?.users_id) }, [userProfileData]) const [showLeftNavbar, setShowLeftNavbar] = useState(false) const [showRightMenu, setShowRightMenu] = useState(false) - const handleLogout = () => { - deleteCookie() - resetUserProfileData() - router.push('/login') - } - useEffect(() => { isUserLoggedIn() }, [userProfileData, isUserLoggedIn]) diff --git a/src/components/communityUniversity/GroupInfo.tsx b/src/components/communityUniversity/GroupInfo.tsx index 9595f3d..bde3e9d 100644 --- a/src/components/communityUniversity/GroupInfo.tsx +++ b/src/components/communityUniversity/GroupInfo.tsx @@ -93,7 +93,7 @@ const GroupInfo = ({ data, isJoinedinCommunity, setIsJoinedInGroup, isJoinedInGr <> bg
-
+
handleCoverImageUpload(e)} />
@@ -102,7 +102,7 @@ const GroupInfo = ({ data, isJoinedinCommunity, setIsJoinedInGroup, isJoinedInGr ) : ( <>
-
+
handleCoverImageUpload(e)} />
@@ -111,7 +111,7 @@ const GroupInfo = ({ data, isJoinedinCommunity, setIsJoinedInGroup, isJoinedInGr {logoImage ? (
dp -
+
handleLogoImageUpload(e)} />
) : (
-
+
handleLogoImageUpload(e)} />
- {data?.adminUserId?._id == userData.id ? ( + {data?.adminUserId?._id == userData?.id ? ( diff --git a/src/components/communityUniversity/HeroSec.tsx b/src/components/communityUniversity/HeroSec.tsx index ac29c54..4fd8c52 100644 --- a/src/components/communityUniversity/HeroSec.tsx +++ b/src/components/communityUniversity/HeroSec.tsx @@ -73,7 +73,7 @@ const HeroSec = ({ data, setIsJoined, isJoined }: any) => { />
handleCoverImageUpload(e)} /> @@ -82,7 +82,7 @@ const HeroSec = ({ data, setIsJoined, isJoined }: any) => { ) : (
-
+
handleCoverImageUpload(e)} />
@@ -111,7 +111,7 @@ const HeroSec = ({ data, setIsJoined, isJoined }: any) => { src={data?.community?.communityLogoUrl.imageUrl} alt="dp" /> -
+
handleLogoImageUpload(e)} />