complete renaming functions, abstracts more svg, sets title to current convo title, adds a try again feature to errors

This commit is contained in:
Daniel Avila 2023-02-11 10:22:15 -05:00
parent 592b7629aa
commit 5af5a97d8f
24 changed files with 512 additions and 82 deletions

View file

@ -1,11 +1,12 @@
import React from 'react';
import TrashIcon from '../svg/TrashIcon';
import CrossIcon from '../svg/CrossIcon';
import manualSWR from '~/utils/fetchers';
import { useDispatch } from 'react-redux';
import { setConversation } from '~/store/convoSlice';
import { setMessages } from '~/store/messageSlice';
export default function DeleteButton({ conversationId }) {
export default function DeleteButton({ conversationId, renaming, cancelHandler }) {
const dispatch = useDispatch();
const { trigger, isMutating } = manualSWR(
'http://localhost:3050/clear_convos',
@ -17,13 +18,14 @@ export default function DeleteButton({ conversationId }) {
);
const clickHandler = () => trigger({ conversationId });
const handler = renaming ? cancelHandler : clickHandler;
return (
<button
className="p-1 hover:text-white"
onClick={clickHandler}
onClick={handler}
>
<TrashIcon />
{ renaming ? <CrossIcon/> : <TrashIcon />}
</button>
);
}