Skip to content
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

fix: select community image #129

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/components/Timeline/Modals/ConnectionsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { useGetUserFollow, useGetUserFollowers } from '@/services/connection'
import { useUniStore } from '@/store/store'
import UserListItemSkeleton from '@/components/Connections/UserListItemSkeleton'
import { FollowingItemProps } from '@/types/constants'
import { useGetUserData } from '@/services/user'

type props = {
isChat?: boolean
Expand All @@ -15,7 +14,6 @@ type props = {
userId?: string
}
const ConnectionsModal = ({ isChat, setIsCreateGroupModalOpen, setIsModalOpen, userId }: props) => {
console.log(userId, 'userId')
const [content, setContent] = useState<'Following' | 'Followers'>('Following')
const { userProfileData } = useUniStore()
const userFollowingIDs = userProfileData && userProfileData?.following?.map((following) => following.userId)
Expand Down
2 changes: 1 addition & 1 deletion src/components/Timeline/UserListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const UserListItem: React.FC<FollowingItemProps> = ({
return (
<div className="flex items-center p-2 md:p-4 border-b border-border justify-between">
<div onClick={() => handleProfileClicked(id)} className="flex gap-4 items-center cursor-pointer">
<img src={imageUrl || avatar.src} alt={firstName} className="w-12 h-12 rounded-full " />
<img src={imageUrl || avatar.src} alt={firstName} className="w-12 h-12 rounded-full flex-none" />
<div className="">
<h3 className="font-medium text-base text-gray-dark">
{firstName} {lastName}
Expand Down
2 changes: 1 addition & 1 deletion src/components/communityUniversity/GroupSelectors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const GroupSelectors = ({
>
<div
onClick={() => handleGroupNavigate()}
className={`flex w-full items-center gap-3 py-2 first-of-type:border-0 relative after:content-[''] after:absolute after:left-3 after:z-30 after:top-[calc(90%+10px)] after:w-[calc(60%)] after:bg-[#6647FF] `}
className={`flex w-full items-center gap-3 py-2 px-4 first-of-type:border-0 relative after:content-[''] after:absolute after:left-3 after:z-30 after:top-[calc(90%+10px)] after:w-[calc(60%)] after:bg-[#6647FF] `}
>
{data?.communityGroupLogoUrl?.imageUrl ? (
<img className="w-10 h-10 object-cover rounded-full" src={data?.communityGroupLogoUrl.imageUrl} alt="dp" />
Expand Down
2 changes: 1 addition & 1 deletion src/components/molecules/Modal/ModalWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const ModalWrapper = ({ children, setModal, isShown, smallHeight = false, taking
} ${smallHeight ? 'h-[99%]' : 'h-screen'} top-0 flex justify-center items-center z-50`}
>
<div onClick={() => setModal(false)} className="bg-black opacity-70 w-full h-screen fixed -z-10"></div>
<div className="relative bg-white w-[550px] max-sm:w-11/12 max-md:w-2/3 min-w-[550px] min-h-[85%] max-h-[85%] overflow-y-auto rounded-2xl shadow-lg px-4 py-4">
<div className="relative bg-white w-[550px] max-sm:w-11/12 max-md:w-2/3 min-h-[85%] max-h-[85%] overflow-y-auto rounded-2xl shadow-lg px-4 py-4">
<div className="absolute right-0 top-0">
<button onClick={() => setModal(false)} className="p-2">
<IoClose size={24} />
Expand Down
53 changes: 40 additions & 13 deletions src/components/molecules/NavbarUniversityItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default function NavbarUniversityItem({ setActiveMenu, toggleLeftNavbar }
const [community, setCommunity] = useState<Community>()
const [selectCommunityId, selectedCommuntyGroupdId] = [communityId || community?._id, communityGroupId]
const { data: subscribedCommunities, isFetching, isLoading } = useGetSubscribedCommunties()
const [communityOpen, setCommunityOpen] = useState(false)

const targetCommunityId = subscribedCommunities?.[0]?._id
const communityIdForNewGroup = userProfileData?.email?.find((item) => item.communityId === targetCommunityId)?.communityId ?? ''
Expand All @@ -58,6 +59,10 @@ export default function NavbarUniversityItem({ setActiveMenu, toggleLeftNavbar }
toggleLeftNavbar && toggleLeftNavbar()
}

const isUserJoinedSelectedCommunity = useMemo(() => {
return community?.users?.some((user) => user?.id?.toString() === userData?.id)
}, [community])

const handleNewGroupModal = () => {
openModal(<CreateNewGroupBox communityId={communityId || communityIdForNewGroup} setNewGroup={setShowNewGroup} />)
}
Expand Down Expand Up @@ -180,17 +185,20 @@ export default function NavbarUniversityItem({ setActiveMenu, toggleLeftNavbar }
toggleLeftNavbar={toggleLeftNavbar}
/>

<div className="flex justify-center items-center p-2">
<button onClick={() => handleNewGroupModal()} className="bg-[#6647FF] py-2 w-11/12 rounded-lg text-white">
Create Group
</button>
</div>
{isUserJoinedSelectedCommunity && (
<div className="flex justify-center items-center p-2">
<button onClick={() => handleNewGroupModal()} className="bg-[#6647FF] py-2 w-11/12 rounded-lg text-white">
Create Group
</button>
</div>
)}
</div>
),
},
]

const handleUniversityClick = (index: React.SetStateAction<number>) => {
setCommunityOpen(false)
const indextoPush = Number(index)
setCommunity(subscribedCommunities?.[indextoPush] as Community)
router.push(`/community/${subscribedCommunities?.[indextoPush]._id}`)
Expand Down Expand Up @@ -236,21 +244,40 @@ export default function NavbarUniversityItem({ setActiveMenu, toggleLeftNavbar }
style={{ boxShadow: '0px 8px 40px rgba(0, 0, 0, 0.10)' }}
className="flex items-center justify-center bg-white rounded-full w-[40px] h-[40px] cursor-pointer"
>
<Image
width={40}
height={40}
className="w-[40px] h-[40px] object-cover rounded-full"
src={community?.communityLogoUrl?.imageUrl || avatar}
alt="communtiy image"
/>
<Popover open={communityOpen} onOpenChange={() => setCommunityOpen(!communityOpen)}>
<PopoverTrigger asChild>
<Image
width={40}
height={40}
className="w-[40px] h-[40px] object-cover rounded-full"
src={community?.communityLogoUrl?.imageUrl || avatar}
alt="communtiy image"
/>
</PopoverTrigger>
<PopoverContent className="bg-white border-none shadow-lg w-fit px-0 rounded-full flex flex-col gap-2 cursor-pointer">
{subscribedCommunities?.map((community, index) => {
return (
<Image
key={community?._id}
onClick={() => handleUniversityClick(index)}
width={40}
height={40}
className="w-[40px] h-[40px] object-cover rounded-full"
src={community?.communityLogoUrl?.imageUrl || avatar}
alt="communtiy image"
/>
)
})}
</PopoverContent>
</Popover>
</div>
<GroupSearchBox placeholder="Search Groups" type="text" onChange={handleSearch} />
</div>
</div>
</>

{subscribedCommunities?.length !== 0 ? (
<Tabs tabs={tabData} tabAlign="left" className="px-4 my-4" />
<Tabs tabs={tabData} tabAlign="left" className="my-4" />
) : (
<div className="px-4 w-full text-center font-poppins text-neutral-400">
<p>Add your university to join or create groups</p>
Expand Down
2 changes: 1 addition & 1 deletion src/components/molecules/PostCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ const PostCard = ({
</div>

<div>
<p className="text-sm text-neutral-700 py-4">{text}</p>
<pre className="text-xs lg:text-sm text-neutral-700 py-4 font-poppins whitespace-pre-wrap break-words">{text}</pre>
</div>

{/* //post Image */}
Expand Down
1 change: 0 additions & 1 deletion src/components/molecules/PostCommentBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ const PostCommentBox = ({ showCommentSec, postID, type, data }: Props) => {
if ((isFetching && !isFetchingNextPage) || (communityCommentsIsFetching && !communityCommentsIsFetchingNextPage)) {
return <Spinner />
}
// console.log('comments', comments)

return comments?.map((comment, index: number) => (
<div key={comment._id} className={`mb-4 h-full relative ${childCommentsId.includes(comment._id) ? 'ms-8 max-sm:ms-4 w-10/12' : 'w-full'} `}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/molecules/Tabs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const Tabs: React.FC<TabsProps> = ({ tabs, className = '', tabAlign = 'left' })
return (
<div className={`w-full ${className} `}>
{/* Tabs List */}
<div className={`border-gray-200 text-${tabAlign}`}>
<div className={`border-gray-200 text-${tabAlign} px-4`}>
{tabs.map((tab, index) => (
<button
key={index}
Expand Down
4 changes: 2 additions & 2 deletions src/components/organisms/ProfileCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export function UserProfileCard({
)}
</div>
<div className="w-full">
<div className="flex w-full items-center justify-between flex-wrap">
<div className="flex w-full items-center justify-between flex-wrap gap-4">
<div className="flex gap-4 items-center">
<p className="font-poppins text-neutral-700 text:md lg:text-[20px] font-bold">{name}</p>
{isPremium && <p className="bg-primary-800 text-white rounded-xl px-2 text-3xs">Premium</p>}
Expand Down Expand Up @@ -192,7 +192,7 @@ export function UserProfileCard({
</div>
</div>
</div>
<div className="grid grid-flow-row-dense grid-cols-1 lg:grid-cols-3 gap-4 pt-8 text-neutral-500">
<div className="grid grid-flow-row-dense grid-cols-1 lg:grid-cols-3 gap-4 pt-3 lg:pt-8 text-neutral-500">
{affiliation && occupation && (
<>
{occupation && (
Expand Down
4 changes: 2 additions & 2 deletions src/services/community-university.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export const useJoinCommunity = () => {
mutationFn: (communityId: string) => joinCommunity(communityId, cookieValue),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['communityGroupsPost'] })
queryClient.invalidateQueries({ queryKey: ['community'] })
queryClient.invalidateQueries({ queryKey: ['useGetSubscribedCommunties'] })
showCustomSuccessToast(`Joined Community `)
},
onError: (res: any) => {
Expand All @@ -206,7 +206,7 @@ export const useLeaveCommunity = () => {
mutationFn: (communityId: string) => leaveCommunity(communityId, cookieValue),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['communityGroupsPost'] })
queryClient.invalidateQueries({ queryKey: ['community'] })
queryClient.invalidateQueries({ queryKey: ['useGetSubscribedCommunties'] })
showCustomDangerToast(`Left Community`)
},
onError: (res: any) => {
Expand Down
Loading