-
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 #104 from BacPacNet/feat-connections-profile
Feat connections profile
- Loading branch information
Showing
45 changed files
with
1,118 additions
and
361 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,43 @@ | ||
import React from 'react' | ||
'use client' | ||
import Card from '@/components/atoms/Card' | ||
import Tabs from '@/components/molecules/Tabs' | ||
import FindPeople from '@/components/molecules/Tabs/FindPeople' | ||
import Followers from '@/components/molecules/Tabs/Followers' | ||
import Following from '@/components/molecules/Tabs/Following' | ||
import { useUniStore } from '@/store/store' | ||
import React, { useMemo, useRef } from 'react' | ||
|
||
export default function ConnectionPage() { | ||
return <div>ConnectionPage</div> | ||
const { userProfileData } = useUniStore() | ||
|
||
const userFollowingIDs = useMemo(() => { | ||
return userProfileData?.following?.map((following: { userId: string }) => following.userId) | ||
}, [userProfileData]) | ||
|
||
const userFollowerIDs = useMemo(() => { | ||
return userProfileData?.followers?.map((followers: { userId: string }) => followers.userId) | ||
}, [userProfileData]) | ||
|
||
const tabs = [ | ||
{ | ||
label: 'Find People', | ||
content: <FindPeople />, | ||
}, | ||
{ | ||
label: `Following`, | ||
content: <Following userFollowingIDs={userFollowingIDs || []} />, | ||
}, | ||
{ | ||
label: `Follower`, | ||
content: <Followers userFollowingIDs={userFollowingIDs || []} />, | ||
}, | ||
] | ||
|
||
return ( | ||
<div className="py-8 h-with-navbar"> | ||
<Card className="rounded-2xl h-full overflow-hidden px-4"> | ||
<Tabs tabs={tabs} className={'h-full'} /> | ||
</Card> | ||
</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,69 @@ | ||
'use client' | ||
import Spinner from '@/components/atoms/spinner' | ||
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, { useState } from 'react' | ||
|
||
export default function Profile({ params }: { params: { id: string } }) { | ||
const userId = params.id[0] | ||
const [isModalOpen, setIsModalOpen] = useState(false) | ||
const [modalContentType, setModalContentType] = useState<ModalContentType>() | ||
const isSelfProfile = useCheckSelfProfile(userId) | ||
|
||
const { data: userProfileData, isLoading: isUserProfileDataLoading } = useGetUserData(userId) | ||
const modalContent = (modalContentType: string) => { | ||
switch (modalContentType) { | ||
case 'EditProfileModal': | ||
return <EditProfileModal /> | ||
case 'ConnectionsModal': | ||
return <ConnectionsModal /> | ||
default: | ||
return null | ||
} | ||
} | ||
const { dob, profile, firstName, lastName, email } = userProfileData || {} | ||
const { bio, university_name, followers, following, study_year, major, degree, phone_number, country } = profile || {} | ||
return ( | ||
<div className="h-with-navbar py-4"> | ||
<Modal isOpen={isModalOpen} onClose={() => setIsModalOpen(false)}> | ||
{modalContentType && modalContent(modalContentType)} | ||
</Modal> | ||
{isUserProfileDataLoading || !userProfileData ? ( | ||
<Skeleton className="w-full h-60 bg-slate-300" /> | ||
) : ( | ||
<UserProfileCard | ||
name={`${firstName} ${lastName}`} | ||
isPremium={true} | ||
description={bio || ''} | ||
university={university_name || 'Lorem University'} | ||
isVerified={true} | ||
following={followers?.length || 0} | ||
followers={following?.length || 0} | ||
year={study_year || ''} | ||
degree={degree || ''} | ||
major={major || ''} | ||
email={email || ''} | ||
phone={phone_number || '0000'} | ||
location={'Bangalore'} | ||
birthday={dob || ''} | ||
avatarUrl={profile?.profile_dp?.imageUrl || ''} | ||
isVerifiedUniversity={true} | ||
country={country || ''} | ||
setModalContentType={setModalContentType} | ||
setIsModalOpen={setIsModalOpen} | ||
isSelfProfile={isSelfProfile} | ||
/> | ||
)} | ||
<PostContainer userId={userId} type={PostType.Profile} /> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
'use client' | ||
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 { 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<ModalContentType>() | ||
const { userData, userProfileData } = useUniStore() | ||
const modalContent = (modalContentType: string) => { | ||
switch (modalContentType) { | ||
case 'EditProfileModal': | ||
return <EditProfileModal /> | ||
case 'ConnectionsModal': | ||
return <ConnectionsModal /> | ||
default: | ||
return null | ||
} | ||
} | ||
const { bio, university_name, followers, following, study_year, major, phone_number, dob, degree, country } = userProfileData | ||
const { firstName, lastName, email } = userData | ||
return ( | ||
<div className="h-with-navbar py-4"> | ||
<Modal isOpen={isModalOpen} onClose={() => setIsModalOpen(false)}> | ||
{modalContentType && modalContent(modalContentType)} | ||
</Modal> | ||
<UserProfileCard | ||
name={`${firstName} ${lastName}`} | ||
isPremium={true} | ||
description={bio || ''} | ||
university={university_name || 'Lorem University'} | ||
isVerified={true} | ||
following={followers?.length || 0} | ||
followers={following?.length || 0} | ||
year={study_year || ''} | ||
degree={degree || ''} | ||
major={major || ''} | ||
email={email || ''} | ||
phone={phone_number || '0000'} | ||
location={'Bangalore'} | ||
birthday={dob || ''} | ||
avatarUrl={userProfileData?.profile_dp?.imageUrl || ''} | ||
isVerifiedUniversity={true} | ||
country={country || ''} | ||
setModalContentType={setModalContentType} | ||
setIsModalOpen={setIsModalOpen} | ||
/> | ||
<PostContainer type={PostType.Timeline} /> | ||
</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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Oops, something went wrong.