@@ -113,23 +113,32 @@ export function useModel( return } + debugger + + const date = new Date(); + const offsetMs = date.getTimezoneOffset() * 60 * 1000; + const msLocal = date.getTime() - offsetMs; + const dateLocal = new Date(msLocal); + + const userMessage: Message = { content: dataForSend.content.trim(), info: dataForSend.info as any, is_sent: true, - file: dataForSend.file ? ((await base64(dataForSend.file)) as string) : null, + file: dataForSend.file ? ((URL.createObjectURL(dataForSend.file) + '?type=.' + dataForSend.file.name.split('.')[1]) as string) : null, from_model: false, uid: 'new-send', elapsed_time: '', is_favourite: false, - created_at: new Date().toISOString(), + created_at: dateLocal.toISOString(), } const modelMessageAboutStartGeneration: Message = { ...userMessage, content: `Ваш вопрос получен. Ожидание ответа от ${modelType}...`, from_model: true, - created_at: new Date().toISOString(), + file: null, + created_at: dateLocal.toISOString(), } setLoading(true) @@ -6,6 +6,7 @@ import Image from 'next/image' import { useAppSelector } from '@/src/main/store/store' import { TooltipCustom } from '@/src/shared' import { Markdown } from '@/src/widgets/markdown/markdown' +import { formatDate } from '@/src/shared/lib/helpers' export function BotMessage(props: any) { // const LazyCode = dynamic(() => import('src/widgets/chat-gpt-field/ui/code')) @@ -32,7 +33,9 @@ export function BotMessage(props: any) { fileName = splitFileName.slice(0, 25) + '...' + - splitFileName.slice(splitFileName.length - 8, splitFileName.length).split('.')[0] + + splitFileName + .slice(splitFileName.length - 8, splitFileName.length) + .split('.')[0] + '.' + splitFileName.split('.')[1] } else { @@ -42,20 +45,19 @@ export function BotMessage(props: any) { } }, [props]) - const flexStyle = - props.message.file && props.modelType !== 'chatgpt' - ? { - display: 'flex', - alignItems: 'center', - justifyContent: 'start', - gap: '12px', - color: '#7f7df3 !important', - fontWeight: '600 !important', - lineHeight: '140%', - letterSpacing: '0.2px', - cursor: 'pointer', - } - : {} + const flexStyle = props.message.file + ? { + display: 'flex', + alignItems: 'center', + justifyContent: 'start', + gap: '12px', + color: '#7f7df3 !important', + fontWeight: '600 !important', + lineHeight: '140%', + letterSpacing: '0.2px', + cursor: 'pointer', + } + : {} return ( // @@ -70,7 +72,12 @@ export function BotMessage(props: any) { > {props.desktop && ( - {''} + {''} )} - {props.message.created_at.slice(10, 16).replace('T', ' ')} + {formatDate(props.message.created_at, { + hour: 'numeric', + minute: 'numeric', + })} @@ -119,7 +129,9 @@ export function BotMessage(props: any) { overflowY: 'scroll', position: 'relative', padding: '15px 23px', - border: `1px solid ${props.theme === 'dark' ? '#303035' : '#EFF0F2'}`, + border: `1px solid ${ + props.theme === 'dark' ? '#303035' : '#EFF0F2' + }`, color: props.theme === 'light' ? '#5E5E5E' : '#A6A5A5', boxShadow: 'none', lineHeight: '22.5px', @@ -135,8 +147,14 @@ export function BotMessage(props: any) { ...flexStyle, }} > - {props.message.file && props.modelType !== 'chatgpt' ? ( - + {props.message.file ? ( + + - - - - - + + + + + @@ -177,12 +228,14 @@ export function BotMessage(props: any) { onClick={handleClose} sx={{ '& .MuiMenu-list': { - backgroundColor: theme === 'dark' ? '#303035' : '#EFF0F2', + backgroundColor: + theme === 'dark' ? '#303035' : '#EFF0F2', color: '#8280FF', borderRadius: '15px', }, '& .MuiPopover-paper': { - backgroundColor: theme === 'dark' ? '#303035' : '#EFF0F2', + backgroundColor: + theme === 'dark' ? '#303035' : '#EFF0F2', borderRadius: '15px', }, }} @@ -197,10 +250,22 @@ export function BotMessage(props: any) { gap: '10px', }} onClick={() => { - copy(props.message.content ? props.message.content : props.message.file.split('/')[4].split('?')[0]) + copy( + props.message.content + ? props.message.content + : props.message.file + .split('/')[4] + .split('?')[0] + ) }} > - + - + { + console.log(props.message.file) + }, [props.message.file]) + const flexStyle = { display: 'flex', alignItems: 'center', @@ -116,9 +121,10 @@ export const UserMessage = React.memo(function UserMessage(props: IMessagesList) marginLeft: 1, }} > - {props.message.created_at - .slice(10, 16) - .replace('T', ' ')} + {formatDate(props.message.created_at, { + hour: 'numeric', + minute: 'numeric', + })} @@ -160,7 +166,7 @@ export const UserMessage = React.memo(function UserMessage(props: IMessagesList) }} width={500} height={500} - src={props.message.file.toString()} + src={props.message.file.toString().split('?type')[0]} alt={ 'К сожалению, изображение не загрузилось' } @@ -6,6 +6,7 @@ import Image from 'next/image' import { useAppSelector } from '@/src/main/store/store' import { TooltipCustom } from '@/src/shared' import { Markdown } from '@/src/widgets/markdown/markdown' +import { formatDate } from '@/src/shared/lib/helpers' export function BotMessage(props: any) { // const LazyCode = dynamic(() => import('src/widgets/chat-gpt-field/ui/code')) @@ -44,20 +45,19 @@ export function BotMessage(props: any) { } }, [props]) - const flexStyle = - props.message.file && props.modelType !== 'chatgpt' - ? { - display: 'flex', - alignItems: 'center', - justifyContent: 'start', - gap: '12px', - color: '#7f7df3 !important', - fontWeight: '600 !important', - lineHeight: '140%', - letterSpacing: '0.2px', - cursor: 'pointer', - } - : {} + const flexStyle = props.message.file + ? { + display: 'flex', + alignItems: 'center', + justifyContent: 'start', + gap: '12px', + color: '#7f7df3 !important', + fontWeight: '600 !important', + lineHeight: '140%', + letterSpacing: '0.2px', + cursor: 'pointer', + } + : {} return ( // @@ -111,7 +111,10 @@ export function BotMessage(props: any) { marginRight: 4, }} > - {props.message.created_at.slice(10, 16).replace('T', ' ')} + {formatDate(props.message.created_at, { + hour: 'numeric', + minute: 'numeric', + })} @@ -144,7 +147,7 @@ export function BotMessage(props: any) { ...flexStyle, }} > - {props.message.file && props.modelType !== 'chatgpt' ? ( + {props.message.file ? (