npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rxbenefits/admin

v1.0.0

Published

Administrative functionality for RxBenefits platform including user management, roles, and permissions

Readme

@rxbenefits/admin

Administrative functionality for the RxBenefits platform including user management, roles, permissions, and feature flags.

npm version License: MIT TypeScript React

📋 Table of Contents

🎯 Overview

The @rxbenefits/admin package provides a comprehensive suite of administrative tools for the RxBenefits platform. It includes user management, role-based access control, feature flags administration, and user import/export functionality.

Key Capabilities

  • User Management: Create, edit, view, and manage users across the platform
  • Role-Based Access Control: Comprehensive roles and permissions system
  • User Import: Import users from DataNet or other external systems
  • Feature Flags: Admin interface for managing feature flags
  • Multi-Tenant Support: Organization-based user management
  • User Types: Support for Internal, Broker, and Client user types

✨ Features

User Management

  • Create new users (Internal, Broker, Client types)
  • Edit existing user details
  • View comprehensive user information
  • Import users from external systems
  • Manage user activation/deactivation
  • Assign roles and permissions
  • Manage organizational access

Role Management

  • View and manage user roles
  • Assign roles to users
  • Role-based permission system
  • Custom role configurations

Feature Flags Administration

  • View all feature flags
  • Enable/disable feature flags
  • Real-time feature flag management
  • Developer-only access control

Organization Management

  • Assign users to organizations
  • Manage benefit group access
  • Multi-organization support
  • Organization-level permissions

📦 Installation

# Using yarn
yarn add @rxbenefits/admin

# Using npm
npm install @rxbenefits/admin

Peer Dependencies

This package requires the following peer dependencies:

{
  "react": "^18.0.0",
  "react-dom": "^18.0.0"
}

Additional Dependencies

The package also depends on other RxBenefits packages:

yarn add @rxbenefits/api @rxbenefits/components @rxbenefits/constants \
         @rxbenefits/contexts @rxbenefits/forms @rxbenefits/hooks \
         @rxbenefits/types @rxbenefits/ui @rxbenefits/utils

🚀 Usage

Basic Usage

import { AdminModule } from '@rxbenefits/admin';
import { ModuleConfig } from '@rxbenefits/contexts';

function App() {
  return (
    <ModuleConfig basePath="/admin">
      <AdminModule basePath="/admin" />
    </ModuleConfig>
  );
}

User Management

import { AdminCreateUser, AdminUsers, AdminUserDetail } from '@rxbenefits/admin';
import { Route, Routes } from 'react-router-dom';

function UserManagement() {
  return (
    <Routes>
      <Route path="/users" element={<AdminUsers />} />
      <Route path="/users/create" element={<AdminCreateUser />} />
      <Route path="/users/:id" element={<AdminUserDetail />} />
    </Routes>
  );
}

Role Management

import { AdminRoles } from '@rxbenefits/admin';

function RoleManagement() {
  return <AdminRoles />;
}

Feature Flags Administration

import { AdminFeatureFlags } from '@rxbenefits/admin';

function FeatureFlagsAdmin() {
  return <AdminFeatureFlags />;
}

User Import

import { ImportUser } from '@rxbenefits/admin';

function UserImport() {
  return <ImportUser />;
}

📚 Components

AdminModule

Main module component that provides routing for all admin features.

Props:

  • basePath: string - Base path for admin routes

Example:

<AdminModule basePath="/admin" />

AdminUsers

User list component with search, filtering, and pagination.

Features:

  • Display paginated list of users
  • Search by name, email, organization
  • Filter by user type, status, role
  • Quick actions (view, edit, deactivate)

Example:

<AdminUsers />

AdminCreateUser

User creation form with validation and role assignment.

Features:

  • User type selection (Internal, Broker, Client)
  • User details form
  • Organization selection
  • Role and permission assignment
  • Benefit group management
  • User activation toggle

Example:

<AdminCreateUser />

AdminUserDetail

User detail view and edit form.

Features:

  • View/edit user information
  • Update roles and permissions
  • Manage organizational access
  • Update user status
  • View user activity

Example:

<AdminUserDetail />

AdminRoles

Role management interface.

Features:

  • View all available roles
  • Role descriptions and permissions
  • Role assignment interface

Example:

<AdminRoles />

AdminFeatureFlags

Feature flags administration interface.

Features:

  • View all feature flags
  • Enable/disable flags
  • Real-time updates
  • Developer-only access

Example:

<AdminFeatureFlags />

ImportUser

User import from external systems (DataNet).

Features:

  • Email-based user lookup
  • Preview user data
  • Import user to Optimize platform
  • Error handling and validation

Example:

<ImportUser />

🎣 Hooks

useCurrentUser

Hook to get current user information and permissions.

Returns:

  • currentUser - Current user object
  • currentUserAccess - Current user access permissions
  • currentUserOrganizations - Current user's organizations
  • isCurrentUserRxBAdmin - Whether current user is RxB admin
  • isCurrentUserLoading - Loading state
  • userData - Extended user data
  • isUserDataLoading - User data loading state

Example:

import { useCurrentUser } from '@rxbenefits/admin';

function MyComponent() {
  const { currentUser, isCurrentUserRxBAdmin } = useCurrentUser();
  
  if (isCurrentUserRxBAdmin) {
    return <div>Admin features</div>;
  }
  
  return <div>Regular features</div>;
}

useEditUser

Hook for editing user information.

Parameters:

  • userId: number - User ID to edit

Returns:

  • userData - User data
  • isLoading - Loading state
  • updateUser - Function to update user
  • isUpdating - Update in progress state

Example:

import { useEditUser } from '@rxbenefits/admin';

function EditUserComponent({ userId }) {
  const { userData, updateUser, isUpdating } = useEditUser(userId);
  
  const handleUpdate = (data) => {
    updateUser(data, {
      onSuccess: () => console.log('User updated'),
      onError: (error) => console.error('Update failed', error)
    });
  };
  
  return <div>Edit user form</div>;
}

useSelectedSet

Hook for managing selected items (roles, organizations, etc.).

Returns:

  • [selected, setSelected, handleUpdates] - Array of selected items, setter, and update handler

Example:

import { useSelectedSet } from '@rxbenefits/admin';

function RoleSelection() {
  const [selectedRoles, setSelectedRoles, handleRoleUpdates] = useSelectedSet<number>([]);
  
  const handleRoleChange = (roleId: number, checked: boolean) => {
    handleRoleUpdates(roleId, checked);
  };
  
  return <div>Role selection UI</div>;
}

🛠️ Development

Setup

# Clone the repository
git clone https://github.com/rxbenefits/admin.git
cd admin

# Install dependencies
yarn install

# Run tests
yarn test

# Build the package
yarn build

Scripts

  • yarn build - Build the package for production
  • yarn test - Run the test suite
  • yarn test:watch - Run tests in watch mode
  • yarn test:coverage - Generate test coverage report
  • yarn lint - Lint the codebase
  • yarn lint:fix - Fix linting issues
  • yarn typecheck - Run TypeScript type checking
  • yarn clean - Clean build artifacts

Testing

# Run all tests
yarn test

# Run tests in watch mode
yarn test:watch

# Generate coverage report
yarn test:coverage

Building

# Build for production
yarn build

# Clean and rebuild
yarn clean && yarn build

📝 API Reference

Types

import {
  UserType,
  AuthUser,
  CreateAuthUserRequest,
  UpdateAuthUserRequest,
  AuthCreateUserOrgs,
  SelectedBenefitGroups
} from '@rxbenefits/admin';

Constants

import {
  MANAGE_USER_PERMISSIONS,
  ORGANIZATION_PERMISSIONS
} from '@rxbenefits/admin';

Utilities

import {
  filterTransferOptions,
  scrollToError,
  RoleGroupMappings
} from '@rxbenefits/admin';

🔒 Security

Authentication

All admin features require authentication via Auth0. Users must be logged in to access any admin functionality.

Authorization

Admin features use role-based access control (RBAC):

  • View Users: Requires MANAGE_USER_PERMISSIONS.VIEW and ORGANIZATION_PERMISSIONS.AUTH_VIEW
  • Create Users: Requires MANAGE_USER_PERMISSIONS.ADD and ORGANIZATION_PERMISSIONS.AUTH_VIEW
  • Edit Users: Requires MANAGE_USER_PERMISSIONS.EDIT and ORGANIZATION_PERMISSIONS.AUTH_VIEW
  • Import Users: Requires MANAGE_USER_PERMISSIONS.IMPORTDNUSER
  • View Roles: Requires specific role permissions
  • Feature Flags: Requires developer permissions

Data Protection

  • All user data is encrypted in transit and at rest
  • HIPAA compliance for protected health information
  • Audit logging for all administrative actions
  • Multi-factor authentication support

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Process

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Add tests for your changes
  5. Run tests and linting (yarn test && yarn lint)
  6. Commit your changes (git commit -m 'Add amazing feature')
  7. Push to the branch (git push origin feature/amazing-feature)
  8. Open a Pull Request

Code Style

  • Follow the existing code style
  • Use TypeScript for all new code
  • Write tests for new features
  • Update documentation as needed
  • Use meaningful commit messages

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🔗 Related Packages

📞 Support

For support, please contact:

📊 Changelog

See CHANGELOG.md for a list of changes.


Made with ❤️ by RxBenefits