Skip to content

feat(react, examples): add service hook, container, and example apps#161

Open
rax7389 wants to merge 3 commits intofeat/mm-invitations-componentsfrom
feat/mm-invitations-hook-container
Open

feat(react, examples): add service hook, container, and example apps#161
rax7389 wants to merge 3 commits intofeat/mm-invitations-componentsfrom
feat/mm-invitations-hook-container

Conversation

@rax7389
Copy link
Copy Markdown
Contributor

@rax7389 rax7389 commented Mar 14, 2026

Changes

Summary: Adds the central useOrganizationMemberManagement hook for state management, a service layer hook for API abstraction, the OrganizationMemberManagement container component connecting the hook to the view layer, and example app integration with sidebar navigation.

Why: The presentational components from PR 3 are purely prop-driven. This PR provides the orchestration layer — a single hook that manages all invitation state (fetching, mutations, pagination, sorting, filtering, modals) and a container component that wires everything together. Separating the hook from the UI components keeps business logic testable and the view layer thin.

What:

useMemberManagementService Hook (Service Layer)

Abstraction layer for member management API calls, encapsulating all invitation CRUD operations via TanStack Query. This separates API concerns from UI state management.

const {
  invitationsQuery,
  providersQuery,
  createInvitationMutation,
  revokeInvitationMutation,
  resendInvitationMutation,
  fetchInvitationDetails,
} = useMemberManagementService(options);

useOrganizationMemberManagement Hook

Central hook managing all invitation lifecycle state:

  • Data fetching — Uses useMemberManagementService for queries and mutations.
  • Checkpoint pagination — Uses useCheckpointPagination (from PR 2) for token stack management.
  • Server-side sorting — Maps table column keys to API sort fields (e.g., created_atcreated-at).
  • Race condition handlinguseRef request ID tracking for details fetch to discard stale responses.
  • Toast notifications — Success/error feedback for all mutation outcomes.
const { state, handlers } = useOrganizationMemberManagement({
  defaultTab: 'invitations',
  createInvitationAction: {
    onBefore: (data) => { console.log('Creating:', data); return true; },
    onAfter: (data, result) => console.log('Created:', result),
  },
});

OrganizationMemberManagement Container Component

Connects the hook to the view layer with tab-based navigation (Members / Invitations), renders the invitation table and all modals (create, details, revoke, revoke-resend). Supports theming via getComponentStyles, readOnly mode, hideHeader, and custom CSS classes.

<OrganizationMemberManagement
  defaultTab="invitations"
  hideHeader={false}
  readOnly={false}
  createInvitationAction={{ onAfter: (data, result) => track('invite_sent') }}
  styling={{ classes: { 'OrganizationMemberManagement-root': 'my-custom-class' } }}
/>

Example App Integration

  • Added /member-management page to all example apps (next-rwa, react-spa-npm, react-spa-shadcn).
  • Added "Members & Invitations" sidebar link with Users icon.
  • Updated example scripts for member management resource servers.

Exports

  • Added OrganizationMemberManagement to components/index.ts
  • Added useOrganizationMemberManagement to hooks/index.ts

References

Part of the member management invitations feature.

Testing

  • This change adds unit test coverage

Integration tests are in PR 5.

  • This change has been tested on the latest version of the platform/language

Checklist

@rax7389 rax7389 force-pushed the feat/mm-invitations-components branch from 7b93170 to bf603bf Compare March 14, 2026 12:07
@rax7389 rax7389 force-pushed the feat/mm-invitations-hook-container branch from 2d3d1df to 312a1ae Compare March 14, 2026 12:07
@rax7389 rax7389 self-assigned this Mar 15, 2026
@rax7389 rax7389 added enhancement New feature or request examples Changes are limited to the examples folder. labels Mar 15, 2026
@rax7389 rax7389 changed the title feat(react): add invitation hook, container, and example app feat(react. examples): add invitation hook, container, and example app Mar 16, 2026
@rax7389 rax7389 force-pushed the feat/mm-invitations-components branch from bf603bf to e29c388 Compare March 29, 2026 17:44
@rax7389 rax7389 force-pushed the feat/mm-invitations-hook-container branch 2 times, most recently from b1ad377 to 1755393 Compare March 29, 2026 17:52
@rax7389 rax7389 force-pushed the feat/mm-invitations-components branch from 1333dcb to abd498c Compare April 8, 2026 09:04
@rax7389 rax7389 closed this Apr 8, 2026
@rax7389 rax7389 force-pushed the feat/mm-invitations-hook-container branch from 1755393 to abd498c Compare April 8, 2026 09:05
@rax7389 rax7389 reopened this Apr 8, 2026
@rax7389 rax7389 force-pushed the feat/mm-invitations-components branch from abd498c to 1397fc9 Compare April 8, 2026 10:44
@rax7389 rax7389 force-pushed the feat/mm-invitations-hook-container branch from dd0358c to 89fff00 Compare April 8, 2026 10:45
@rax7389 rax7389 force-pushed the feat/mm-invitations-components branch from 1397fc9 to 3fef17b Compare April 8, 2026 10:59
@rax7389 rax7389 force-pushed the feat/mm-invitations-hook-container branch from 89fff00 to f5d3f6e Compare April 8, 2026 11:00
@rax7389 rax7389 force-pushed the feat/mm-invitations-components branch from 3fef17b to 2b6461e Compare April 8, 2026 11:07
@rax7389 rax7389 force-pushed the feat/mm-invitations-hook-container branch from f5d3f6e to 2880189 Compare April 8, 2026 11:08
@rax7389 rax7389 force-pushed the feat/mm-invitations-components branch from 9f53be5 to e9c796d Compare April 8, 2026 11:17
@rax7389 rax7389 force-pushed the feat/mm-invitations-hook-container branch 2 times, most recently from 4184f90 to d1e9fd7 Compare April 8, 2026 11:24
@rax7389 rax7389 force-pushed the feat/mm-invitations-components branch from a831fdd to 53b1407 Compare April 8, 2026 11:33
@rax7389 rax7389 force-pushed the feat/mm-invitations-hook-container branch from d1e9fd7 to 5b79311 Compare April 8, 2026 11:33
@rax7389 rax7389 changed the title feat(react. examples): add invitation hook, container, and example app feat(react, examples): add service hook, container, and example apps Apr 8, 2026
@rax7389 rax7389 requested review from NaveenChand755, chakrihacker and harishsundar-okta and removed request for harishsundar-okta April 8, 2026 12:42
} from '@/types/my-organization/member-management/organization-member-management-types';

export const memberManagementQueryKeys = {
all: ['member-management'] as const,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be moved to core

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request examples Changes are limited to the examples folder.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants