2023-02-06 13:27:28 -05:00
|
|
|
import React from 'react';
|
2023-03-12 00:32:03 +08:00
|
|
|
import { useSelector, useDispatch } from 'react-redux';
|
|
|
|
|
import { setNewConvo } from '~/store/convoSlice';
|
|
|
|
|
import { setMessages } from '~/store/messageSlice';
|
2023-03-13 05:21:30 +08:00
|
|
|
import { setSubmission } from '~/store/submitSlice';
|
2023-03-12 00:32:03 +08:00
|
|
|
import { setText } from '~/store/textSlice';
|
|
|
|
|
|
|
|
|
|
export default function MobileNav({ setNavVisible }) {
|
|
|
|
|
const dispatch = useDispatch();
|
2023-03-15 04:05:14 +08:00
|
|
|
const { conversationId, convos, title } = useSelector((state) => state.convo);
|
2023-03-12 00:32:03 +08:00
|
|
|
|
|
|
|
|
const toggleNavVisible = () => {
|
|
|
|
|
setNavVisible((prev) => {
|
|
|
|
|
return !prev
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const newConvo = () => {
|
|
|
|
|
dispatch(setText(''));
|
|
|
|
|
dispatch(setMessages([]));
|
|
|
|
|
dispatch(setNewConvo());
|
2023-03-11 22:35:39 -05:00
|
|
|
dispatch(setSubmission({}));
|
2023-03-12 00:32:03 +08:00
|
|
|
}
|
|
|
|
|
|
2023-02-06 13:27:28 -05:00
|
|
|
return (
|
2023-03-18 00:29:34 +08:00
|
|
|
<div className="fixed top-0 left-0 right-0 z-10 flex items-center border-b border-white/20 bg-gray-800 pl-1 pt-1 text-gray-200 sm:pl-3 md:hidden">
|
2023-02-06 13:27:28 -05:00
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
className="-ml-0.5 -mt-0.5 inline-flex h-10 w-10 items-center justify-center rounded-md hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-white dark:hover:text-white"
|
2023-03-12 00:32:03 +08:00
|
|
|
onClick={toggleNavVisible}
|
2023-02-06 13:27:28 -05:00
|
|
|
>
|
|
|
|
|
<span className="sr-only">Open sidebar</span>
|
|
|
|
|
<svg
|
|
|
|
|
stroke="currentColor"
|
|
|
|
|
fill="none"
|
|
|
|
|
strokeWidth="1.5"
|
|
|
|
|
viewBox="0 0 24 24"
|
|
|
|
|
strokeLinecap="round"
|
|
|
|
|
strokeLinejoin="round"
|
|
|
|
|
className="h-6 w-6"
|
|
|
|
|
height="1em"
|
|
|
|
|
width="1em"
|
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
|
>
|
|
|
|
|
<line
|
|
|
|
|
x1="3"
|
|
|
|
|
y1="12"
|
|
|
|
|
x2="21"
|
|
|
|
|
y2="12"
|
|
|
|
|
/>
|
|
|
|
|
<line
|
|
|
|
|
x1="3"
|
|
|
|
|
y1="6"
|
|
|
|
|
x2="21"
|
|
|
|
|
y2="6"
|
|
|
|
|
/>
|
|
|
|
|
<line
|
|
|
|
|
x1="3"
|
|
|
|
|
y1="18"
|
|
|
|
|
x2="21"
|
|
|
|
|
y2="18"
|
|
|
|
|
/>
|
|
|
|
|
</svg>
|
|
|
|
|
</button>
|
2023-03-15 04:05:14 +08:00
|
|
|
<h1 className="flex-1 text-center text-base font-normal">{title || 'New Chat'}</h1>
|
2023-02-06 13:27:28 -05:00
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
className="px-3"
|
2023-03-12 00:32:03 +08:00
|
|
|
onClick={newConvo}
|
2023-02-06 13:27:28 -05:00
|
|
|
>
|
|
|
|
|
<svg
|
|
|
|
|
stroke="currentColor"
|
|
|
|
|
fill="none"
|
|
|
|
|
strokeWidth="1.5"
|
|
|
|
|
viewBox="0 0 24 24"
|
|
|
|
|
strokeLinecap="round"
|
|
|
|
|
strokeLinejoin="round"
|
|
|
|
|
className="h-6 w-6"
|
|
|
|
|
height="1em"
|
|
|
|
|
width="1em"
|
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
|
>
|
|
|
|
|
<line
|
|
|
|
|
x1="12"
|
|
|
|
|
y1="5"
|
|
|
|
|
x2="12"
|
|
|
|
|
y2="19"
|
|
|
|
|
/>
|
|
|
|
|
<line
|
|
|
|
|
x1="5"
|
|
|
|
|
y1="12"
|
|
|
|
|
x2="19"
|
|
|
|
|
y2="12"
|
|
|
|
|
/>
|
|
|
|
|
</svg>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|