-
-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(organizations: remove invite params on accept/decline TASK-1582 (#…
…5535) ### 📣 Summary Remove relevant search params when a user accepts or declines an MMO invite
- Loading branch information
1 parent
93e73f2
commit cfea6e4
Showing
2 changed files
with
14 additions
and
8 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
18 changes: 11 additions & 7 deletions
18
jsapp/js/account/organization/invites/OrgInviteModalWrapper.tsx
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,21 +1,25 @@ | ||
import { useLocation } from 'react-router-dom' | ||
import { useSearchParams } from 'react-router-dom' | ||
import OrgInviteModal from './OrgInviteModal' | ||
|
||
/** | ||
* This is a wrapper for conditionally rendering the OrgInviteModal component. It simply looks for particular pair of | ||
* search parameters. | ||
* This is a wrapper for conditionally rendering the OrgInviteModal component. It looks for a particular pair of | ||
* search parameters to pass to the modal. Also, if an invitation is deleted or accepted, it removes those params. | ||
*/ | ||
export default function OrgInviteModalWrapper() { | ||
// Get values from URL params | ||
const location = useLocation() | ||
const searchParams = new URLSearchParams(location.search) | ||
const [searchParams, setSearchParams] = useSearchParams() | ||
const inviteId = searchParams.get('organization_invite') | ||
const orgId = searchParams.get('organization_id') | ||
|
||
function handleUserResponse() { | ||
searchParams.delete('organization_invite') | ||
searchParams.delete('organization_id') | ||
setSearchParams(searchParams) | ||
} | ||
|
||
// Avoid rendering anything if there is no invite in the URL | ||
if (!inviteId || !orgId) { | ||
return null | ||
} | ||
|
||
return <OrgInviteModal orgId={orgId} inviteId={inviteId} /> | ||
return <OrgInviteModal orgId={orgId} inviteId={inviteId} onUserResponse={handleUserResponse} /> | ||
} |