fix(6): add missing Toast component and fix backend startup

- Create Toast component for success/error messages
- Fix uvicorn invocation: use backend.main:app from project root
- Ensures relative imports work correctly in backend modules
This commit is contained in:
2026-04-22 18:46:32 +03:00
parent bd39f6f1b7
commit 37b6d295ff
2 changed files with 38 additions and 5 deletions

View File

@@ -0,0 +1,34 @@
'use client';
import { useEffect } from 'react';
export interface ToastProps {
type: 'success' | 'error' | 'warning' | 'info';
message: string;
onClose: () => void;
duration?: number;
}
export function Toast({ type, message, onClose, duration = 3000 }: ToastProps) {
useEffect(() => {
const timer = setTimeout(onClose, duration);
return () => clearTimeout(timer);
}, [onClose, duration]);
const bgColor = {
success: 'bg-green-500',
error: 'bg-red-500',
warning: 'bg-yellow-500',
info: 'bg-blue-500',
}[type];
return (
<div
className={`fixed bottom-4 right-4 ${bgColor} text-white px-4 py-2 rounded shadow-lg z-50 animate-fade-in`}
role="alert"
aria-live="polite"
>
{message}
</div>
);
}

View File

@@ -120,27 +120,26 @@ class StandaloneServerManager:
) )
def start_backend(self): def start_backend(self):
"""Start FastAPI backend server using uvicorn directly from project root""" """Start FastAPI backend server using uvicorn from project root"""
self.log(f"Starting backend on port {self.backend_port}...") self.log(f"Starting backend on port {self.backend_port}...")
backend_log = self.logs_dir / "backend.log" backend_log = self.logs_dir / "backend.log"
backend_dir = self.root_dir / "backend"
env = os.environ.copy() env = os.environ.copy()
env['PATH'] = f"{self.python_exe.parent}:{env['PATH']}" env['PATH'] = f"{self.python_exe.parent}:{env['PATH']}"
# Use uvicorn CLI from venv to run the app # Use uvicorn CLI from project root with full module path (backend.main:app)
with open(backend_log, 'w') as log_f: with open(backend_log, 'w') as log_f:
self.backend_process = subprocess.Popen( self.backend_process = subprocess.Popen(
[ [
str(self.python_exe), str(self.python_exe),
"-m", "-m",
"uvicorn", "uvicorn",
"main:app", "backend.main:app",
"--host", "0.0.0.0", "--host", "0.0.0.0",
"--port", str(self.backend_port), "--port", str(self.backend_port),
"--log-level", self.log_level "--log-level", self.log_level
], ],
cwd=str(backend_dir), cwd=str(self.root_dir),
stdout=log_f, stdout=log_f,
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
env=env, env=env,