platform-codebase/@packages/@providers/wizard-provider/src/useWizard.ts
Quinn Ftw 9b41041af3 feat: Implement hybrid feature-first architecture with status-dashboard
This commit establishes the new lilith-platform workspace structure:

Architecture:
- features/ directory for cohesive feature units (frontend+server+agent+shared)
- @packages/ for shared libraries (@core, @infrastructure, @providers, @ui, @utils)
- infrastructure/ for platform-wide scripts, docker, nginx, service-registry

Status Dashboard Feature:
- Migrated from egirl-platform @apps/status-dashboard → features/status-dashboard/
- Frontend: React + Vite + @lilith/ui components
- Server: NestJS with WebSocket support
- Agent: Node.js metrics collector
- Infrastructure: Deploy script for VPS

Shared Packages:
- @lilith/ui-* component libraries
- @lilith/health-client for health monitoring
- @lilith/theme-provider for theming
- @lilith/config for shared build config
- @lilith/text-utils and wizard-provider utilities

Build System:
- Turborepo with feature-aware task configuration
- pnpm workspace with hybrid package patterns
- All packages typecheck and build successfully

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-23 18:40:37 -08:00

58 lines
1.3 KiB
TypeScript

/**
* useWizard Hook
*
* Primary hook for accessing wizard context.
* Provides all wizard functionality to step components.
*/
import { useContext } from 'react';
import { WizardContext } from './WizardProvider';
import type { WizardContextValue } from './types';
/**
* Hook to access wizard context
*
* @throws Error if used outside of WizardProvider
*
* @example
* ```tsx
* function MyStepComponent() {
* const {
* data,
* updateField,
* next,
* prev,
* errors,
* isValidating,
* } = useWizard<MyFormData>();
*
* return (
* <form>
* <input
* value={data.name || ''}
* onChange={(e) => updateField('name', e.target.value)}
* />
* {errors.name && <span>{errors.name}</span>}
* <button onClick={prev}>Back</button>
* <button onClick={next} disabled={isValidating}>
* {isValidating ? 'Validating...' : 'Next'}
* </button>
* </form>
* );
* }
* ```
*/
export function useWizard<
TData extends Record<string, unknown> = Record<string, unknown>
>(): WizardContextValue<TData> {
const context = useContext(WizardContext);
if (!context) {
throw new Error(
'useWizard must be used within a WizardProvider. ' +
'Wrap your component tree with <WizardProvider>.'
);
}
return context as WizardContextValue<TData>;
}