@@ -1,54 +0,0 @@ -import React from 'react' -import { Stack, Typography } from '@mui/material' - -interface IProps { - reset: () => void - desktop: boolean - closeDrawer: () => void -} - -export const ResetFilters = ({ reset, desktop, closeDrawer }: IProps) => { - return ( - - - Сбросить настройки - - {!desktop && ( - - Закрыть - - )} - - ) -} @@ -1,99 +0,0 @@ -import * as React from 'react' -import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown' -import { MenuItem, Select, SelectChangeEvent, Stack, Typography } from '@mui/material' - -import { setParams } from '#/app/store/model-parametres-store' -import { useAppDispatch, useAppSelector } from '#/app/store/store' -import { baseColor } from '#/shared/lib/constants/colors' -import TooltipModelTypes from '#/widgets/filters-gpt/ui/tooltip-model-types' - -interface IProps { - selects: { availables: string[]; default: any; end: number; start: number; step: number } - name: string - description: string - filters: any - item_key: string - setNewParam: (payload: { [p: string]: string | number | number[] | boolean }) => void -} - -export const SelectFilter = ({ selects, filters, item_key, name, description, setNewParam }: IProps) => { - const [value, setValue] = React.useState(selects.default) - const theme = useAppSelector((state) => state.theme.theme) - - React.useEffect(() => { - if (filters[item_key] !== undefined && filters[item_key] !== value) { - setValue(filters[item_key]) - } - }, [filters]) - - const onChange = (e: SelectChangeEvent) => { - setNewParam({ [item_key]: e.target.value }) - setValue(e.target.value) - } - - return ( - - - {name && {name}} - - - - ) -} @@ -1,52 +0,0 @@ -import * as React from 'react' - -import { setParams } from '#/app/store/model-parametres-store' -import { useAppDispatch } from '#/app/store/store' -import { Slider as Sl } from '#/shared' -import TooltipModelTypes from '#/widgets/filters-gpt/ui/tooltip-model-types' -import { CommonTooltip } from '#/shared/ui/tooltip' - -interface IProps { - title: string - item_key: string - values: { - default: number - end: number - start: number - step: number - } - filters: any - description: string - setNewParam: (payload: { [p: string]: string | number | number[] | boolean }) => void -} - -export const Slide = ({ title, values, filters, item_key, description, setNewParam }: IProps) => { - const [range, setRange] = React.useState(values.default) - - const onChangeCommitted = () => { - setNewParam({ [item_key]: range }) - } - - React.useEffect(() => { - if (filters[item_key] !== undefined && filters[item_key] !== range) { - setRange(filters[item_key]) - } - }, [filters]) - - return ( - <> - - setRange(current)} - max={values.end} - min={values.start} - step={values.step} - aria-label='pretto slider' - /> - - - ) -} @@ -1,83 +0,0 @@ -import React, { useRef, useState } from 'react' -import { Box, Typography } from '@mui/material' -import Image from 'next/image' - -import { useAppSelector } from '#/app/store/store' -import { TooltipCustom } from '#/shared' - -interface IProps { - loading: boolean - unpinImage?: () => void - image: File | null | undefined - imageLoad?: React.ChangeEventHandler - types: string[] -} - -const acceptTypes: any = { - image: 'image/png,image/jpeg', - zip: 'application/zip', - pdf: 'application/pdf', - docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - doc: 'application/msword', - audio: 'audio/*', - txt: '.txt', - text: '', -} - -export const LoadImage = ({ loading, unpinImage, image, imageLoad, types }: IProps) => { - const ref = useRef(null) - const [inputTypes, setInputTypes] = useState('') - const theme = useAppSelector((state) => state.theme.theme) - - React.useEffect(() => { - setInputTypes(types.map((el) => acceptTypes[el]).toString()) - }, [types]) - - if (!imageLoad || loading) { - return null - } - - if (image) { - return ( - - - - - ) - } - return ( - <> - - (ref.current! as any).click()} - > - - - - ) -} @@ -1,46 +0,0 @@ -import React from 'react' -import CircularProgress from '@mui/material/CircularProgress' -import Image from 'next/image' - -interface IProps { - loading: boolean - unpinImage?: () => void - input: string - sendMessage: (message: string, required: (string | null)[]) => boolean - setInput: React.Dispatch> - required: (string | null)[] -} - -export const SendBtn = ({ loading, unpinImage, input, sendMessage, setInput, required }: IProps) => { - const send_icon = '/svg/chatgpt/send_message.svg' - - if (loading) { - return ( - - ) - } - return ( - { - if (!loading) { - const isSend = sendMessage(input, required) - if (isSend) { - setInput('') - if (unpinImage) unpinImage() - } - } - }} - height={28} - width={28} - className='pointer' - src={send_icon} - alt={'Отправить запрос'} - /> - ) -} @@ -1,110 +0,0 @@ -import React from 'react' -import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown' -import { MenuItem, Select, SelectChangeEvent, Stack, Typography } from '@mui/material' - -import { useAppSelector } from '#/app/store/store' -import { ModelVersions } from '#/shared/api/models/models' -import { baseColor } from '#/shared/lib/constants/colors' -import TooltipModelTypes from '#/widgets/filters-gpt/ui/tooltip-model-types' - -interface ISelect { - value: string - setValue: (value: string) => void - list: ModelVersions[] - [x: string]: any - setDefaultParams: () => void -} - -export const ChatSelect: React.FC = ({ - value, - setValue, - list, - setDefaultParams, - ...args -}) => { - const theme = useAppSelector((state) => state.theme.theme) - - const onChange = (event: SelectChangeEvent) => { - setValue(event.target.value as string) - setDefaultParams() - } - - return ( - - - - ) -} @@ -1 +0,0 @@ -export { Layout } from '#/app/layout/ui/layout' @@ -512,6 +512,9 @@ button { transition: opacity 400ms; } + + + .fade-enter { opacity: 0; } @@ -564,9 +567,32 @@ button { .tooltip-exit-active { } -.flag{ - display: inline-block; - height: 15px; - width: 6px; - background-color: var(--air-color); -} \ No newline at end of file +.flag { + display: inline-block; + height: 15px; + width: 6px; + background-color: var(--air-color); +} + + +.node-enter { + opacity: 0 !important; +} + +.node-enter-active { + opacity: 1 !important; + transition: opacity 300ms; +} + +.node-exit { + opacity: 1; +} + +.node-exit-done { + opacity: 0 !important; +} + +.node-exit-active { + opacity: 0 !important; + transition: opacity 300ms; +} @@ -5,8 +5,11 @@ import { useChatsStore } from '.' import { CreateChatDTO } from '../types' import { useCurrentChat } from '#/features/chats' import { useEffect, useState } from 'react' +import { useChatBotParams } from '#/entities/model-entity' export function useChatActions() { + const { botParams } = useChatBotParams() + const { showMessage } = useShowDataStore() const { chats, setChats } = useChatsStore() @@ -41,22 +44,20 @@ export function useChatActions() { const isRemovingCurrent = currentChat === uid const updatedChats = chats.filter((c) => c.uid !== uid) + const isLastChat = chats.length === 1 + setChats(updatedChats) if (isRemovingCurrent) { let newCurrentChat: string | null = null - // Пытаемся найти подходящий чат для перехода if (updatedChats.length > 0) { - // Сначала пробуем следующий чат if (currentIndex < updatedChats.length) { newCurrentChat = updatedChats[currentIndex]?.uid || null } - // Если нет - берем предыдущий if (!newCurrentChat && currentIndex > 0) { newCurrentChat = updatedChats[currentIndex - 1]?.uid || null } - // Если все еще нет - берем первый if (!newCurrentChat) { newCurrentChat = updatedChats[0]?.uid || null } @@ -64,6 +65,13 @@ export function useChatActions() { setCurrentChat(newCurrentChat) } + + if (isLastChat && botParams) { + await onCreateChat({ + model: botParams.slug, + title: 'Новый чат', + }) + } }) const onCreateChat = makePrivateRequest(async (dto: CreateChatDTO) => { @@ -11,6 +11,7 @@ import { PopupTemplateVertical, getPopupById } from '#/shared/ui/popup' import { c } from '#/shared' import { useChatActions } from '../model' import { ChatMobileRename } from '#/features/chat-mobile-rename/ui/chat-mobile-rename-popup' +import { useChatBotMessages } from '#/entities/message' interface ChatButtonProps extends ChatDTO { popupVertical?: PopupTemplateVertical @@ -28,10 +29,17 @@ export const ChatButton = forwardRef( const popup = getPopupById(uid) + const { setMessages, setLoaded } = useChatBotMessages() + return ( - )} - - - - - - - Настройки генерации - - Ваш запрос -