Spaces:
Runtime error
Runtime error
File size: 15,323 Bytes
b366dd7 9e90c44 b366dd7 f07547d b366dd7 d01234f b366dd7 d01234f b366dd7 ff9811c b366dd7 d01234f b366dd7 20e42bb b366dd7 f07547d b366dd7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 | import React, { useState } from 'react';
import {
AppBar,
Box,
CssBaseline,
Drawer,
IconButton,
List,
ListItem,
ListItemButton,
ListItemIcon,
ListItemText,
Toolbar,
Typography,
useTheme as useMuiTheme,
useMediaQuery,
Avatar,
Chip,
Divider,
Badge,
Tooltip,
} from '@mui/material';
import {
Menu as MenuIcon,
Dashboard as DashboardIcon,
Settings as SettingsIcon,
Build as BuildIcon,
History as HistoryIcon,
AccountCircle as AccountCircleIcon,
Notifications as NotificationsIcon,
BusinessCenter as BusinessCenterIcon,
Chat as ChatIcon,
AutoAwesome as AutoAwesomeIcon,
Compare as CompareIcon
} from '@mui/icons-material';
import { Routes, Route, useNavigate, useLocation } from 'react-router-dom';
import MainPage from '../pages/MainPage';
import ConfigurationPage from '../pages/ConfigurationPageNew';
import HistoryPage from '../pages/HistoryPage';
import SettingsPage from '../pages/SettingsPage';
import ChatPage from '../pages/ChatPage';
import DIYGeneratorPage from '../pages/DIYGeneratorPage';
import AnomalyPage from '../pages/AnomalyPage';
const drawerWidth = 240;
interface NavItem {
text: string;
icon: React.ReactElement;
path: string;
}
const navigationItems: NavItem[] = [
{ text: 'Dashboard', icon: <DashboardIcon />, path: '/' },
{ text: 'DIY Generator', icon: <AutoAwesomeIcon />, path: '/diy-generator' },
{ text: 'Configuration', icon: <BuildIcon />, path: '/configuration' },
{ text: 'Anomaly', icon: <CompareIcon />, path: '/anomaly' },
{ text: 'Chat', icon: <ChatIcon />, path: '/chat' },
// { text: 'History', icon: <HistoryIcon />, path: '/history' },
{ text: 'Settings', icon: <SettingsIcon />, path: '/settings' },
];
const Layout: React.FC = () => {
const theme = useMuiTheme();
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
const [mobileOpen, setMobileOpen] = useState(false);
const navigate = useNavigate();
const location = useLocation();
// Add keyframes for pulse animation
React.useEffect(() => {
const style = document.createElement('style');
style.textContent = `
@keyframes pulse {
0% {
transform: scale(0.95);
box-shadow: 0 0 0 0 rgba(77, 196, 212, 0.7);
}
70% {
transform: scale(1);
box-shadow: 0 0 0 6px rgba(77, 196, 212, 0);
}
100% {
transform: scale(0.95);
box-shadow: 0 0 0 0 rgba(77, 196, 212, 0);
}
}
`;
document.head.appendChild(style);
return () => {
document.head.removeChild(style);
};
}, []);
const handleDrawerToggle = () => {
setMobileOpen(!mobileOpen);
};
const handleNavigate = (path: string) => {
navigate(path);
if (isMobile) {
setMobileOpen(false);
}
};
const drawer = (
<Box sx={{
height: '100vh',
background: 'linear-gradient(180deg, #5009b5 0%, #2b1b49 100%)', // Carelon purple gradient
display: 'flex',
flexDirection: 'column',
position: 'relative'
}}>
{/* Header Section */}
<Box sx={{
p: 3,
textAlign: 'center',
borderBottom: '1px solid rgba(0, 0, 0, 0.1)',
flexShrink: 0,
backgroundColor: '#f7f7f7', // Light grey background
borderTopLeftRadius: 0,
borderTopRightRadius: 0
}}>
{/* Carelon Logo */}
<Box sx={{ mb: 2 }}>
<img
src="/carelon.svg"
alt="Carelon"
style={{
height: '40px',
width: 'auto'
// Removed filter to show original logo colors
}}
/>
</Box>
<Typography
variant="h6"
sx={{
color: '#5009b5', // Carelon primary purple
fontWeight: 700,
fontSize: '1.1rem',
mb: 0.5
}}
>
Benefit Agent Portal
</Typography>
<Typography
variant="body2"
sx={{
color: '#2b1b49', // Darker purple for secondary text
fontSize: '0.875rem'
}}
>
Behavioral Health Platform
</Typography>
</Box>
{/* User Info Section */}
<Box sx={{
p: 2,
borderBottom: '1px solid rgba(255, 255, 255, 0.1)',
mb: 1,
flexShrink: 0
}}>
<Box sx={{ display: 'flex', alignItems: 'center', gap: 2 }}>
<Avatar sx={{ width: 40, height: 40, backgroundColor: 'rgba(255, 255, 255, 0.2)' }}>
<AccountCircleIcon />
</Avatar>
<Box sx={{ flex: 1 }}>
<Typography
variant="body2"
sx={{
color: 'white',
fontWeight: 600,
fontSize: '0.875rem'
}}
>
Benefit Agent
</Typography>
<Chip
label="Benefits Analyst"
size="small"
sx={{
height: 20,
fontSize: '0.75rem',
backgroundColor: 'rgba(255, 255, 255, 0.15)',
color: 'white',
'& .MuiChip-label': {
px: 1
}
}}
/>
</Box>
</Box>
</Box>
{/* Navigation Items */}
<List sx={{
px: 2,
py: 1,
flex: 1,
overflow: 'auto'
}}>
{navigationItems.map((item, index) => (
<ListItem key={item.text} disablePadding sx={{ mb: 0.5 }}>
<ListItemButton
selected={location.pathname === item.path}
onClick={() => handleNavigate(item.path)}
sx={{
borderRadius: '12px',
py: 1.5,
px: 2,
'&.Mui-selected': {
backgroundColor: 'rgba(255, 255, 255, 0.15)',
backdropFilter: 'blur(10px)',
border: '1px solid rgba(255, 255, 255, 0.2)',
'&:hover': {
backgroundColor: 'rgba(255, 255, 255, 0.2)',
},
},
'&:hover': {
backgroundColor: 'rgba(255, 255, 255, 0.1)',
},
transition: 'all 0.3s ease',
}}
>
<ListItemIcon
sx={{
color: 'white',
minWidth: 40,
}}
>
{item.icon}
</ListItemIcon>
<ListItemText
primary={item.text}
sx={{
'& .MuiListItemText-primary': {
fontWeight: location.pathname === item.path ? 600 : 500,
color: 'white',
fontSize: '0.875rem',
},
}}
/>
{location.pathname === item.path && (
<Box
sx={{
width: 4,
height: 20,
backgroundColor: 'white',
borderRadius: '2px',
opacity: 0.8
}}
/>
)}
</ListItemButton>
</ListItem>
))}
</List>
{/* Bottom Status */}
<Box sx={{
p: 2,
borderTop: '1px solid rgba(255, 255, 255, 0.1)',
flexShrink: 0,
mt: 'auto'
}}>
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 1 }}>
<Box
sx={{
width: 8,
height: 8,
borderRadius: '50%',
backgroundColor: '#4DC4D4', // Carelon light teal
animation: 'pulse 2s infinite'
}}
/>
<Typography
variant="caption"
sx={{
color: 'rgba(255, 255, 255, 0.8)',
fontSize: '0.75rem'
}}
>
System Online
</Typography>
</Box>
</Box>
</Box>
);
return (
<Box sx={{ display: 'flex' }}>
<CssBaseline />
<AppBar
position="fixed"
elevation={0}
sx={{
width: { md: `calc(100% - ${drawerWidth}px)` },
ml: { md: `${drawerWidth}px` },
background: 'linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.85) 100%)',
backdropFilter: 'blur(20px)',
borderBottom: '1px solid rgba(0, 0, 0, 0.06)',
color: theme.palette.text.primary,
}}
>
<Toolbar sx={{ justifyContent: 'space-between' }}>
<Box sx={{ display: 'flex', alignItems: 'center' }}>
<IconButton
color="inherit"
aria-label="open drawer"
edge="start"
onClick={handleDrawerToggle}
sx={{
mr: 2,
display: { md: 'none' },
backgroundColor: 'rgba(0, 0, 0, 0.04)',
'&:hover': {
backgroundColor: 'rgba(0, 0, 0, 0.08)',
}
}}
>
<MenuIcon />
</IconButton>
<Box>
<Typography
variant="h5"
component="div"
sx={{
fontWeight: 700,
background: 'linear-gradient(135deg, #5009b5 0%, #2b1b49 100%)', // Carelon purple gradient
backgroundClip: 'text',
WebkitBackgroundClip: 'text',
color: 'transparent',
fontSize: '1.25rem'
}}
>
{navigationItems.find(item => item.path === location.pathname)?.text || 'Dashboard'}
</Typography>
<Typography
variant="body2"
sx={{
color: 'text.secondary',
fontSize: '0.875rem',
mt: -0.5
}}
>
{location.pathname === '/' && 'Use Benefit AI Agent to perform Domain functions'}
{location.pathname === '/diy-generator' && 'Create custom benefit plans step by step'}
{location.pathname === '/configuration' && 'Configure processing parameters'}
{location.pathname === '/chat' && 'AI-powered health insurance benefits assistant'}
{location.pathname === '/history' && 'View processing history and reports'}
{location.pathname === '/settings' && 'Manage application settings'}
</Typography>
</Box>
</Box>
{/* Right side of AppBar */}
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
<Tooltip title="Notifications">
<IconButton
sx={{
backgroundColor: 'rgba(0, 0, 0, 0.04)',
'&:hover': {
backgroundColor: 'rgba(0, 0, 0, 0.08)',
}
}}
>
<Badge badgeContent={3} color="error">
<NotificationsIcon />
</Badge>
</IconButton>
</Tooltip>
<Divider orientation="vertical" flexItem sx={{ mx: 1 }} />
<Chip
avatar={
<Avatar sx={{
width: 24,
height: 24,
backgroundColor: 'primary.main'
}}>
JD
</Avatar>
}
label="Benefit Agent"
variant="outlined"
sx={{
backgroundColor: 'rgba(0, 0, 0, 0.02)',
border: '1px solid rgba(0, 0, 0, 0.08)',
'&:hover': {
backgroundColor: 'rgba(0, 0, 0, 0.04)',
}
}}
/>
</Box>
</Toolbar>
</AppBar>
<Box
component="nav"
sx={{ width: { md: drawerWidth }, flexShrink: { md: 0 } }}
>
<Drawer
variant="temporary"
open={mobileOpen}
onClose={handleDrawerToggle}
ModalProps={{
keepMounted: true,
}}
sx={{
display: { xs: 'block', md: 'none' },
'& .MuiDrawer-paper': {
boxSizing: 'border-box',
width: drawerWidth,
border: 'none',
boxShadow: '0 10px 30px rgba(0, 0, 0, 0.3)',
},
}}
>
{drawer}
</Drawer>
<Drawer
variant="permanent"
sx={{
display: { xs: 'none', md: 'block' },
'& .MuiDrawer-paper': {
boxSizing: 'border-box',
width: drawerWidth,
border: 'none',
boxShadow: '4px 0 20px rgba(0, 0, 0, 0.1)',
position: 'fixed',
top: 0,
left: 0,
height: '100vh',
overflow: 'hidden',
},
}}
open
>
{drawer}
</Drawer>
</Box>
<Box
component="main"
sx={{
flexGrow: 1,
p: { xs: 1, md: 0 },
width: { md: `calc(100% - ${drawerWidth}px)` },
// ml: { md: `${drawerWidth}px` },
background: theme.palette.mode === 'dark'
? 'linear-gradient(135deg, #121212 0%, #1E1E1E 100%)' // Standard dark theme
: 'linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%)', // Clean white like Carelon
minHeight: '100vh',
height: '100vh',
overflow: 'hidden',
position: 'relative',
'&::before': {
content: '""',
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
background: theme.palette.mode === 'dark'
? 'radial-gradient(circle at 20% 80%, rgba(77, 196, 212, 0.1) 0%, transparent 50%), radial-gradient(circle at 80% 20%, rgba(46, 95, 126, 0.1) 0%, transparent 50%)'
: 'radial-gradient(circle at 20% 80%, rgba(0, 163, 181, 0.05) 0%, transparent 50%), radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.8) 0%, transparent 50%)',
pointerEvents: 'none',
}
}}
>
<Toolbar />
<Box sx={{
position: 'relative',
zIndex: 1,
height: 'calc(100vh - 64px)',
overflow: 'auto',
px: { xs: 1, md: 3 },
py: { xs: 1, md: 2 }
}}>
<Routes>
<Route path="/" element={<MainPage />} />
<Route path="/index.html" element={<MainPage />} />
<Route path="/diy-generator" element={<DIYGeneratorPage />} />
<Route path="/configuration" element={<ConfigurationPage />} />
<Route path="/anomaly" element={<AnomalyPage />} />
<Route path="/chat" element={<ChatPage />} />
<Route path="/history" element={<HistoryPage />} />
<Route path="/settings" element={<SettingsPage />} />
</Routes>
</Box>
</Box>
</Box>
);
};
export default Layout; |