diff --git a/src/stores/FormStore.js b/src/stores/FormStore.js new file mode 100644 index 0000000..7fef332 --- /dev/null +++ b/src/stores/FormStore.js @@ -0,0 +1,13 @@ +import { create } from 'zustand'; +import { RealTimeAPI } from '@/lib/realTimeAPI'; +import { olog, isEmpty } from '@/utils/utils'; +import { receivedMsgTypeMapped, handleNotification } from '@/lib/msgUtils'; +import { fetchConversationsList, fetchTemplates, fetchMessages } from '@/actions/ConversationActions'; +import { devtools } from 'zustand/middleware'; +import { WS_URL } from '@/config'; + +export const useFormStore = create(devtools((set, get) => ({ + chatHistory: {}, + setChatHistory: (chatHistory) => set({ chatHistory }), +}))); +export default useFormStore; diff --git a/src/views/ChatHistory.jsx b/src/views/ChatHistory.jsx index 31a0585..4cfcfa1 100644 --- a/src/views/ChatHistory.jsx +++ b/src/views/ChatHistory.jsx @@ -5,6 +5,8 @@ import { StarFilled, ZoomInOutlined, StarOutlined, SearchOutlined } from '@ant-d import { ChatList, ChatItem, MessageBox } from 'react-chat-elements'; import { fetchConversationsList, fetchMessages } from '@/actions/ConversationActions'; import { isEmpty } from '@/utils/utils'; +import useFormStore from '@/stores/FormStore'; +import { useShallow } from 'zustand/react/shallow'; const { Sider, Content, Header, Footer } = Layout; const { Search } = Input; @@ -63,7 +65,7 @@ const data = [ ]; // eslint-disable-next-line react/display-name -const SearchForm = memo(function ({ onSubmit }) { +const SearchForm = memo(function ({ initialValues, onSubmit }) { const [form] = Form.useForm(); function handleSubmit(values) { onSubmit?.(values); @@ -72,7 +74,7 @@ const SearchForm = memo(function ({ onSubmit }) {
[state.chatHistory, state.setChatHistory]), + ) + const handleSubmit = useCallback((values) => { setFormValues({ ...values }); @@ -290,7 +296,7 @@ function ChatHistory() { )); return ( <> - +