primus-saas-react 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/styles.css +568 -0
  2. package/package.json +15 -9
  3. package/DEMO.md +0 -68
  4. package/INTEGRATION.md +0 -702
  5. package/build_log.txt +0 -0
  6. package/postcss.config.js +0 -6
  7. package/src/components/ai/AICopilot.tsx +0 -88
  8. package/src/components/auth/PrimusLogin.tsx +0 -298
  9. package/src/components/auth/UserProfile.tsx +0 -26
  10. package/src/components/banking/accounts/AccountDashboard.tsx +0 -67
  11. package/src/components/banking/cards/CreditCardVisual.tsx +0 -67
  12. package/src/components/banking/credit/CreditScoreCard.tsx +0 -80
  13. package/src/components/banking/kyc/KYCVerification.tsx +0 -76
  14. package/src/components/banking/loans/LoanCalculator.tsx +0 -106
  15. package/src/components/banking/transactions/TransactionHistory.tsx +0 -74
  16. package/src/components/crud/PrimusDataTable.tsx +0 -220
  17. package/src/components/crud/PrimusModal.tsx +0 -68
  18. package/src/components/dashboard/PrimusDashboard.tsx +0 -145
  19. package/src/components/documents/DocumentViewer.tsx +0 -107
  20. package/src/components/featureflags/FeatureFlagToggle.tsx +0 -64
  21. package/src/components/insurance/agents/AgentDirectory.tsx +0 -72
  22. package/src/components/insurance/claims/ClaimStatusTracker.tsx +0 -78
  23. package/src/components/insurance/fraud/FraudDetectionDashboard.tsx +0 -68
  24. package/src/components/insurance/policies/PolicyCard.tsx +0 -77
  25. package/src/components/insurance/premium/PremiumCalculator.tsx +0 -104
  26. package/src/components/insurance/quotes/QuoteComparison.tsx +0 -75
  27. package/src/components/layout/PrimusHeader.tsx +0 -75
  28. package/src/components/layout/PrimusLayout.tsx +0 -47
  29. package/src/components/layout/PrimusSidebar.tsx +0 -102
  30. package/src/components/logging/LogViewer.tsx +0 -90
  31. package/src/components/notifications/NotificationFeed.tsx +0 -106
  32. package/src/components/notifications/PrimusNotificationCenter.tsx +0 -282
  33. package/src/components/payments/CheckoutForm.tsx +0 -167
  34. package/src/components/security/SecurityDashboard.tsx +0 -83
  35. package/src/components/shared/Button.tsx +0 -36
  36. package/src/components/shared/Input.tsx +0 -36
  37. package/src/components/storage/FileUploader.tsx +0 -79
  38. package/src/context/PrimusProvider.tsx +0 -156
  39. package/src/context/PrimusThemeProvider.tsx +0 -160
  40. package/src/hooks/useNotifications.ts +0 -58
  41. package/src/hooks/usePrimusAuth.ts +0 -3
  42. package/src/hooks/useRealtimeNotifications.ts +0 -114
  43. package/src/index.ts +0 -42
  44. package/tailwind.config.js +0 -18
  45. package/tsconfig.json +0 -28
package/INTEGRATION.md DELETED
@@ -1,702 +0,0 @@
1
- # Primus UI Components - Integration Guide
2
-
3
- ## Overview
4
-
5
- This guide shows developers **exactly how** to integrate Primus UI components into their React applications.
6
-
7
- ---
8
-
9
- ## Quick Start (5 Minutes)
10
-
11
- ### Step 1: Install the Package
12
-
13
- ```bash
14
- npm install @primus-saas/react
15
- ```
16
-
17
- ### Step 2: Wrap Your App
18
-
19
- ```tsx
20
- // src/main.tsx or src/index.tsx
21
- import { PrimusProvider } from '@primus-saas/react';
22
-
23
- ReactDOM.createRoot(document.getElementById('root')!).render(
24
- <PrimusProvider
25
- authority="https://your-backend-api.com"
26
- clientId="your-app-id"
27
- >
28
- <App />
29
- </PrimusProvider>
30
- );
31
- ```
32
-
33
- ### Step 3: Use Components
34
-
35
- ```tsx
36
- // src/pages/LoginPage.tsx
37
- import { PrimusLogin } from '@primus-saas/react';
38
-
39
- function LoginPage() {
40
- return <PrimusLogin allowSocial />;
41
- }
42
- ```
43
-
44
- **Done!** You now have a working login form.
45
-
46
- ---
47
-
48
- ## Component Catalog
49
-
50
- ### 🔐 Authentication Components
51
-
52
- #### `<PrimusLogin />`
53
-
54
- **Purpose:** Complete login form with email/password and social login options.
55
-
56
- **Installation:**
57
- ```bash
58
- npm install @primus-saas/react
59
- ```
60
-
61
- **Basic Usage:**
62
- ```tsx
63
- import { PrimusLogin } from '@primus-saas/react';
64
-
65
- function LoginPage() {
66
- return (
67
- <PrimusLogin
68
- allowSocial
69
- onSuccess={(user) => console.log('Logged in!', user)}
70
- />
71
- );
72
- }
73
- ```
74
-
75
- **With Navigation:**
76
- ```tsx
77
- import { PrimusLogin } from '@primus-saas/react';
78
- import { useNavigate } from 'react-router-dom';
79
-
80
- function LoginPage() {
81
- const navigate = useNavigate();
82
-
83
- return (
84
- <PrimusLogin
85
- allowSocial
86
- logo="/logo.png"
87
- title="Welcome to MyApp"
88
- onSuccess={(user) => {
89
- console.log('User logged in:', user);
90
- navigate('/dashboard');
91
- }}
92
- onError={(error) => {
93
- console.error('Login failed:', error);
94
- alert('Login failed: ' + error);
95
- }}
96
- />
97
- );
98
- }
99
- ```
100
-
101
- **Props:**
102
-
103
- | Prop | Type | Default | Description |
104
- |------|------|---------|-------------|
105
- | `allowSocial` | `boolean` | `true` | Show Google/GitHub buttons |
106
- | `logo` | `string` | `undefined` | URL to logo image |
107
- | `title` | `string` | `"Sign in to Primus SaaS"` | Form title |
108
- | `onSuccess` | `(user, token) => void` | `undefined` | Called after successful login |
109
- | `onError` | `(error) => void` | `undefined` | Called on login failure |
110
- | `showLoadingOverlay` | `boolean` | `true` | Show loading spinner |
111
-
112
- **Social Login Configuration:**
113
-
114
- The social login buttons (Google, GitHub) will call your backend's OAuth endpoints. You need to configure these in your backend:
115
-
116
- ```csharp
117
- // Backend: Program.cs
118
- builder.Services.AddPrimusIdentity(opts => {
119
- opts.Issuers = new[] {
120
- new IssuerConfig {
121
- Name = "Google",
122
- Type = "Google",
123
- ClientId = "your-google-client-id",
124
- ClientSecret = "your-google-secret"
125
- },
126
- new IssuerConfig {
127
- Name = "GitHub",
128
- Type = "GitHub",
129
- ClientId = "your-github-client-id",
130
- ClientSecret = "your-github-secret"
131
- }
132
- };
133
- });
134
- ```
135
-
136
- ---
137
-
138
- #### `<UserProfile />`
139
-
140
- **Purpose:** Display user information with avatar.
141
-
142
- **Usage:**
143
- ```tsx
144
- import { UserProfile, usePrimusAuth } from '@primus-saas/react';
145
-
146
- function Dashboard() {
147
- const { user } = usePrimusAuth();
148
-
149
- return (
150
- <UserProfile
151
- name={user?.name || 'Guest'}
152
- email={user?.email}
153
- avatar="/avatar.jpg"
154
- />
155
- );
156
- }
157
- ```
158
-
159
- **Props:**
160
-
161
- | Prop | Type | Description |
162
- |------|------|-------------|
163
- | `name` | `string` | User's display name |
164
- | `email` | `string` | User's email |
165
- | `avatar` | `string` | Avatar image URL |
166
- | `role` | `string` | User's role (optional) |
167
-
168
- ---
169
-
170
- ### 💳 Payment Components
171
-
172
- #### `<CheckoutForm />`
173
-
174
- **Purpose:** Complete payment form with card input.
175
-
176
- **Usage:**
177
- ```tsx
178
- import { CheckoutForm } from '@primus-saas/react';
179
-
180
- function CheckoutPage() {
181
- const handlePayment = async (paymentDetails) => {
182
- const response = await fetch('/api/payments/charge', {
183
- method: 'POST',
184
- headers: { 'Content-Type': 'application/json' },
185
- body: JSON.stringify({
186
- amount: 99.99,
187
- ...paymentDetails
188
- })
189
- });
190
-
191
- if (response.ok) {
192
- alert('Payment successful!');
193
- }
194
- };
195
-
196
- return (
197
- <CheckoutForm
198
- amount={99.99}
199
- currency="USD"
200
- onSubmit={handlePayment}
201
- />
202
- );
203
- }
204
- ```
205
-
206
- **Props:**
207
-
208
- | Prop | Type | Description |
209
- |------|------|-------------|
210
- | `amount` | `number` | Amount to charge (required) |
211
- | `currency` | `string` | Currency code (default: "USD") |
212
- | `onSubmit` | `(details) => Promise<void>` | Payment handler |
213
-
214
- **Backend Integration:**
215
-
216
- ```csharp
217
- // Backend: PaymentsController.cs
218
- [HttpPost("charge")]
219
- public async Task<IActionResult> Charge([FromBody] ChargeRequest request)
220
- {
221
- var result = await _stripeService.ChargeAsync(
222
- request.Amount,
223
- request.CardToken
224
- );
225
-
226
- return Ok(new { success = true, chargeId = result.Id });
227
- }
228
- ```
229
-
230
- ---
231
-
232
- ### 🏦 Banking Components
233
-
234
- #### `<CreditCardVisual />`
235
-
236
- **Purpose:** 3D credit card display.
237
-
238
- **Usage:**
239
- ```tsx
240
- import { CreditCardVisual } from '@primus-saas/react';
241
-
242
- function WalletPage() {
243
- return (
244
- <CreditCardVisual
245
- cardHolder="JOHN DOE"
246
- last4="4242"
247
- expiry="12/28"
248
- variant="platinum"
249
- brand="visa"
250
- />
251
- );
252
- }
253
- ```
254
-
255
- **Props:**
256
-
257
- | Prop | Type | Options | Description |
258
- |------|------|---------|-------------|
259
- | `cardHolder` | `string` | - | Name on card |
260
- | `last4` | `string` | - | Last 4 digits |
261
- | `expiry` | `string` | - | MM/YY format |
262
- | `variant` | `string` | `'black'`, `'gold'`, `'platinum'` | Card theme |
263
- | `brand` | `string` | `'visa'`, `'mastercard'` | Card network |
264
-
265
- ---
266
-
267
- #### `<TransactionHistory />`
268
-
269
- **Purpose:** List of transactions with filters.
270
-
271
- **Usage:**
272
- ```tsx
273
- import { TransactionHistory } from '@primus-saas/react';
274
-
275
- function TransactionsPage() {
276
- const transactions = [
277
- {
278
- id: '1',
279
- description: 'Coffee Shop',
280
- amount: -4.50,
281
- date: '2024-01-15',
282
- category: 'Food'
283
- },
284
- {
285
- id: '2',
286
- description: 'Salary Deposit',
287
- amount: 5000.00,
288
- date: '2024-01-01',
289
- category: 'Income'
290
- }
291
- ];
292
-
293
- return <TransactionHistory transactions={transactions} />;
294
- }
295
- ```
296
-
297
- **Props:**
298
-
299
- | Prop | Type | Description |
300
- |------|------|-------------|
301
- | `transactions` | `Transaction[]` | Array of transaction objects |
302
- | `onFilter` | `(filter) => void` | Filter callback |
303
-
304
- ---
305
-
306
- ### 🏥 Insurance Components
307
-
308
- #### `<PolicyCard />`
309
-
310
- **Purpose:** Insurance policy summary card.
311
-
312
- **Usage:**
313
- ```tsx
314
- import { PolicyCard } from '@primus-saas/react';
315
-
316
- function PoliciesPage() {
317
- return (
318
- <PolicyCard
319
- policyNumber="POL-2024-001"
320
- type="Auto Insurance"
321
- status="active"
322
- coverageAmount={50000}
323
- premiumAmount={150}
324
- renewalDate="2024-12-31"
325
- />
326
- );
327
- }
328
- ```
329
-
330
- **Props:**
331
-
332
- | Prop | Type | Options | Description |
333
- |------|------|---------|-------------|
334
- | `policyNumber` | `string` | - | Policy ID |
335
- | `type` | `string` | - | Policy type (Auto, Home, Life) |
336
- | `status` | `string` | `'active'`, `'pending'`, `'expired'` | Status |
337
- | `coverageAmount` | `number` | - | Coverage limit |
338
- | `premiumAmount` | `number` | - | Monthly premium |
339
- | `renewalDate` | `string` | - | Renewal date |
340
-
341
- ---
342
-
343
- #### `<ClaimStatusTracker />`
344
-
345
- **Purpose:** Visual claim progress tracker.
346
-
347
- **Usage:**
348
- ```tsx
349
- import { ClaimStatusTracker } from '@primus-saas/react';
350
-
351
- function ClaimPage() {
352
- return (
353
- <ClaimStatusTracker
354
- claimNumber="CLM-2024-001"
355
- currentStatus="under_review"
356
- estimatedCompletion="2024-02-15"
357
- />
358
- );
359
- }
360
- ```
361
-
362
- ---
363
-
364
- ### 📧 Notification Components
365
-
366
- #### `<NotificationFeed />`
367
-
368
- **Purpose:** Real-time notification list.
369
-
370
- **Usage:**
371
- ```tsx
372
- import { NotificationFeed } from '@primus-saas/react';
373
-
374
- function DashboardPage() {
375
- const notifications = [
376
- {
377
- id: '1',
378
- title: 'Payment Received',
379
- message: 'Your payment of $99.99 was processed',
380
- timestamp: '2024-01-15T10:30:00Z',
381
- read: false
382
- }
383
- ];
384
-
385
- return (
386
- <NotificationFeed
387
- notifications={notifications}
388
- onMarkAsRead={(id) => console.log('Mark as read:', id)}
389
- />
390
- );
391
- }
392
- ```
393
-
394
- ---
395
-
396
- ### 📄 Document Components
397
-
398
- #### `<DocumentViewer />`
399
-
400
- **Purpose:** PDF and image viewer.
401
-
402
- **Usage:**
403
- ```tsx
404
- import { DocumentViewer } from '@primus-saas/react';
405
-
406
- function InvoicePage() {
407
- return (
408
- <DocumentViewer
409
- url="/invoices/2024-001.pdf"
410
- type="pdf"
411
- title="Invoice #2024-001"
412
- />
413
- );
414
- }
415
- ```
416
-
417
- ---
418
-
419
- ## Complete Integration Example
420
-
421
- ### Scenario: Add Login to Existing React App
422
-
423
- **Your Existing App:**
424
- ```
425
- my-react-app/
426
- ├── src/
427
- │ ├── App.tsx
428
- │ ├── pages/
429
- │ │ ├── HomePage.tsx
430
- │ │ └── DashboardPage.tsx
431
- │ └── main.tsx
432
- └── package.json
433
- ```
434
-
435
- ### Step 1: Install Package
436
-
437
- ```bash
438
- npm install @primus-saas/react react-router-dom
439
- ```
440
-
441
- ### Step 2: Update `main.tsx`
442
-
443
- ```tsx
444
- import React from 'react';
445
- import ReactDOM from 'react-dom/client';
446
- import { BrowserRouter } from 'react-router-dom';
447
- import { PrimusProvider } from '@primus-saas/react';
448
- import App from './App';
449
-
450
- ReactDOM.createRoot(document.getElementById('root')!).render(
451
- <React.StrictMode>
452
- <BrowserRouter>
453
- <PrimusProvider
454
- authority="http://localhost:5000"
455
- clientId="my-app"
456
- onLoginSuccess={(user, token) => {
457
- console.log('User logged in:', user);
458
- localStorage.setItem('token', token);
459
- }}
460
- onLoginError={(error) => {
461
- console.error('Login failed:', error);
462
- }}
463
- >
464
- <App />
465
- </PrimusProvider>
466
- </BrowserRouter>
467
- </React.StrictMode>
468
- );
469
- ```
470
-
471
- ### Step 3: Create `LoginPage.tsx`
472
-
473
- ```tsx
474
- import { PrimusLogin } from '@primus-saas/react';
475
- import { useNavigate } from 'react-router-dom';
476
-
477
- export function LoginPage() {
478
- const navigate = useNavigate();
479
-
480
- return (
481
- <div className="min-h-screen flex items-center justify-center bg-gray-100">
482
- <PrimusLogin
483
- allowSocial
484
- logo="/logo.png"
485
- title="Welcome to MyApp"
486
- onSuccess={() => navigate('/dashboard')}
487
- />
488
- </div>
489
- );
490
- }
491
- ```
492
-
493
- ### Step 4: Update `App.tsx` with Routes
494
-
495
- ```tsx
496
- import { Routes, Route, Navigate } from 'react-router-dom';
497
- import { usePrimusAuth } from '@primus-saas/react';
498
- import { LoginPage } from './pages/LoginPage';
499
- import { DashboardPage } from './pages/DashboardPage';
500
-
501
- function ProtectedRoute({ children }: { children: React.ReactNode }) {
502
- const { isAuthenticated } = usePrimusAuth();
503
- return isAuthenticated ? <>{children}</> : <Navigate to="/login" />;
504
- }
505
-
506
- function App() {
507
- return (
508
- <Routes>
509
- <Route path="/login" element={<LoginPage />} />
510
- <Route
511
- path="/dashboard"
512
- element={
513
- <ProtectedRoute>
514
- <DashboardPage />
515
- </ProtectedRoute>
516
- }
517
- />
518
- <Route path="/" element={<Navigate to="/dashboard" />} />
519
- </Routes>
520
- );
521
- }
522
-
523
- export default App;
524
- ```
525
-
526
- ### Step 5: Use Auth State in Dashboard
527
-
528
- ```tsx
529
- import { usePrimusAuth, UserProfile } from '@primus-saas/react';
530
-
531
- export function DashboardPage() {
532
- const { user, logout } = usePrimusAuth();
533
-
534
- return (
535
- <div>
536
- <header>
537
- <UserProfile
538
- name={user?.name || 'Guest'}
539
- email={user?.email}
540
- />
541
- <button onClick={logout}>Logout</button>
542
- </header>
543
-
544
- <main>
545
- <h1>Welcome, {user?.name}!</h1>
546
- </main>
547
- </div>
548
- );
549
- }
550
- ```
551
-
552
- **Done!** Your app now has authentication.
553
-
554
- ---
555
-
556
- ## Framework-Specific Guides
557
-
558
- ### Next.js Integration
559
-
560
- ```tsx
561
- // app/providers.tsx
562
- 'use client';
563
-
564
- import { PrimusProvider } from '@primus-saas/react';
565
-
566
- export function Providers({ children }: { children: React.ReactNode }) {
567
- return (
568
- <PrimusProvider authority={process.env.NEXT_PUBLIC_API_URL!} clientId="nextjs-app">
569
- {children}
570
- </PrimusProvider>
571
- );
572
- }
573
- ```
574
-
575
- ```tsx
576
- // app/layout.tsx
577
- import { Providers } from './providers';
578
-
579
- export default function RootLayout({ children }: { children: React.ReactNode }) {
580
- return (
581
- <html>
582
- <body>
583
- <Providers>{children}</Providers>
584
- </body>
585
- </html>
586
- );
587
- }
588
- ```
589
-
590
- ### Vite Integration
591
-
592
- ```tsx
593
- // src/main.tsx
594
- import { PrimusProvider } from '@primus-saas/react';
595
-
596
- ReactDOM.createRoot(document.getElementById('root')!).render(
597
- <PrimusProvider authority={import.meta.env.VITE_API_URL} clientId="vite-app">
598
- <App />
599
- </PrimusProvider>
600
- );
601
- ```
602
-
603
- ---
604
-
605
- ## Styling & Customization
606
-
607
- ### Using Tailwind CSS (Recommended)
608
-
609
- Primus components use Tailwind CSS. Install it:
610
-
611
- ```bash
612
- npm install -D tailwindcss postcss autoprefixer
613
- npx tailwindcss init -p
614
- ```
615
-
616
- ```js
617
- // tailwind.config.js
618
- export default {
619
- content: [
620
- "./index.html",
621
- "./src/**/*.{js,ts,jsx,tsx}",
622
- "./node_modules/@primus-saas/react/**/*.{js,ts,jsx,tsx}"
623
- ],
624
- theme: {
625
- extend: {
626
- colors: {
627
- 'primus-600': '#646cff',
628
- 'primus-700': '#535bf2',
629
- }
630
- }
631
- }
632
- }
633
- ```
634
-
635
- ### Custom Styling
636
-
637
- ```tsx
638
- <PrimusLogin
639
- className="custom-login-form"
640
- style={{ maxWidth: '400px' }}
641
- />
642
- ```
643
-
644
- ---
645
-
646
- ## TypeScript Support
647
-
648
- All components have full TypeScript definitions:
649
-
650
- ```tsx
651
- import type { PrimusLoginProps, PrimusUser } from '@primus-saas/react';
652
-
653
- const loginProps: PrimusLoginProps = {
654
- allowSocial: true,
655
- onSuccess: (user: PrimusUser, token: string) => {
656
- console.log(user.email);
657
- }
658
- };
659
- ```
660
-
661
- ---
662
-
663
- ## Troubleshooting
664
-
665
- ### "Module not found: @primus-saas/react"
666
-
667
- **Solution:** Install the package:
668
- ```bash
669
- npm install @primus-saas/react
670
- ```
671
-
672
- ### "usePrimusAuth must be used within PrimusProvider"
673
-
674
- **Solution:** Wrap your app with `<PrimusProvider>`:
675
- ```tsx
676
- <PrimusProvider authority="..." clientId="...">
677
- <App />
678
- </PrimusProvider>
679
- ```
680
-
681
- ### Social login buttons don't work
682
-
683
- **Solution:** Configure OAuth providers in your backend:
684
- ```csharp
685
- builder.Services.AddPrimusIdentity(opts => {
686
- opts.Issuers = new[] {
687
- new IssuerConfig { Name = "Google", Type = "Google", ... }
688
- };
689
- });
690
- ```
691
-
692
- ---
693
-
694
- ## Next Steps
695
-
696
- 1. ✅ Install `@primus-saas/react`
697
- 2. ✅ Wrap app with `<PrimusProvider>`
698
- 3. ✅ Add `<PrimusLogin />` to login page
699
- 4. ✅ Use `usePrimusAuth()` hook for auth state
700
- 5. ✅ Add other components as needed
701
-
702
- **Need help?** Check the [Integration Guide](INTEGRATION_GUIDE.md) or [GitHub Issues](https://github.com/primussoft/Primus-SaaS-Framework/issues).
package/build_log.txt DELETED
Binary file
package/postcss.config.js DELETED
@@ -1,6 +0,0 @@
1
- module.exports = {
2
- plugins: {
3
- tailwindcss: {},
4
- autoprefixer: {},
5
- },
6
- }