2025-07-16 17:53:50 +01:00
|
|
|
/**
|
|
|
|
* React hooks for tool parameter management (URL logic removed)
|
|
|
|
*/
|
|
|
|
|
|
|
|
import { useCallback, useMemo } from 'react';
|
|
|
|
|
|
|
|
type ToolParameterValues = Record<string, any>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register tool parameters and get current values
|
|
|
|
*/
|
|
|
|
export function useToolParameters(
|
2025-09-05 12:16:17 +01:00
|
|
|
_toolName: string,
|
|
|
|
_parameters: Record<string, any>
|
2025-07-16 17:53:50 +01:00
|
|
|
): [ToolParameterValues, (updates: Partial<ToolParameterValues>) => void] {
|
|
|
|
|
|
|
|
// Return empty values and noop updater
|
|
|
|
const currentValues = useMemo(() => ({}), []);
|
|
|
|
const updateParameters = useCallback(() => {}, []);
|
|
|
|
|
|
|
|
return [currentValues, updateParameters];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hook for managing a single tool parameter
|
|
|
|
*/
|
|
|
|
export function useToolParameter<T = any>(
|
|
|
|
toolName: string,
|
|
|
|
paramName: string,
|
|
|
|
definition: any
|
|
|
|
): [T, (value: T) => void] {
|
|
|
|
const [allParams, updateParams] = useToolParameters(toolName, { [paramName]: definition });
|
2025-09-05 12:16:17 +01:00
|
|
|
|
2025-07-16 17:53:50 +01:00
|
|
|
const value = allParams[paramName] as T;
|
2025-09-05 12:16:17 +01:00
|
|
|
|
2025-07-16 17:53:50 +01:00
|
|
|
const setValue = useCallback((newValue: T) => {
|
|
|
|
updateParams({ [paramName]: newValue });
|
|
|
|
}, [paramName, updateParams]);
|
|
|
|
|
|
|
|
return [value, setValue];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hook for getting/setting global parameters (zoom, page, etc.)
|
|
|
|
*/
|
|
|
|
export function useGlobalParameters() {
|
|
|
|
const currentValues = useMemo(() => ({}), []);
|
|
|
|
const updateParameters = useCallback(() => {}, []);
|
|
|
|
|
|
|
|
return [currentValues, updateParameters];
|
2025-09-05 12:16:17 +01:00
|
|
|
}
|