From 4595535baff38aa8541cff4b8b3cabb9f976fd20 Mon Sep 17 00:00:00 2001 From: Mehul Date: Sun, 10 Nov 2024 07:36:33 -0500 Subject: [PATCH] disable community which are not approved --- .../(community)/explore-community/page.tsx | 152 ++++++++---------- 1 file changed, 67 insertions(+), 85 deletions(-) diff --git a/src/app/(community)/explore-community/page.tsx b/src/app/(community)/explore-community/page.tsx index 90459a1..d29a2bf 100644 --- a/src/app/(community)/explore-community/page.tsx +++ b/src/app/(community)/explore-community/page.tsx @@ -42,15 +42,7 @@ const Page: React.FC = () => { community_category: "", community_image: "", }); - const [editingCommunityId, setEditingCommunityId] = useState( - null - ); // To track the community being edited - - const [joinFormData, setJoinFormData] = useState({ - name: "", - email: "", - contact: "", - }); + const [editingCommunityId, setEditingCommunityId] = useState(null); // To track the community being edited const session = useSession(); const { user } = useUserDetails(); @@ -117,18 +109,16 @@ const Page: React.FC = () => { } } else { // Insert new community (as before) - const { data, error } = await supabase.from("communities").insert([ - { - community_name, - community_description, - community_location, - community_category, - community_image, - community_members_count: 0, - community_creation_date: new Date().toISOString(), - is_approved: false, - }, - ]); + const { data, error } = await supabase.from("communities").insert([{ + community_name, + community_description, + community_location, + community_category, + community_image, + community_members_count: 0, + community_creation_date: new Date().toISOString(), + is_approved: false, + }]); if (error) { toast.error("Failed to create community."); @@ -213,11 +203,6 @@ const Page: React.FC = () => { setShowAddCommunityForm(true); // Show the form to edit }; - const handleJoinFormChange = (e: React.ChangeEvent) => { - const { name, value } = e.target; - setJoinFormData({ ...joinFormData, [name]: value }); - }; - const filteredAndSortedCommunities = useMemo(() => { return communities .filter((community) => { @@ -291,75 +276,72 @@ const Page: React.FC = () => { className="absolute right-3 top-1/2 transform -translate-y-1/2 cursor-pointer" onClick={handleSearchClick} > - + - - - -
- {currentCommunities.map((community) => ( - - {/* Trash Icon for Delete */} - - {community.community_name} -

- {community.community_name} -

-

- - {community.community_location} -

-
+ {/* Tooltip for Not Approved */} + {!community.is_approved && ( +
+ Not Approved +
+ )} + + {/* Trash Icon for Delete */} -
-
- ))} + + {community.community_name} +

+ {community.community_name} +

+

+ + {community.community_location} +

+ +
+ +
+ + ))} +
-
+