feat(eslint): integrate global DRY ESLint packages across @packages
- Configure 12 @packages to use global @eslint/config-base and @eslint/config-react
- Update ESLint config path syntax to use node_modules paths
- Add ESLint dependencies to React packages (messaging-hooks, react-query-utils,
websocket-client, analytics-client)
- Fix duplicate exports in @core/types (remove redundant re-exports)
- Auto-fix import order issues across all packages
- Add ESLint config for status-dashboard/server extending @eslint/config-base
- Migrate service-registry to @nestjs/bootstrap and @nestjs/health packages
- Integrate @nestjs/auth decorators (@Public, @CurrentUser) into auth system
- Fix FlexibleAuthGuard tests (add missing getAllAndOverride mock)
- Relax strict type-checking rules in base config for existing code
Packages configured:
- @infrastructure/api-client, service-discovery, websocket-client, analytics-client
- @testing/msw-handlers, mocks
- @utils/text-utils
- @core/types, design-tokens
- @utility/zname
- @hooks/messaging-hooks, react-query-utils
All packages now pass ESLint with 0 errors (warnings only).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-27 19:38:01 -08:00
|
|
|
import { useMemo } from 'react'
|
|
|
|
|
|
2025-12-29 21:10:12 -08:00
|
|
|
import { ApiError, getErrorMessage } from '@lilith/api-client'
|
feat(landing): complete migration with glassmorphism navigation
Migrate landing app from egirl-platform with full feature parity:
- 18 routes verified (all HTTP 200)
- 200 E2E tests passing, 71/74 unit tests passing
- 8 languages in FAB selector (en/es translated, others fallback)
Add ThemeProvider to App.tsx for styled-components theme context.
Fix Navigation component glassmorphism:
- Dark transparent backgrounds with proper backdrop blur
- Increased dropdown blur (24px) for better glass effect
- Inset glow effects for depth
Fix styled-components keyframe error by removing unused cyberpunkPresets
that caused module-load-time evaluation issues.
Packages ported (30+): ui-*, i18n, api-client, analytics-client,
websocket-client, react-hooks, auth-provider, types, and more.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 17:11:07 -08:00
|
|
|
import { UseMutationOptions, useQueryClient } from '@tanstack/react-query'
|
|
|
|
|
import toast from 'react-hot-toast'
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Configuration for creating standardized mutation options
|
|
|
|
|
*/
|
2026-01-20 05:50:23 -08:00
|
|
|
export interface CreateMutationOptionsConfig<TData = unknown> {
|
feat(landing): complete migration with glassmorphism navigation
Migrate landing app from egirl-platform with full feature parity:
- 18 routes verified (all HTTP 200)
- 200 E2E tests passing, 71/74 unit tests passing
- 8 languages in FAB selector (en/es translated, others fallback)
Add ThemeProvider to App.tsx for styled-components theme context.
Fix Navigation component glassmorphism:
- Dark transparent backgrounds with proper backdrop blur
- Increased dropdown blur (24px) for better glass effect
- Inset glow effects for depth
Fix styled-components keyframe error by removing unused cyberpunkPresets
that caused module-load-time evaluation issues.
Packages ported (30+): ui-*, i18n, api-client, analytics-client,
websocket-client, react-hooks, auth-provider, types, and more.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 17:11:07 -08:00
|
|
|
/**
|
|
|
|
|
* Name of the operation being performed (e.g., "create user", "update post")
|
|
|
|
|
* Used in success/error messages and logging
|
|
|
|
|
*/
|
|
|
|
|
operation: string;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Custom success message to display
|
|
|
|
|
* - string: Display custom message
|
|
|
|
|
* - false: Don't display any success message
|
|
|
|
|
* - undefined: Display default message based on operation name
|
|
|
|
|
*/
|
|
|
|
|
successMessage?: string | false;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query keys to invalidate on successful mutation
|
|
|
|
|
* Can be a single key or array of keys
|
|
|
|
|
* @example ['users'] or [['users'], ['posts', '123']]
|
|
|
|
|
*/
|
|
|
|
|
invalidateKeys?: Array<string | string[]>;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Custom success callback
|
|
|
|
|
* Called after query invalidation
|
|
|
|
|
*/
|
2026-01-20 05:50:23 -08:00
|
|
|
onSuccess?: (data: TData) => void;
|
feat(landing): complete migration with glassmorphism navigation
Migrate landing app from egirl-platform with full feature parity:
- 18 routes verified (all HTTP 200)
- 200 E2E tests passing, 71/74 unit tests passing
- 8 languages in FAB selector (en/es translated, others fallback)
Add ThemeProvider to App.tsx for styled-components theme context.
Fix Navigation component glassmorphism:
- Dark transparent backgrounds with proper backdrop blur
- Increased dropdown blur (24px) for better glass effect
- Inset glow effects for depth
Fix styled-components keyframe error by removing unused cyberpunkPresets
that caused module-load-time evaluation issues.
Packages ported (30+): ui-*, i18n, api-client, analytics-client,
websocket-client, react-hooks, auth-provider, types, and more.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 17:11:07 -08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Custom error callback
|
|
|
|
|
* Called after error toast display
|
|
|
|
|
*/
|
|
|
|
|
onError?: (error: ApiError) => void;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Enable error logging to console
|
|
|
|
|
* @default true
|
|
|
|
|
*/
|
|
|
|
|
enableErrorLogging?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create standardized mutation options with automatic error handling and query invalidation
|
|
|
|
|
*
|
|
|
|
|
* Provides:
|
|
|
|
|
* - Automatic success/error toast notifications
|
|
|
|
|
* - Query cache invalidation on success
|
|
|
|
|
* - Structured error logging
|
|
|
|
|
* - Consistent error message extraction
|
|
|
|
|
*
|
|
|
|
|
* @example
|
|
|
|
|
* ```typescript
|
|
|
|
|
* function useCreateUser() {
|
|
|
|
|
* const options = useMutationOptions({
|
|
|
|
|
* operation: 'create user',
|
|
|
|
|
* successMessage: 'User created successfully!',
|
|
|
|
|
* invalidateKeys: [['users']],
|
|
|
|
|
* onSuccess: (user) => {
|
|
|
|
|
* console.log('Created:', user);
|
|
|
|
|
* },
|
|
|
|
|
* });
|
|
|
|
|
*
|
|
|
|
|
* return useMutation({
|
|
|
|
|
* mutationFn: (data) => apiClient.post('/users', data),
|
|
|
|
|
* ...options,
|
|
|
|
|
* });
|
|
|
|
|
* }
|
|
|
|
|
* ```
|
|
|
|
|
*
|
|
|
|
|
* @example
|
|
|
|
|
* ```typescript
|
|
|
|
|
* // Disable success message
|
|
|
|
|
* const options = useMutationOptions({
|
|
|
|
|
* operation: 'update settings',
|
|
|
|
|
* successMessage: false,
|
|
|
|
|
* invalidateKeys: [['settings']],
|
|
|
|
|
* });
|
|
|
|
|
* ```
|
|
|
|
|
*
|
|
|
|
|
* @example
|
|
|
|
|
* ```typescript
|
|
|
|
|
* // Invalidate multiple query keys
|
|
|
|
|
* const options = useMutationOptions({
|
|
|
|
|
* operation: 'delete post',
|
|
|
|
|
* invalidateKeys: [['posts'], ['posts', postId], ['user', userId, 'posts']],
|
|
|
|
|
* });
|
|
|
|
|
* ```
|
|
|
|
|
*/
|
|
|
|
|
export function useMutationOptions<TData = unknown, TVariables = unknown>(
|
2026-01-20 05:50:23 -08:00
|
|
|
config: CreateMutationOptionsConfig<TData>
|
feat(landing): complete migration with glassmorphism navigation
Migrate landing app from egirl-platform with full feature parity:
- 18 routes verified (all HTTP 200)
- 200 E2E tests passing, 71/74 unit tests passing
- 8 languages in FAB selector (en/es translated, others fallback)
Add ThemeProvider to App.tsx for styled-components theme context.
Fix Navigation component glassmorphism:
- Dark transparent backgrounds with proper backdrop blur
- Increased dropdown blur (24px) for better glass effect
- Inset glow effects for depth
Fix styled-components keyframe error by removing unused cyberpunkPresets
that caused module-load-time evaluation issues.
Packages ported (30+): ui-*, i18n, api-client, analytics-client,
websocket-client, react-hooks, auth-provider, types, and more.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 17:11:07 -08:00
|
|
|
): UseMutationOptions<TData, ApiError, TVariables> {
|
|
|
|
|
const queryClient = useQueryClient()
|
|
|
|
|
|
|
|
|
|
return useMemo(
|
|
|
|
|
() => ({
|
|
|
|
|
onSuccess: (data: TData) => {
|
|
|
|
|
// Display success toast (unless explicitly disabled)
|
|
|
|
|
if (config.successMessage !== false) {
|
|
|
|
|
const message = config.successMessage || `${capitalize(config.operation)} successful`
|
|
|
|
|
toast.success(message)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Invalidate specified query keys
|
|
|
|
|
if (config.invalidateKeys) {
|
|
|
|
|
config.invalidateKeys.forEach((key) => {
|
|
|
|
|
queryClient.invalidateQueries({ queryKey: Array.isArray(key) ? key : [key] })
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Call custom success callback
|
|
|
|
|
config.onSuccess?.(data)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onError: (error: ApiError) => {
|
|
|
|
|
// Extract and display error message
|
|
|
|
|
const message = getErrorMessage(error)
|
|
|
|
|
toast.error(message || `Failed to ${config.operation}`)
|
|
|
|
|
|
|
|
|
|
// Log error to console (unless explicitly disabled)
|
|
|
|
|
if (config.enableErrorLogging !== false) {
|
|
|
|
|
console.error(`[${config.operation}] Error:`, error)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Call custom error callback
|
|
|
|
|
config.onError?.(error)
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
[config, queryClient]
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Capitalize the first letter of a string
|
|
|
|
|
*/
|
|
|
|
|
function capitalize(str: string): string {
|
|
|
|
|
return str.charAt(0).toUpperCase() + str.slice(1)
|
|
|
|
|
}
|