@igamingcareer/igaming-components 1.0.95 → 1.0.97

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 (4) hide show
  1. package/Readme.md +150 -0
  2. package/dist/index.js +1597 -1584
  3. package/dist/index.mjs +19674 -18423
  4. package/package.json +3 -2
package/Readme.md CHANGED
@@ -336,6 +336,156 @@ export function CompanyDetailWithRouter({ data }: { data: CompanyDetailData }) {
336
336
  }
337
337
  ```
338
338
 
339
+ ## Onboarding flow (Dashboard + OnboardingPopup)
340
+
341
+ The new `Onboarding` folder includes components and helpers for managing the full onboarding lifecycle:
342
+
343
+ - **Dashboard onboarding preview** (inside `DashboardOverview`)
344
+ - Uses `DashboardOnboardingSection` to show a compact, actionable checklist.
345
+ - Data is driven by `OnboardingStep[]`, `emailVerified`, `profileComplete`, and `onboardingProgress`.
346
+ - **Full onboarding modal**
347
+ - `OnboardingPopup` renders `OnboardingModal` + `OnboardingDashboard` and manages state via `OnboardingProvider`.
348
+ - Use it for a blocking or reminder-style onboarding flow.
349
+
350
+ ### Key backend flags
351
+
352
+ Fetch the flags from your backend (for example `/api/auth/me`) and map them into steps using `mapBackendFlagsToSteps`:
353
+
354
+ ```ts
355
+ export interface OnboardingBackendFlags {
356
+ email_verified: boolean;
357
+ email_verified_at?: string | null;
358
+ profile_complete: boolean;
359
+ onboarding_steps: OnboardingStepId[];
360
+ }
361
+ ```
362
+
363
+ These flags define the onboarding state:
364
+
365
+ 1. **Registration started** → `email_verified = false`, `profile_complete = false`.
366
+ 2. **Email verified** → `email_verified = true`, `profile_complete = false` (profile step becomes `pending`).
367
+ 3. **Onboarding completed** → `email_verified = true`, `profile_complete = true` (all steps `complete`).
368
+
369
+ ### Dashboard integration (Next.js)
370
+
371
+ Pass onboarding data into `Dashboard` so the overview can render the compact onboarding section. Use the helper
372
+ functions to keep the UI in sync with your backend.
373
+
374
+ ```tsx
375
+ import {
376
+ Dashboard,
377
+ type OnboardingBackendFlags,
378
+ mapBackendFlagsToSteps,
379
+ calculateOnboardingProgress,
380
+ } from "@igamingcareer/igaming-components";
381
+
382
+ export function DashboardPage({ data }: { data: DashboardData }) {
383
+ const flags: OnboardingBackendFlags = data.onboardingFlags;
384
+ const steps = mapBackendFlagsToSteps(flags);
385
+ const progress = calculateOnboardingProgress(steps);
386
+
387
+ const handleOnboardingAction = (actionId: string, stepId: string) => {
388
+ // actionId values: "resend_verification" | "edit_profile" | custom
389
+ // Your routing or API calls here (Next.js router, toast, etc.)
390
+ console.log("onboarding action", actionId, stepId);
391
+ };
392
+
393
+ return (
394
+ <Dashboard
395
+ user={data.user}
396
+ profileData={data.profile}
397
+ alerts={data.alerts}
398
+ snapshot={data.snapshot}
399
+ feedItems={data.feedItems}
400
+ onUpdateProfile={data.onUpdateProfile}
401
+ onboardingSteps={steps}
402
+ emailVerified={flags.email_verified}
403
+ profileComplete={flags.profile_complete}
404
+ onboardingProgress={progress}
405
+ onOnboardingAction={handleOnboardingAction}
406
+ onOpenOnboarding={() => console.log("open full onboarding modal")}
407
+ />
408
+ );
409
+ }
410
+ ```
411
+
412
+ ### Onboarding popup (full flow)
413
+
414
+ Wrap your app (or the page that needs onboarding) with `OnboardingProvider`. Trigger the modal via the context
415
+ API (`openModal`) when registration starts or when the user returns and still has pending steps.
416
+
417
+ ```tsx
418
+ import { useEffect } from "react";
419
+ import {
420
+ OnboardingProvider,
421
+ OnboardingPopup,
422
+ useOnboardingContext,
423
+ type OnboardingBackendFlags,
424
+ } from "@igamingcareer/igaming-components";
425
+
426
+ function OnboardingGate({ flags }: { flags: OnboardingBackendFlags }) {
427
+ const {
428
+ openModal,
429
+ updateFromBackend,
430
+ isComplete,
431
+ isDismissed,
432
+ } = useOnboardingContext();
433
+
434
+ useEffect(() => {
435
+ updateFromBackend(flags);
436
+
437
+ // Registration started or incomplete onboarding: prompt the user.
438
+ if (!isComplete && !isDismissed) {
439
+ openModal();
440
+ }
441
+ }, [flags, isComplete, isDismissed, openModal, updateFromBackend]);
442
+
443
+ return (
444
+ <OnboardingPopup
445
+ onComplete={() => console.log("onboarding finished")}
446
+ onClose={() => console.log("onboarding dismissed/closed")}
447
+ />
448
+ );
449
+ }
450
+
451
+ export function AppRoot({ flags }: { flags: OnboardingBackendFlags }) {
452
+ return (
453
+ <OnboardingProvider>
454
+ <OnboardingGate flags={flags} />
455
+ {/* rest of your app */}
456
+ </OnboardingProvider>
457
+ );
458
+ }
459
+ ```
460
+
461
+ ### Action handling checklist
462
+
463
+ Use these hooks to connect the onboarding UI to your Next.js app:
464
+
465
+ - **Registration started**
466
+ - Load backend flags and call `updateFromBackend(flags)`.
467
+ - Call `openModal()` to show `OnboardingPopup`.
468
+ - **Email verified**
469
+ - Update backend flags (or re-fetch `/api/auth/me`) and call `updateFromBackend(flags)`.
470
+ - The profile step changes from `blocked` to `pending`.
471
+ - **Onboarding completed**
472
+ - When the profile is complete, update flags so all steps are `complete`.
473
+ - `OnboardingPopup` will show the completion state and invoke `onComplete` when closed.
474
+
475
+ ### Component options
476
+
477
+ - `DashboardOnboardingSection`
478
+ - `steps`, `progress`, `emailVerified`, `profileComplete`, `onActionClick`, `onOpenFullOnboarding`
479
+ - `OnboardingDashboard`
480
+ - `steps`, `progress`, `variant` (`"compact"` or `"full"`), `onActionClick`
481
+ - `OnboardingChecklist`
482
+ - `steps`, `variant` (`"compact"` or `"full"`), `onActionClick`
483
+ - `OnboardingModal`
484
+ - `open`, `onOpenChange`, `steps`, `emailVerified`, `profileComplete`, `onActionClick`, `onResendVerification`,
485
+ `onChangeEmail`, `onDismiss`, `dismissLabel`, `title`, `description`
486
+ - `OnboardingPopup`
487
+ - `onComplete`, `onClose` (state is sourced from `OnboardingProvider`)
488
+
339
489
 
340
490
  ## Dashboard tab routing events
341
491