feat(05-01): wire BackendSelectionStep to registry and remove dead export
- Replace hardcoded BACKENDS array with Object.entries(BACKEND_REGISTRY) - Import BACKEND_REGISTRY in BackendSelectionStep.tsx - Remove BackendFormValues<T> export from schemas/index.ts (dead code TECH-04) - TypeScript compiles with zero errors
This commit is contained in:
@@ -4,6 +4,7 @@ import { zodResolver } from '@hookform/resolvers/zod';
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { useWizard } from '../../store/context';
|
import { useWizard } from '../../store/context';
|
||||||
import type { BackendType } from '../../store/types';
|
import type { BackendType } from '../../store/types';
|
||||||
|
import { BACKEND_REGISTRY } from '../../schemas/registry';
|
||||||
import { BackendCard } from '../ui/BackendCard';
|
import { BackendCard } from '../ui/BackendCard';
|
||||||
|
|
||||||
const remoteNameSchema = z.object({
|
const remoteNameSchema = z.object({
|
||||||
@@ -18,23 +19,6 @@ const remoteNameSchema = z.object({
|
|||||||
|
|
||||||
type RemoteNameFormValues = z.infer<typeof remoteNameSchema>;
|
type RemoteNameFormValues = z.infer<typeof remoteNameSchema>;
|
||||||
|
|
||||||
const BACKENDS: { type: BackendType; name: string; description: string }[] = [
|
|
||||||
{
|
|
||||||
type: 'azureblob',
|
|
||||||
name: 'Azure Blob Storage',
|
|
||||||
description: 'Microsoft Azure cloud storage',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 's3',
|
|
||||||
name: 'Amazon S3',
|
|
||||||
description: 'AWS Simple Storage Service',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 's3-compatible',
|
|
||||||
name: 'S3-Compatible',
|
|
||||||
description: 'Wasabi, MinIO, Cloudflare R2, and others',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export function BackendSelectionStep() {
|
export function BackendSelectionStep() {
|
||||||
const { state, dispatch } = useWizard();
|
const { state, dispatch } = useWizard();
|
||||||
@@ -77,13 +61,13 @@ export function BackendSelectionStep() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div data-testid="backend-cards">
|
<div data-testid="backend-cards">
|
||||||
{BACKENDS.map((backend) => (
|
{Object.entries(BACKEND_REGISTRY).map(([type, entry]) => (
|
||||||
<BackendCard
|
<BackendCard
|
||||||
key={backend.type}
|
key={type}
|
||||||
name={backend.name}
|
name={entry.displayName}
|
||||||
description={backend.description}
|
description={entry.description}
|
||||||
selected={state.remote.backendType === backend.type}
|
selected={state.remote.backendType === type}
|
||||||
onClick={() => handleCardClick(backend.type)}
|
onClick={() => handleCardClick(type as BackendType)}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -23,6 +23,3 @@ export const BACKEND_SCHEMAS = {
|
|||||||
's3-compatible': buildZodSchema('s3-compatible'),
|
's3-compatible': buildZodSchema('s3-compatible'),
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// Utility type: infer TypeScript type from a backend's Zod schema
|
|
||||||
export type BackendFormValues<T extends BackendType> =
|
|
||||||
z.infer<typeof BACKEND_SCHEMAS[T]>;
|
|
||||||
|
|||||||
Reference in New Issue
Block a user