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

@docon/staff-portal

v1.0.1

Published

Standalone Thyrocare Staff Portal Component - Drop-in booking and ULC flow

Downloads

268

Readme

Staff Portal - Standalone Component

🚀 Quick Start (30 seconds)

import StaffPortal from './staff';

<StaffPortal
  authToken="your-jwt-token"
  apiKey="your-api-key"
  userCode="user123"
/>

Done! Staff portal is now embedded.


📦 What is this?

A completely standalone staff portal component that you can drop into any React app. No complex setup, no shared stores, just works.

Features

  • ✅ Prop-driven or storage-driven auth
  • ✅ Self-contained Redux store (no conflicts)
  • ✅ Works with any React app
  • ✅ Zero configuration needed
  • ✅ Booking flow + ULC flow
  • ✅ TypeScript support

🎯 Three Ways to Use

1. Props (Simplest - Recommended)

Parent app passes auth as props:

import StaffPortal from './staff';

function App() {
  const { authToken, apiKey } = useYourAuth();

  return (
    <StaffPortal
      authToken={authToken}
      apiKey={apiKey}
      userCode="user123"
      onLogout={() => handleLogout()}
    />
  );
}

2. Shared Storage

Parent app writes to storage, staff portal reads:

// Parent app: Write to storage
localStorage.setItem('AUTH_DATA', JSON.stringify({
  accessToken: 'token',
  apiKey: 'key',
}));

// Staff portal: Read from storage
<StaffPortal
  useSharedStorage={true}
  storageKey="AUTH_DATA"
/>

3. IndexedDB

For persistent storage across sessions:

import { storageService } from 'services';

// Parent app: Write to IndexedDB
await storageService.set('AUTH_DATA', {
  accessToken: 'token',
  apiKey: 'key',
});

// Staff portal: Read from IndexedDB
<StaffPortal
  useSharedStorage={true}
  storageKey="AUTH_DATA"
  storageType="indexedDB"
/>

📖 Props API

| Prop | Type | Default | Description | |------|------|---------|-------------| | authToken | string | - | JWT access token | | apiKey | string | - | Staff API key | | userCode | string | - | User code/ID | | user | object | - | User object | | useSharedStorage | boolean | false | Read auth from storage | | storageKey | string | 'AUTH_DATA' | Storage key name | | storageType | 'localStorage' | 'indexedDB' | 'localStorage' | Storage type | | onLogout | function | - | Logout callback | | onError | function | - | Error callback | | onAuthChange | function | - | Auth change callback | | basePath | string | '/staff' | Base route path | | showHeader | boolean | true | Show header | | headerTitle | string | 'Staff Portal' | Header title | | debug | boolean | false | Enable debug logs |


🎨 Examples

Basic Usage

<StaffPortal
  authToken="token"
  apiKey="key"
/>

With Callbacks

<StaffPortal
  authToken="token"
  apiKey="key"
  onLogout={() => {
    console.log('User logged out');
    navigate('/login');
  }}
  onError={(err) => {
    console.error('Error:', err);
  }}
/>

With React Router

import { Routes, Route } from 'react-router-dom';

<Routes>
  <Route path="/staff/*" element={
    <StaffPortal
      authToken={token}
      apiKey={key}
      basePath="/staff"  // Must match route
    />
  } />
</Routes>

Custom Styling

<StaffPortal
  authToken="token"
  apiKey="key"
  headerTitle="My Custom Portal"
  showHeader={true}
/>

Without Header

<div>
  <YourCustomHeader />
  <StaffPortal
    authToken="token"
    apiKey="key"
    showHeader={false}
  />
</div>

📂 File Structure

src/staff/
├── StaffPortalStandalone.tsx  # Main component
├── StaffPortalExamples.tsx    # 13 usage examples
├── index.ts                   # Package exports
├── pages/
│   ├── Dashboard.tsx          # Dashboard page
│   ├── BookingForm.tsx        # Booking flow
│   └── ThankYou.tsx           # Confirmation page
├── redux/
│   └── reducer/
│       ├── auth.ts            # Auth state
│       └── booking.ts         # Booking state
└── ...other staff files

🔧 Integration Guide

Step 1: Import

import StaffPortal from './staff';
// or
import { StaffPortalStandalone } from './staff';

Step 2: Add to your app

<StaffPortal
  authToken={yourAuthToken}
  apiKey={yourApiKey}
/>

Step 3: Done! 🎉

That's literally it.


🚦 Routes

When you embed the staff portal, it provides these routes:

  • /staff/dashboard - Main dashboard
  • /staff/booking - Booking form
  • /staff/thank-you - Order confirmation

All routes are prefixed with basePath prop (default: /staff).


🐛 Troubleshooting

Issue: "Auth not working"

Check: Are you passing auth props?

console.log({ authToken, apiKey }); // Should not be undefined

Issue: "Routes not found"

Check: Does basePath match your route?

// Parent route
<Route path="/staff/*" ... />

// Staff portal basePath
<StaffPortal basePath="/staff" />  // Must match!

Issue: "Styles missing"

Check: Is UI library installed?

npm install @docon/docon-ui-library

Issue: "Storage not syncing"

Check: Are you using the same storage key?

// Parent writes
localStorage.setItem('AUTH_DATA', ...);

// Staff reads
<StaffPortal storageKey="AUTH_DATA" />  // Must match!

🧪 Testing

// Test with hardcoded auth
<StaffPortal
  authToken="test-token"
  apiKey="test-key"
  userCode="test-user"
  debug={true}  // Enable logging
/>

Check browser console for debug logs.


📚 More Examples

See StaffPortalExamples.tsx for 13 detailed examples including:

  1. ✅ Simplest prop-driven
  2. ✅ With callbacks
  3. ✅ Storage-driven
  4. ✅ React Router integration
  5. ✅ Conditional rendering
  6. ✅ Custom styling
  7. ✅ Without header
  8. ✅ Debug mode
  9. ✅ IndexedDB storage
  10. ✅ Complete app integration
  11. ✅ Multiple instances
  12. ✅ Lazy loading
  13. ✅ Iframe alternative

🎁 Bonus: Custom Hook

import { useStaffPortal } from './staff/StaffPortalExamples';

function App() {
  const { isOpen, openStaffPortal, StaffPortalComponent } = useStaffPortal({
    authToken: 'token',
    apiKey: 'key',
  });

  return (
    <div>
      <button onClick={openStaffPortal}>Open Staff Portal</button>
      {StaffPortalComponent}
    </div>
  );
}

⏱️ Performance

  • Bundle size: ~200KB (with dependencies)
  • First load: < 2 seconds
  • Hot reload: < 500ms

🔐 Security

  • ✅ Auth passed via props (not in URL)
  • ✅ Isolated Redux store (no state leaks)
  • ✅ Token validation before API calls
  • ✅ HTTPS only in production

📦 Making it a Package (Optional)

To reuse across multiple apps:

1. Create package.json

{
  "name": "@thyrocare/staff-portal",
  "version": "1.0.0",
  "main": "dist/index.js",
  "types": "dist/index.d.ts",
  "peerDependencies": {
    "react": "^18.0.0",
    "react-router-dom": "^6.0.0",
    "@reduxjs/toolkit": "^1.9.0"
  }
}

2. Build

npm run build

3. Use in other apps

npm install @thyrocare/staff-portal
import StaffPortal from '@thyrocare/staff-portal';

🚀 Quick Implementation Timeline

Day 1 (4 hours)

  • ✅ Files already created
  • Import in parent app
  • Pass auth props
  • Test basic flow

Day 2 (4 hours)

  • Test booking flow end-to-end
  • Test ULC flow end-to-end
  • Handle edge cases

Day 3 (4 hours)

  • Add error handling
  • Add loading states
  • Polish UI

Day 4 (4 hours)

  • Full testing
  • Deploy to staging
  • Deploy to production

Total: 16 hours (4 days)


✅ Checklist

  • [ ] Import StaffPortal component
  • [ ] Pass auth props (token, apiKey, userCode)
  • [ ] Test dashboard loads
  • [ ] Test booking flow works
  • [ ] Test ULC flow works
  • [ ] Add onLogout callback
  • [ ] Add error handling
  • [ ] Test in production

📞 Support


🎯 Summary

Before:

  • Complex setup
  • Shared stores
  • Cross-app sync
  • 6 weeks implementation

Now:

  • One component
  • Pass props
  • Works immediately
  • 4 days implementation

Just import and use. It's that simple. 🚀


Staff Portal Standalone v1.0
Ready to use - No configuration needed