From a94380898d2fc59554eaaaeba23f58e9c0c20bd2 Mon Sep 17 00:00:00 2001 From: bacpactech Date: Fri, 20 Dec 2024 01:05:07 +0530 Subject: [PATCH] fix: communitygroup UI --- src/components/atoms/Buttons/index.tsx | 2 +- .../atoms/CustomToasts/CustomToasts.tsx | 3 +- .../atoms/PostImageSlider/index.tsx | 2 +- src/components/atoms/SelectUsers/index.tsx | 4 +- .../molecules/CommunityGroupBanner/index.tsx | 49 +++++-------------- .../molecules/CreateNewGroupBox/index.tsx | 4 +- .../EditCommunityGroupModal/index.tsx | 20 ++++---- .../molecules/UniversityCard/index.tsx | 11 +++-- .../organisms/ProfileCard/index.tsx | 2 +- src/services/community-university.ts | 10 ++-- 10 files changed, 44 insertions(+), 63 deletions(-) diff --git a/src/components/atoms/Buttons/index.tsx b/src/components/atoms/Buttons/index.tsx index 2b6db39..47fccf3 100644 --- a/src/components/atoms/Buttons/index.tsx +++ b/src/components/atoms/Buttons/index.tsx @@ -20,7 +20,7 @@ const Buttons: React.FC = ({ className = '', variant = 'primary', s medium: 'text-md py-2 px-4 ', large: 'text-lg py-2 px-4 ', extra_small: 'text-2xs py-1 px-2', - extra_small_paddind_2: 'text-2xs py-2 px-2', + extra_small_paddind_2: 'text-3xs py-2 px-2', } const variantClass = variantClasses[variant] diff --git a/src/components/atoms/CustomToasts/CustomToasts.tsx b/src/components/atoms/CustomToasts/CustomToasts.tsx index d9bd8f3..8aa0dfd 100644 --- a/src/components/atoms/CustomToasts/CustomToasts.tsx +++ b/src/components/atoms/CustomToasts/CustomToasts.tsx @@ -1,3 +1,4 @@ +import { MESSAGES } from '@/content/constant' import React from 'react' import toast from 'react-hot-toast' @@ -88,7 +89,7 @@ export function showCustomDangerToast(message: string) { textAlign: 'center', }, }, - React.createElement('p', { className: 'text-white' }, message), + React.createElement('p', { className: 'text-white' }, message || MESSAGES.SOMETHING_WENT_WRONG), React.createElement( 'button', { diff --git a/src/components/atoms/PostImageSlider/index.tsx b/src/components/atoms/PostImageSlider/index.tsx index dd3bc92..1650b5b 100644 --- a/src/components/atoms/PostImageSlider/index.tsx +++ b/src/components/atoms/PostImageSlider/index.tsx @@ -22,7 +22,7 @@ type prop = { export default function PostImageSlider({ images, initialSlide, messageImage }: prop) { return ( -
+

closeImageModal()}>

diff --git a/src/components/atoms/SelectUsers/index.tsx b/src/components/atoms/SelectUsers/index.tsx index 3b17e96..2ee3582 100644 --- a/src/components/atoms/SelectUsers/index.tsx +++ b/src/components/atoms/SelectUsers/index.tsx @@ -1,4 +1,6 @@ import React from 'react' +import avatar from '@assets/avatar.svg' +import Image from 'next/image' type user = { id: string @@ -31,7 +33,7 @@ const SelectUsers = ({ selectedUsers, setSelectedUsers, user }: Props) => {
handleClick(user)} className="w-4" type="checkbox" checked={isSelected} />
- +

{user?.firstName}

{/*

{data?.profile?.university_name ? data?.profile?.university_name : 'Not Availaible'}

*/} diff --git a/src/components/molecules/CommunityGroupBanner/index.tsx b/src/components/molecules/CommunityGroupBanner/index.tsx index 7517cee..a938d94 100644 --- a/src/components/molecules/CommunityGroupBanner/index.tsx +++ b/src/components/molecules/CommunityGroupBanner/index.tsx @@ -146,47 +146,19 @@ export default function CommunityGroupBanner({ communityID, communityGroupID, is
-
+
- {!communityGroupID ? ( -
- handleLogoImageUpload(e)} /> - -
- ) : ( -
- handleGroupLogoImageUpload(e)} - /> - -
- )} - logo

{communityGroups?.title}

@@ -198,8 +170,11 @@ export default function CommunityGroupBanner({ communityID, communityGroupID, is } flex items-center`} > {isGroupAdmin ? ( -
- +
handleEditCommunityGroupModal()} + className="flex gap-2 items-center text-2xs lg:text-xs text-primary-500 whitespace-nowrap cursor-pointer" + > +
) : ( @@ -210,8 +185,8 @@ export default function CommunityGroupBanner({ communityID, communityGroupID, is
-

{communityGroups?.description}

-

+

{communityGroups?.description}

+

{communityGroups?.users?.length} members

diff --git a/src/components/molecules/CreateNewGroupBox/index.tsx b/src/components/molecules/CreateNewGroupBox/index.tsx index d9c4fb5..af4a0d6 100644 --- a/src/components/molecules/CreateNewGroupBox/index.tsx +++ b/src/components/molecules/CreateNewGroupBox/index.tsx @@ -51,7 +51,7 @@ const CreateNewGroup = ({ setNewGroup, communityId = '' }: Props) => { const handleSelectAll = useCallback(() => { const getAlluser: any = communityData?.users?.filter((user) => user?.id !== userData?.id).map((user) => user) setSelectedUsers(getAlluser) - }, []) + }, [communityData]) const handleCategoryChange = (category: Category) => { setSelectedGroupCategory(category) @@ -318,7 +318,7 @@ const CreateNewGroup = ({ setNewGroup, communityId = '' }: Props) => {
{/*
diff --git a/src/components/molecules/UniversityCard/index.tsx b/src/components/molecules/UniversityCard/index.tsx index 3a7bc12..b5daeb3 100644 --- a/src/components/molecules/UniversityCard/index.tsx +++ b/src/components/molecules/UniversityCard/index.tsx @@ -11,6 +11,7 @@ import { Skeleton } from '@/components/ui/Skeleton' import { openModal } from '../Modal/ModalManager' import CommunityLeaveModal from '../CommunityLeaveModal' +import Spinner from '@/components/atoms/spinner' interface Props { communityID: string @@ -73,7 +74,7 @@ export default function UniversityCard({ communityID, isGroupAdmin, setIsGroupAd return (
-
+
-
-
+
+

{communityData?.name}

-

AI POWERED

+

AI POWERED

diff --git a/src/components/organisms/ProfileCard/index.tsx b/src/components/organisms/ProfileCard/index.tsx index 16ecc2c..9ec1593 100644 --- a/src/components/organisms/ProfileCard/index.tsx +++ b/src/components/organisms/ProfileCard/index.tsx @@ -123,7 +123,7 @@ export function UserProfileCard({ {isSelfProfile ? (
openModal()} - className="flex gap-2 items-center text-2xs lg:text-xs text-primary-500 cursor-pointer" + className="flex gap-2 items-center text-2xs lg:text-xs text-primary-500 whitespace-nowrap cursor-pointer" > diff --git a/src/services/community-university.ts b/src/services/community-university.ts index 7a4b1bf..39195ff 100644 --- a/src/services/community-university.ts +++ b/src/services/community-university.ts @@ -176,9 +176,11 @@ export const useUpdateCommunity = () => { mutationFn: ({ id, data }: any) => UpdateCommunity(id, data), onSuccess: () => { queryClient.invalidateQueries({ queryKey: ['community'] }) + showCustomSuccessToast('Community updated successfully') }, onError: (res: any) => { console.log(res.response.data.message, 'res') + showCustomDangerToast(res.response.data.message) }, }) } @@ -240,11 +242,13 @@ export const useCreateCommunityGroup = () => { const queryClient = useQueryClient() return useMutation({ mutationFn: ({ communityId, data }: any) => CreateCommunityGroup(communityId, cookieValue, data), - onSuccess: (response: any) => { + onSuccess: () => { queryClient.invalidateQueries({ queryKey: ['communityGroups'] }) + showCustomSuccessToast('Community successfully created ') }, - onError: (res: any) => { - console.log(res.response.data.message, 'res') + onError: (error: any) => { + console.log(error.response.data.message, 'res') + showCustomDangerToast(error.response.data.message) }, }) }