diff --git a/components/User/ResponsiveDrawer.tsx b/components/User/ResponsiveDrawer.tsx new file mode 100644 index 0000000..f7e9783 --- /dev/null +++ b/components/User/ResponsiveDrawer.tsx @@ -0,0 +1,38 @@ +import { Drawer, useMediaQuery, useTheme } from '@mui/material'; +import { FC, PropsWithChildren } from 'react'; + +const DESKTOP_DRAWER_STYLES = { + position: 'sticky', + top: '5rem', + height: 'calc(100vh - 5rem)', + border: 'none', + boxShadow: 'none', +} as const; + +export interface ResponsiveDrawerProps extends PropsWithChildren { + open: boolean; + onClose: () => void; +} + +export const ResponsiveDrawer: FC = ({ open, onClose, children }) => { + const theme = useTheme(); + const isMobile = useMediaQuery(theme.breakpoints.down('md')); + + return ( + + {children} + + ); +}; diff --git a/components/User/SessionBox.tsx b/components/User/SessionBox.tsx index 5f89820..513fd65 100644 --- a/components/User/SessionBox.tsx +++ b/components/User/SessionBox.tsx @@ -1,12 +1,21 @@ import { User } from '@idea2app/data-server'; -import { Box, List, ListItem, ListItemButton, ListItemText, Modal } from '@mui/material'; +import { + Box, + IconButton, + List, + ListItem, + ListItemButton, + ListItemText, + Modal, +} from '@mui/material'; import { observable } from 'mobx'; import { observer } from 'mobx-react'; import Link from 'next/link'; import { JWTProps } from 'next-ssr-middleware'; import { Component, HTMLAttributes, JSX } from 'react'; -import { PageHead } from '../PageHead'; +import { SymbolIcon } from '../Icon'; +import { ResponsiveDrawer } from './ResponsiveDrawer'; import { SessionForm } from './SessionForm'; export type MenuItem = Pick; @@ -21,46 +30,69 @@ export class SessionBox extends Component { @observable accessor modalShown = false; + @observable + accessor drawerOpen = false; + componentDidMount() { this.modalShown = !this.props.jwtPayload; } + toggleDrawer = () => (this.drawerOpen = !this.drawerOpen); + + closeDrawer = () => (this.drawerOpen = false); + + renderMenuItems() { + const { path, menu = [] } = this.props; + + return ( + + {menu.map(({ href, title }) => ( + + + + + + ))} + + ); + } + render() { - const { className = '', title, children, path, menu = [], jwtPayload, ...props } = this.props; + const { className = '', children, jwtPayload, ...props } = this.props; return ( -
-
- + {/* Mobile Menu Button */} +
+ - {menu.map(({ href, title }) => ( - - - - - - ))} - + +
-
+ + {/* Unified Responsive Drawer */} + +
{this.renderMenuItems()}
+
+ + {/* Main Content */} +
{children} (this.modalShown = false)} /> diff --git a/next-env.d.ts b/next-env.d.ts index d3956e1..7996d35 100644 --- a/next-env.d.ts +++ b/next-env.d.ts @@ -1,6 +1,6 @@ /// /// -import './.next/dev/types/routes.d.ts'; +import "./.next/dev/types/routes.d.ts"; // NOTE: This file should not be edited // see https://nextjs.org/docs/pages/api-reference/config/typescript for more information. diff --git a/pages/dashboard/index.tsx b/pages/dashboard/index.tsx index 283c12a..e6db4e8 100644 --- a/pages/dashboard/index.tsx +++ b/pages/dashboard/index.tsx @@ -37,14 +37,18 @@ const DashboardPage: FC = observer(({ route, jwtPayload }) = return ( - - + + {t('welcome_use')} - = observer(({ route, jwtPayload }) = defaultValue={route.query.name} /> - + - + {t('recent_projects')} @@ -76,16 +84,16 @@ const DashboardPage: FC = observer(({ route, jwtPayload }) = jwtPayload?.roles.includes(2 as UserRole.Client) ? { createdBy: jwtPayload.id } : {} } renderList={allItems => ( - + {allItems[0] ? ( allItems.map(project => ( - + )) ) : ( - + {t('no_project_data')} diff --git a/pages/dashboard/project/[id].tsx b/pages/dashboard/project/[id].tsx index 0e42cd2..e56f235 100644 --- a/pages/dashboard/project/[id].tsx +++ b/pages/dashboard/project/[id].tsx @@ -80,44 +80,35 @@ export default class ProjectEvaluationPage extends ObservedComponent< const name = isBot ? `${t('ai_assistant')} 🤖` : createdBy?.name || 'User'; return ( - - - + - + {name} {content && ( )} @@ -130,13 +121,13 @@ export default class ProjectEvaluationPage extends ObservedComponent< /> )} {createdAt && ( - + {new Date(createdAt).toLocaleTimeString()} )} - - +
+
); }; @@ -154,31 +145,36 @@ export default class ProjectEvaluationPage extends ObservedComponent< -

{title}

+ + {title} + {/* Chat Messages Area */} - +
( - +
{allItems.map(this.renderChatMessage)} - +
)} /> -
+
{/* Message Input Form */} - +
- +