* feat: adding create bot functionality Signed-off-by: James <james@jan.ai> * update the temperature progress bar Signed-off-by: James <james@jan.ai> * WIP baselayout * Mapping plugins with available preferences * Added loader component * WIP working another screen * Cleanup types and avoid import one by one * Prepare bottom bar * Add css variables colors to enable user select the accent * Enable change accent color * Seperate css variable * Fix conflict * Add blank state of my model empty * Restyle explore models page * Enable user config left sidebar * Restyle my models page * WIP styling chat page * Restyling chat message * Fix conflict * Adde form preferences setting plugins * Fixed form bot info * Sidebar bot chat * Showing rightbar for both setting when user created bot * Fix style bot info * Using overflow auto intead of scroll * Remove script built UI from root package * Fix missig import * Resolve error linter * fix e2e tests Signed-off-by: James <james@jan.ai> --------- Signed-off-by: James <james@jan.ai> Co-authored-by: James <james@jan.ai>
70 lines
1.8 KiB
TypeScript
70 lines
1.8 KiB
TypeScript
import { activeBotAtom } from '@helpers/atoms/Bot.atom'
|
|
import { useAtomValue, useSetAtom } from 'jotai'
|
|
import React from 'react'
|
|
import Avatar from '../Avatar'
|
|
import PrimaryButton from '../PrimaryButton'
|
|
import useCreateConversation from '@hooks/useCreateConversation'
|
|
import useDeleteBot from '@hooks/useDeleteBot'
|
|
import {
|
|
setMainViewStateAtom,
|
|
MainViewState,
|
|
} from '@helpers/atoms/MainView.atom'
|
|
|
|
const BotInfoContainer: React.FC = () => {
|
|
const activeBot = useAtomValue(activeBotAtom)
|
|
const setMainView = useSetAtom(setMainViewStateAtom)
|
|
const { deleteBot } = useDeleteBot()
|
|
const { createConvoByBot } = useCreateConversation()
|
|
|
|
const onNewChatClicked = () => {
|
|
if (!activeBot) {
|
|
alert('No bot selected')
|
|
return
|
|
}
|
|
|
|
createConvoByBot(activeBot)
|
|
}
|
|
|
|
const onDeleteBotClick = async () => {
|
|
if (!activeBot) {
|
|
alert('No bot selected')
|
|
return
|
|
}
|
|
|
|
// TODO: display confirmation diaglog
|
|
const result = await deleteBot(activeBot._id)
|
|
if (result === 'success') {
|
|
setMainView(MainViewState.Welcome)
|
|
}
|
|
}
|
|
|
|
if (!activeBot) return null
|
|
|
|
return (
|
|
<div className="flex h-full w-full pt-4">
|
|
<div className="mx-auto flex w-[672px] min-w-max flex-col gap-4">
|
|
<Avatar />
|
|
<h1 className="text-center text-2xl font-bold">{activeBot?.name}</h1>
|
|
<div className="flex gap-4">
|
|
<PrimaryButton
|
|
fullWidth
|
|
title="New chat"
|
|
onClick={onNewChatClicked}
|
|
/>
|
|
<PrimaryButton
|
|
fullWidth
|
|
className="bg-red-500 hover:bg-red-400"
|
|
title="Delete bot"
|
|
onClick={onDeleteBotClick}
|
|
/>
|
|
</div>
|
|
<p>{activeBot?.description}</p>
|
|
<p>System prompt</p>
|
|
<p>{activeBot?.systemPrompt}</p>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default BotInfoContainer
|