2023-02-06 13:27:28 -05:00
|
|
|
import React from 'react';
|
|
|
|
|
import NavLink from './NavLink';
|
2023-02-07 10:26:19 -05:00
|
|
|
import TrashIcon from '../svg/TrashIcon';
|
|
|
|
|
import DarkModeIcon from '../svg/DarkModeIcon';
|
|
|
|
|
import LogOutIcon from '../svg/LogOutIcon';
|
2023-02-07 16:22:35 -05:00
|
|
|
import manualSWR from '~/utils/fetchers';
|
|
|
|
|
import { useDispatch } from 'react-redux';
|
|
|
|
|
import { setConversation } from '~/store/convoSlice';
|
|
|
|
|
import { setMessages } from '~/store/messageSlice';
|
2023-02-06 13:27:28 -05:00
|
|
|
|
|
|
|
|
export default function NavLinks() {
|
2023-02-07 16:22:35 -05:00
|
|
|
const dispatch = useDispatch();
|
|
|
|
|
|
|
|
|
|
const { trigger, isMutating } = manualSWR(
|
|
|
|
|
'http://localhost:3050/clear_convos',
|
|
|
|
|
'post',
|
|
|
|
|
() => {
|
|
|
|
|
dispatch(setMessages([]));
|
|
|
|
|
dispatch(setConversation({ conversationId: null, parentMessageId: null }));
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const clickHandler = () => trigger({});
|
|
|
|
|
|
2023-02-06 13:27:28 -05:00
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<NavLink
|
|
|
|
|
svg={TrashIcon}
|
|
|
|
|
text="Clear conversations"
|
2023-02-07 16:22:35 -05:00
|
|
|
onClick={clickHandler}
|
2023-02-06 13:27:28 -05:00
|
|
|
/>
|
|
|
|
|
<NavLink
|
|
|
|
|
svg={DarkModeIcon}
|
|
|
|
|
text="Dark mode"
|
|
|
|
|
/>
|
|
|
|
|
<NavLink
|
|
|
|
|
svg={LogOutIcon}
|
|
|
|
|
text="Log out"
|
|
|
|
|
/>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|