diff --git a/backend/src/routes/settings.ts b/backend/src/routes/settings.ts index bcaa445..7016114 100644 --- a/backend/src/routes/settings.ts +++ b/backend/src/routes/settings.ts @@ -18,14 +18,14 @@ router.get('/notifications', async (req: AuthRequest, res: Response) => { return; } - // Don't expose full tokens, just indicate if they're set res.json({ - telegram_configured: !!(settings.telegram_bot_token && settings.telegram_chat_id), - telegram_chat_id: settings.telegram_chat_id, + telegram_bot_token: settings.telegram_bot_token || null, + telegram_chat_id: settings.telegram_chat_id || null, telegram_enabled: settings.telegram_enabled ?? true, - discord_configured: !!settings.discord_webhook_url, + discord_webhook_url: settings.discord_webhook_url || null, discord_enabled: settings.discord_enabled ?? true, - pushover_configured: !!(settings.pushover_user_key && settings.pushover_app_token), + pushover_user_key: settings.pushover_user_key || null, + pushover_app_token: settings.pushover_app_token || null, pushover_enabled: settings.pushover_enabled ?? true, }); } catch (error) { @@ -66,12 +66,13 @@ router.put('/notifications', async (req: AuthRequest, res: Response) => { } res.json({ - telegram_configured: !!(settings.telegram_bot_token && settings.telegram_chat_id), - telegram_chat_id: settings.telegram_chat_id, + telegram_bot_token: settings.telegram_bot_token || null, + telegram_chat_id: settings.telegram_chat_id || null, telegram_enabled: settings.telegram_enabled ?? true, - discord_configured: !!settings.discord_webhook_url, + discord_webhook_url: settings.discord_webhook_url || null, discord_enabled: settings.discord_enabled ?? true, - pushover_configured: !!(settings.pushover_user_key && settings.pushover_app_token), + pushover_user_key: settings.pushover_user_key || null, + pushover_app_token: settings.pushover_app_token || null, pushover_enabled: settings.pushover_enabled ?? true, message: 'Notification settings updated successfully', }); @@ -196,13 +197,11 @@ router.get('/ai', async (req: AuthRequest, res: Response) => { return; } - // Don't expose full API keys, just indicate if they're set res.json({ ai_enabled: settings.ai_enabled || false, ai_provider: settings.ai_provider || null, - anthropic_configured: !!settings.anthropic_api_key, - openai_configured: !!settings.openai_api_key, - ollama_configured: !!(settings.ollama_base_url && settings.ollama_model), + anthropic_api_key: settings.anthropic_api_key || null, + openai_api_key: settings.openai_api_key || null, ollama_base_url: settings.ollama_base_url || null, ollama_model: settings.ollama_model || null, }); @@ -235,9 +234,8 @@ router.put('/ai', async (req: AuthRequest, res: Response) => { res.json({ ai_enabled: settings.ai_enabled || false, ai_provider: settings.ai_provider || null, - anthropic_configured: !!settings.anthropic_api_key, - openai_configured: !!settings.openai_api_key, - ollama_configured: !!(settings.ollama_base_url && settings.ollama_model), + anthropic_api_key: settings.anthropic_api_key || null, + openai_api_key: settings.openai_api_key || null, ollama_base_url: settings.ollama_base_url || null, ollama_model: settings.ollama_model || null, message: 'AI settings updated successfully', diff --git a/frontend/src/api/client.ts b/frontend/src/api/client.ts index 01861f1..e901e97 100644 --- a/frontend/src/api/client.ts +++ b/frontend/src/api/client.ts @@ -149,12 +149,13 @@ export const stockHistoryApi = { // Settings API export interface NotificationSettings { - telegram_configured: boolean; + telegram_bot_token: string | null; telegram_chat_id: string | null; telegram_enabled: boolean; - discord_configured: boolean; + discord_webhook_url: string | null; discord_enabled: boolean; - pushover_configured: boolean; + pushover_user_key: string | null; + pushover_app_token: string | null; pushover_enabled: boolean; } @@ -206,9 +207,8 @@ export const settingsApi = { export interface AISettings { ai_enabled: boolean; ai_provider: 'anthropic' | 'openai' | 'ollama' | null; - anthropic_configured: boolean; - openai_configured: boolean; - ollama_configured: boolean; + anthropic_api_key: string | null; + openai_api_key: string | null; ollama_base_url: string | null; ollama_model: string | null; } diff --git a/frontend/src/components/PasswordInput.tsx b/frontend/src/components/PasswordInput.tsx index 918f8ef..6bce369 100644 --- a/frontend/src/components/PasswordInput.tsx +++ b/frontend/src/components/PasswordInput.tsx @@ -4,24 +4,22 @@ interface PasswordInputProps extends Omit, // All standard input props are inherited } -export default function PasswordInput({ style, value, ...props }: PasswordInputProps) { +export default function PasswordInput({ style, ...props }: PasswordInputProps) { const [visible, setVisible] = useState(false); - const hasValue = value !== undefined && value !== null && String(value).length > 0; return (
- {hasValue && } +
); } diff --git a/frontend/src/pages/ProductDetail.tsx b/frontend/src/pages/ProductDetail.tsx index 35e1095..9c9098c 100644 --- a/frontend/src/pages/ProductDetail.tsx +++ b/frontend/src/pages/ProductDetail.tsx @@ -525,9 +525,9 @@ export default function ProductDetail() { {notificationSettings && ( - (notificationSettings.telegram_configured && notificationSettings.telegram_enabled) || - (notificationSettings.discord_configured && notificationSettings.discord_enabled) || - (notificationSettings.pushover_configured && notificationSettings.pushover_enabled) + ((notificationSettings.telegram_bot_token && notificationSettings.telegram_chat_id) && notificationSettings.telegram_enabled) || + (notificationSettings.discord_webhook_url && notificationSettings.discord_enabled) || + ((notificationSettings.pushover_user_key && notificationSettings.pushover_app_token) && notificationSettings.pushover_enabled) ) && ( <>