Files
chatbot-ui/components/Sidebar/ClearConversations.tsx
T
Danil Shishkevich 3ca503a3f2 chore: some small improvements (#223)
* chore: stylize error message div
chore: correct styles for sidebar btn
chore: add spinner and replace header "Please wait" on spinner
chore: correct Russian translate
chore: hide clear conversation btn if not conversations
chore: stylize "Need OpenAI key" div

* chore: corrent Russian translate
2023-03-27 07:43:01 -06:00

56 lines
1.5 KiB
TypeScript

import { IconCheck, IconTrash, IconX } from '@tabler/icons-react';
import { FC, useState } from 'react';
import { useTranslation } from 'next-i18next';
import { SidebarButton } from './SidebarButton';
interface Props {
onClearConversations: () => void;
}
export const ClearConversations: FC<Props> = ({ onClearConversations }) => {
const [isConfirming, setIsConfirming] = useState<boolean>(false);
const { t } = useTranslation('sidebar');
const handleClearConversations = () => {
onClearConversations();
setIsConfirming(false);
};
return isConfirming ? (
<div className="flex w-full cursor-pointer items-center rounded-lg py-3 px-3 hover:bg-gray-500/10">
<IconTrash size={18} />
<div className="ml-3 flex-1 text-left text-[12.5px] leading-3 text-white">
{t('Are you sure?')}
</div>
<div className="flex w-[40px]">
<IconCheck
className="ml-auto min-w-[20px] mr-1 text-neutral-400 hover:text-neutral-100"
size={18}
onClick={(e) => {
e.stopPropagation();
handleClearConversations();
}}
/>
<IconX
className="ml-auto min-w-[20px] text-neutral-400 hover:text-neutral-100"
size={18}
onClick={(e) => {
e.stopPropagation();
setIsConfirming(false);
}}
/>
</div>
</div>
) : (
<SidebarButton
text={t('Clear conversations')}
icon={<IconTrash size={18} />}
onClick={() => setIsConfirming(true)}
/>
);
};