diff --git a/src/pages/invitation.tsx b/src/pages/invitation.tsx index e6caa4270..1a97867db 100644 --- a/src/pages/invitation.tsx +++ b/src/pages/invitation.tsx @@ -83,6 +83,7 @@ function Invitation() { role: '', status: '', }); + const[filterDisabled,setFilterDisabled]=useState(true) const modalRef = useRef(null); const organizationToken = localStorage.getItem('orgToken'); @@ -133,7 +134,7 @@ function Invitation() { useEffect(() => { if (invitationStats) { - setSelectedStatus(invitationStats); // Set the fetched status as the default value + setSelectedStatus(''); // Set the fetched status as the default value } }, [invitationStats]); @@ -219,7 +220,7 @@ function Invitation() { filterInvitations({ variables: { role: filterVariables.role || null, - status: typeof filterVariables.status === 'string' ? filterVariables.status : null, + status:filterVariables.status || null, orgToken: organizationToken, }, }); @@ -277,6 +278,27 @@ function Invitation() { fetchInvitations({ variables: { query: searchQuery } }); }; + + useEffect(() => { + if (selectedRole || selectedStatus) { + setFilterDisabled(false); + } else { + setFilterDisabled(true); + } + }, [selectedRole, selectedStatus]); + +const handleRoleChange=(e:React.ChangeEvent)=>{ + const role=e.target.value + setSelectedRole(role) + +} + +const handleStatusChange=(e:React.ChangeEvent)=>{ + const status=e.target.value + setSelectedStatus(status) + +} + const handleFilter = () => { if (!selectedRole && !selectedStatus) { toast.info('Please select role or status.'); @@ -291,6 +313,7 @@ function Invitation() { role: selectedRole, status: typeof selectedStatus === 'string' ? selectedStatus : '', }); + }; const toggleOptions = (row: string) => { @@ -364,7 +387,8 @@ function Invitation() { className="absolute z-50 w-64 p-4 mt-2 overflow-hidden border border-gray-300 rounded-lg shadow-md dropdown right-4 bg-light-bg max-h-30 dark:bg-dark-bg"> <>
-
+ + { row.original.Status === 'Pending' &&
{ @@ -388,6 +412,7 @@ function Invitation() {
+ } {/* Conditionally render Cancel button */} {row.original.Status === 'Pending' && ( @@ -803,7 +828,7 @@ function Invitation() { type="button" disabled={disabledSearch} onClick={handleSearch} - className="bg-[#9e85f5] text-white text-lg md:text-xl rounded-md h-10 flex items-center justify-center md:w-[10%] p-0 sm:p-5 xm:p-5" + className={`bg-[#9e85f5] text-white text-lg md:text-xl rounded-md h-10 flex items-center justify-center md:w-[10%] p-0 sm:p-5 xm:p-5 ${disabledSearch?'cursor-not-allowed opacity-50':'cursor-pointer'}`} > Search @@ -821,7 +846,7 @@ function Invitation() { setSelectedStatus(e.target.value)} + onChange={ handleStatusChange} > @@ -849,13 +874,15 @@ function Invitation() { + type="button" + disabled={filterDisabled} + onClick={handleFilter} + className={`w-full max-w-xs md:w-auto bg-[#9e85f5] text-white text-lg md:text-xl rounded-md h-10 flex items-center justify-center px-4 py-2 + ${filterDisabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer'}`} +> + Filter + + {/* Table view */} {content}