11import { ConsultMessage , User , UserRole } from '@idea2app/data-server' ;
2- import { Avatar , Box , Button , Container , Paper , TextField , Typography } from '@mui/material' ;
2+ import { Avatar , Button , Container , Paper , TextField , Typography } from '@mui/material' ;
33import { marked } from 'marked' ;
44import { observer } from 'mobx-react' ;
55import { ObservedComponent , reaction } from 'mobx-react-helper' ;
66import { compose , JWTProps , jwtVerifier , RouteProps , router } from 'next-ssr-middleware' ;
7- import { FormEvent } from 'react' ;
7+ import { FormEvent , KeyboardEventHandler } from 'react' ;
88import { formToJSON , scrollTo , sleep } from 'web-utility' ;
99
1010import { PageHead } from '../../../components/PageHead' ;
@@ -69,6 +69,13 @@ export default class ProjectEvaluationPage extends ObservedComponent<
6969 form . reset ( ) ;
7070 } ;
7171
72+ handleQuickSubmit : KeyboardEventHandler = ( { ctrlKey, key, target } ) => {
73+ if ( ctrlKey && key === 'Enter' )
74+ ( target as HTMLTextAreaElement ) . form ?. dispatchEvent (
75+ new SubmitEvent ( 'submit' , { cancelable : true , bubbles : true } ) ,
76+ ) ;
77+ } ;
78+
7279 renderChatMessage = (
7380 { id, content, evaluation, prototypes, createdAt, createdBy } : ConsultMessage ,
7481 index = 0 ,
@@ -86,12 +93,12 @@ export default class ProjectEvaluationPage extends ObservedComponent<
8693 className = { `mb-2 flex w-full ${ isBot ? 'justify-start' : 'justify-end' } ` }
8794 >
8895 < div
89- className = { `flex items-start gap-1 max-w-[95%] sm:max-w-[80%] ${ isBot ? 'flex-row' : 'flex-row-reverse' } ` }
96+ className = { `flex max-w-[95%] items-start gap-1 sm:max-w-[80%] ${ isBot ? 'flex-row' : 'flex-row-reverse' } ` }
9097 >
9198 < Avatar src = { avatarSrc } alt = { name } className = "h-7 w-7 sm:h-8 sm:w-8" />
9299 < Paper
93100 elevation = { 1 }
94- className = "rounded-[16px_16px_4px_16px] p-1.5 sm:p-2 bg-primary-light text-primary-contrast "
101+ className = "bg-primary-light text-primary-contrast rounded-[16px_16px_4px_16px] p-1.5 sm:p-2"
95102 sx = { {
96103 backgroundColor : 'primary.light' ,
97104 color : 'primary.contrastText' ,
@@ -143,16 +150,10 @@ export default class ProjectEvaluationPage extends ObservedComponent<
143150 < SessionBox { ...{ jwtPayload, menu, title } } path = { `/dashboard/project/${ projectId } ` } >
144151 < PageHead title = { title } />
145152
146- < Container
147- maxWidth = "md"
148- className = "flex h-[calc(100vh-120px)] flex-col gap-2 px-0 sm:gap-4 sm:px-2 md:h-[85vh]"
149- >
150- < Typography
151- component = "h1"
152- className = "mb-1 mt-2 px-2 text-2xl font-bold sm:mb-2 sm:mt-4 sm:px-0 sm:text-3xl md:mt-20 md:text-5xl"
153- >
153+ < Container maxWidth = "md" className = "px-4 py-6 pt-16" >
154+ < h1 className = "sticky top-[4rem] z-1 m-0 py-5 text-3xl font-bold backdrop-blur-md" >
154155 { title }
155- </ Typography >
156+ </ h1 >
156157 { /* Chat Messages Area */ }
157158 < div className = "mb-2 flex-1 overflow-auto" >
158159 < ScrollList
@@ -171,29 +172,28 @@ export default class ProjectEvaluationPage extends ObservedComponent<
171172 < Paper
172173 component = "form"
173174 elevation = { 1 }
174- className = "mx-1 mb-1 mt-auto p-1.5 sm:mx-0 sm:mb-0 sm:p-2"
175+ className = "sticky bottom-0 mx-1 mt-auto mb-1 flex items-end gap-2 p-1.5 sm:mx-0 sm:mb-0 sm:p-2"
175176 onSubmit = { this . handleMessageSubmit }
176177 >
177- < div className = "flex flex-col items-end gap-1 sm:flex-row" >
178- < TextField
179- name = "content"
180- placeholder = { t ( 'type_your_message' ) }
181- multiline
182- maxRows = { 4 }
183- fullWidth
184- variant = "outlined"
185- size = "small"
186- required
187- />
188- < Button
189- type = "submit"
190- variant = "contained"
191- className = "min-w-full whitespace-nowrap px-2 sm:min-w-0"
192- disabled = { messageStore . uploading > 0 }
193- >
194- { t ( 'send' ) }
195- </ Button >
196- </ div >
178+ < TextField
179+ name = "content"
180+ placeholder = { t ( 'type_your_message' ) }
181+ multiline
182+ maxRows = { 4 }
183+ fullWidth
184+ variant = "outlined"
185+ size = "small"
186+ required
187+ onKeyUp = { this . handleQuickSubmit }
188+ />
189+ < Button
190+ type = "submit"
191+ variant = "contained"
192+ className = "min-w-full px-2 whitespace-nowrap sm:min-w-0"
193+ disabled = { messageStore . uploading > 0 }
194+ >
195+ { t ( 'send' ) }
196+ </ Button >
197197 </ Paper >
198198 </ Container >
199199 </ SessionBox >
0 commit comments