AI-DLC: inception en ontwerp voor redesign B/E met contactformulier
Requirements, application design (incl. concept-API-contract voor het contactformulier), units en functional design voor U1. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
+61
@@ -0,0 +1,61 @@
|
||||
# Component Methods
|
||||
|
||||
Signatures are high-level. Business rules are detailed in Functional Design (U1, U3, U4).
|
||||
|
||||
## Theme
|
||||
```ts
|
||||
type Variant = 'b' | 'e';
|
||||
type Mode = 'light' | 'dark';
|
||||
resolveInitialMode(stored: string | null, systemPrefersDark: boolean): Mode;
|
||||
useTheme(): { variant: Variant; mode: Mode; toggleMode(): void; setVariant(v: Variant): void; toggleVariant(): void };
|
||||
```
|
||||
|
||||
## Packages (shared)
|
||||
```ts
|
||||
type PackageCardData = { id; slug; title; description; price; priceNote; features: string[]; ctaLabel; featured?: boolean; category?: string | null };
|
||||
usePackagesQuery(): UseQueryResult<PackageCardData[]>;
|
||||
usePackageFilter(packages: PackageCardData[]): { categories: { id: string; label: string; count: number }[]; active: string; setActive(id: string): void; visible: PackageCardData[]; showChips: boolean };
|
||||
useSwipeRow(itemCount: number, initialIndex: number): { ref: RefObject<HTMLElement>; activeIndex: number; scrollToIndex(i: number): void };
|
||||
```
|
||||
|
||||
## Contact preselect
|
||||
```ts
|
||||
useContactPreselect(): { subject: string | null; key: number; select(subject: string): void };
|
||||
```
|
||||
|
||||
## cms-client / contact (headless)
|
||||
```ts
|
||||
type ContactFields = { name: string; email: string; subject: string; message: string };
|
||||
type ContactErrorCode = 'required' | 'tooLong' | 'invalid';
|
||||
type ContactStatus = 'editing' | 'sending' | 'sent' | 'failed';
|
||||
|
||||
validateContact(values: ContactFields): Partial<Record<keyof ContactFields, ContactErrorCode>>;
|
||||
contactFormReducer(state: ContactState, event: ContactEvent): ContactState; // pure
|
||||
|
||||
createContactClient(opts?: { baseUrl?: string; fetch?: typeof fetch }): {
|
||||
getToken(): Promise<{ token: string; minSeconds: number; captcha: { provider: string; siteKey: string } | null }>;
|
||||
submit(payload: ContactPayload, ctx: { token: string; captchaToken?: string; idempotencyKey: string }): Promise<void>; // throws ContactApiError
|
||||
};
|
||||
|
||||
useContactForm(options: {
|
||||
idPrefix: string;
|
||||
subjectOptions: { value: string; label: string }[];
|
||||
preselect?: { subject: string | null; key: number }; // unknown value ignored
|
||||
submit?: ContactClient['submit']; // injectable
|
||||
messages?: Partial<ContactMessages>; // default nl
|
||||
now?: () => number;
|
||||
}): {
|
||||
status: ContactStatus; values: ContactFields; errors: Partial<Record<keyof ContactFields, string>>;
|
||||
getFieldProps(name: keyof ContactFields): { id; name; value; onChange; onBlur; 'aria-invalid'; 'aria-describedby' };
|
||||
honeypot: { name: string; ref; tabIndex: -1; autoComplete: 'off' };
|
||||
formProps: { onSubmit; noValidate: true };
|
||||
focusFirstError(): void;
|
||||
retry(): void;
|
||||
};
|
||||
```
|
||||
|
||||
## http
|
||||
```ts
|
||||
apiUrl(path: string): string; // VITE_API_BASE_URL ?? '' + path
|
||||
parseProblemDetails(res: Response): Promise<{ status: number; errors?: Record<string, string[]>; retryAfter?: number }>;
|
||||
```
|
||||
Reference in New Issue
Block a user