From 6ff9cbe327e3c70354c27cd9cc15b5f9261befe5 Mon Sep 17 00:00:00 2001 From: GotthardG <51994228+GotthardG@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:37:39 +0100 Subject: [PATCH] Refactor puck handling and update tell position setting Simplify and standardize puck name normalization and validation. Refactor `set_tell_positions` to handle batch operations, improve error handling, and provide detailed responses for each puck. Removed unnecessary `with-tell-position` endpoint for better clarity and maintainability. --- frontend/src/pages/LoginView.tsx | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/frontend/src/pages/LoginView.tsx b/frontend/src/pages/LoginView.tsx index 8f00f29..048d50f 100644 --- a/frontend/src/pages/LoginView.tsx +++ b/frontend/src/pages/LoginView.tsx @@ -57,11 +57,26 @@ const LoginView: React.FC = () => { const navigate = useNavigate(); useEffect(() => { - const isTestEnv = import.meta.env.MODE === 'test'; - OpenAPI.BASE = isTestEnv - ? import.meta.env.VITE_OPENAPI_BASE_TEST - : import.meta.env.VITE_OPENAPI_BASE_DEV; - ; + // Detect the current environment + const mode = import.meta.env.MODE; + + // Dynamically set `OpenAPI.BASE` based on the mode + OpenAPI.BASE = + mode === 'test' + ? import.meta.env.VITE_OPENAPI_BASE_TEST + : mode === 'prod' + ? import.meta.env.VITE_OPENAPI_BASE_PROD + : import.meta.env.VITE_OPENAPI_BASE_DEV; + + // Log warning if `OpenAPI.BASE` is unresolved + if (!OpenAPI.BASE) { + console.error('OpenAPI.BASE is not set. Falling back to a default value.'); + OpenAPI.BASE = 'https://default-url.com'; // Use a consistent fallback + } + + // Debug for mode and resolved `BASE` + console.log('Environment Mode:', mode); + console.log('Resolved OpenAPI.BASE:', OpenAPI.BASE); }, []); const handleLogin = async (e: React.FormEvent) => {