From 1aa52c563e5344f001c031c971192996ddd8c9f2 Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Mon, 13 Jul 2026 15:02:42 +0000 Subject: [PATCH] =?UTF-8?q?Add=20Resos=20connection=20status=20card=20to?= =?UTF-8?q?=20Settings=20=E2=80=94=20read-only,=20sourced=20from=20central?= =?UTF-8?q?=20Settings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the removed API key form with a status card showing whether the Resos key is configured in the central Settings app, plus a Test Connection button. Adds back the GET /settings/resos and POST /settings/resos/test endpoints (now reading from central_settings rather than system_config). Co-Authored-By: Claude Sonnet 4.6 --- backend/api/config.py | 19 ++++++++ frontend/src/pages/Settings.tsx | 83 ++++++++++++++++++++++++++++++++- 2 files changed, 101 insertions(+), 1 deletion(-) diff --git a/backend/api/config.py b/backend/api/config.py index ed836fc..56f7765 100644 --- a/backend/api/config.py +++ b/backend/api/config.py @@ -137,6 +137,25 @@ async def test_newbook_settings( return await _test_newbook(db) +# ============================================ +# RESOS SETTINGS ENDPOINTS +# ============================================ + +@router.get("/settings/resos") +async def get_resos_settings(current_user: dict = Depends(get_current_user)): + """Check whether a Resos API key is configured in the central Settings service""" + from services.central_settings import get_resos_credentials + creds = await get_resos_credentials() + return {"configured": bool(creds and creds.get("api_key"))} + + +@router.post("/settings/resos/test") +async def test_resos_settings( + db: AsyncSession = Depends(get_db), + current_user: dict = Depends(get_current_user) +): + """Test Resos connection using credentials from the central Settings service""" + return await _test_resos(db) # ============================================ diff --git a/frontend/src/pages/Settings.tsx b/frontend/src/pages/Settings.tsx index 60cc159..000cf7e 100644 --- a/frontend/src/pages/Settings.tsx +++ b/frontend/src/pages/Settings.tsx @@ -2151,7 +2151,11 @@ const ResosPage: React.FC = () => { return (

Resos Settings

-

Configure Resos sync settings for restaurant reservation management. The Resos API key is managed centrally in the Settings app.

+

Configure Resos sync settings for restaurant reservation management.

+ + + +
@@ -2174,6 +2178,83 @@ const ResosPage: React.FC = () => { ) } +// ============================================ +// RESOS CONNECTION STATUS SECTION +// ============================================ + +const ResosConnectionStatus: React.FC = () => { + const [testStatus, setTestStatus] = useState<'idle' | 'testing' | 'success' | 'error'>('idle') + const [testMessage, setTestMessage] = useState('') + + const { data } = useQuery({ + queryKey: ['resos-status'], + queryFn: async () => { + const response = await fetch('/forecasting/api/config/settings/resos') + if (!response.ok) throw new Error('Failed to fetch') + return response.json() as Promise<{ configured: boolean }> + }, + staleTime: 60000, + }) + + const handleTest = async () => { + setTestStatus('testing') + setTestMessage('') + try { + const response = await fetch('/forecasting/api/config/settings/resos/test', { method: 'POST' }) + const result = await response.json() + if (response.ok) { + setTestStatus('success') + setTestMessage(result.message || 'Connected successfully') + } else { + setTestStatus('error') + setTestMessage(result.detail || 'Connection failed') + } + } catch { + setTestStatus('error') + setTestMessage('Connection failed') + } + setTimeout(() => { setTestStatus('idle'); setTestMessage('') }, 5000) + } + + return ( +
+
+

API Connection

+

Resos API credentials are managed in the central Settings app.

+
+ +
+ {testMessage && ( +
+ {testMessage} +
+ )} +
+
+

Connection Status

+
+
+ API Key + + {data?.configured ? 'Configured' : 'Not set'} + +
+
+
+
+ ) +} + // ============================================ // RESOS CUSTOM FIELD MAPPING SECTION // ============================================