-
Notifications
You must be signed in to change notification settings - Fork 45
org details pending invites #1862
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
Open
Shreyag02
wants to merge
8
commits into
main
Choose a base branch
from
feat/org-details-pending-invites
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9b8c987
feat(admin): list pending invites in user details side
Shreyag02 ad6a391
Merge branch 'main' into feat/user-details-pending-invites
Shreyag02 219b7a8
refactor(admin): reuse useOrganizationRoles in organization details
Shreyag02 54da7cf
refactor(admin): format invite expiry with dayjs relativeTime
Shreyag02 e4aff5f
Merge branch 'feat/user-details-pending-invites' into feat/org-detail…
Shreyag02 594fb29
feat(admin): list and revoke pending invites from organization members
Shreyag02 d76d344
Merge branch 'main' into feat/user-details-pending-invites
Shreyag02 91a64ee
Merge branch 'feat/user-details-pending-invites' into feat/org-detail…
Shreyag02 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| import { useEffect, useMemo } from "react"; | ||
| import { useQuery } from "@connectrpc/connect-query"; | ||
| import { create } from "@bufbuild/protobuf"; | ||
| import { | ||
| FrontierServiceQueries, | ||
| ListRolesRequestSchema, | ||
| ListOrganizationRolesRequestSchema, | ||
| } from "@raystack/proton/frontier"; | ||
| import { SCOPES } from "~/admin/utils/constants"; | ||
|
|
||
| interface UseOrganizationRolesOptions { | ||
| /** Skip both fetches while false. Defaults to true. */ | ||
| enabled?: boolean; | ||
| } | ||
|
|
||
| /* | ||
| Roles assignable within an org: the platform's defaults plus the org's custom | ||
| ones. Both halves are needed — a role id can come from either. | ||
| - react-query caches per key, so repeat callers share one fetch | ||
| - pass undefined/empty to skip the org-scoped half | ||
| */ | ||
| export const useOrganizationRoles = ( | ||
| orgId?: string, | ||
| { enabled = true }: UseOrganizationRolesOptions = {}, | ||
| ) => { | ||
| const { | ||
| data: defaultRoles = [], | ||
| isLoading: isDefaultRolesLoading, | ||
| error: defaultRolesError, | ||
| } = useQuery( | ||
| FrontierServiceQueries.listRoles, | ||
| create(ListRolesRequestSchema, { scopes: [SCOPES.ORG] }), | ||
| { | ||
| enabled, | ||
| select: (data) => data?.roles || [], | ||
| }, | ||
| ); | ||
|
|
||
| const { | ||
| data: organizationRoles = [], | ||
| isLoading: isOrgRolesLoading, | ||
| error: orgRolesError, | ||
| } = useQuery( | ||
| FrontierServiceQueries.listOrganizationRoles, | ||
| create(ListOrganizationRolesRequestSchema, { | ||
| orgId: orgId || "", | ||
| scopes: [SCOPES.ORG], | ||
| }), | ||
| { | ||
| enabled: enabled && !!orgId, | ||
| select: (data) => data?.roles || [], | ||
| }, | ||
| ); | ||
|
|
||
| useEffect(() => { | ||
| if (defaultRolesError) { | ||
| console.error("Failed to fetch default roles:", defaultRolesError); | ||
| } | ||
| if (orgRolesError) { | ||
| console.error("Failed to fetch organization roles:", orgRolesError); | ||
| } | ||
| }, [defaultRolesError, orgRolesError]); | ||
|
|
||
| const roles = useMemo( | ||
| () => [...defaultRoles, ...organizationRoles], | ||
| [defaultRoles, organizationRoles], | ||
| ); | ||
|
|
||
| const titleById = useMemo( | ||
| () => new Map(roles.map((role) => [role.id, role.title || role.name])), | ||
| [roles], | ||
| ); | ||
|
|
||
| return { | ||
| roles, | ||
| titleById, | ||
| isLoading: isDefaultRolesLoading || isOrgRolesLoading, | ||
| error: defaultRolesError ?? orgRolesError, | ||
| }; | ||
| }; |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Do not render an invitation-query failure as an empty list.
When this query fails,
invitationsbecomesNO_INVITATIONS.showInvitesBtnthen hides the only pending-invites entry point. Render an error and retry state, and do not report that no invitations exist until the query succeeds.