@esvndev/es-react-template-chat 0.0.30 → 0.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -26824,9 +26824,9 @@ const appChatSlice = toolkit.createSlice({
26824
26824
  // builder.addCase(update_chat_room_member.fulfilled, (state: IFState) => {
26825
26825
  // state.checkInit = !state.checkInit
26826
26826
  // })
26827
- // builder.addCase(get_history.fulfilled, (state: IFState, action) => {
26828
- // state.listHistory = action.payload?.items
26829
- // })
26827
+ builder.addCase(get_history.fulfilled, (state, action) => {
26828
+ state.listHistory = action.payload?.items;
26829
+ });
26830
26830
  // builder.addCase(getPinMessageChatRoomApi.fulfilled, (state: IFState, action) => {
26831
26831
  // // Backend trả về danh sách PinMessage (mảng / items / data)
26832
26832
  // const payload = action.payload as any
@@ -26857,12 +26857,27 @@ const appChatSlice = toolkit.createSlice({
26857
26857
  });
26858
26858
  appChatSlice.actions;
26859
26859
 
26860
+ //import * as chatStore from '../store'
26860
26861
  const useChat = () => {
26861
26862
  const dispatch = configureStore.useAppDispatch();
26862
26863
  const { active, checkInit, chatRoomId, userLogin, listContact, contactId, typeChat, loadChat, messageByGroup, listHistory, listChatType, archiveStore, checkScroll, listGeneralGroup, pinnedMessages, typingUsers } = configureStore.useAppSelector((state) => state.chat);
26863
26864
  const getHistoryApi = (params) => {
26864
26865
  return dispatch(get_history(params));
26865
26866
  };
26867
+ // const getHistoryApi = async (params: any) => {
26868
+ // const queryString = new URLSearchParams(params).toString()
26869
+ // const response = await fetch(`${CHAT.URL_API.GET_HISTORY_API}?${queryString}`, {
26870
+ // method: 'GET',
26871
+ // headers: {
26872
+ // 'Authorization': `Bearer ${getToken()}`,
26873
+ // 'Content-Type': 'application/json'
26874
+ // }
26875
+ // })
26876
+ // if (!response.ok) {
26877
+ // throw new Error(`HTTP error! status: ${response.status}`)
26878
+ // }
26879
+ // return response.json()
26880
+ // }
26866
26881
  // const get_message_by_group_cursor_api = (params: any) => {
26867
26882
  // return dispatch(chatStore.get_message_by_group_cursor(params))
26868
26883
  // }
@@ -26985,15 +27000,15 @@ const useChat = () => {
26985
27000
  };
26986
27001
 
26987
27002
  const AppChat = () => {
26988
- const { active,
27003
+ const { active,
26989
27004
  // contactId,
26990
- // typeChat,
27005
+ typeChat,
26991
27006
  // chatRoomId,
26992
27007
  // messageByGroup,
26993
27008
  // listHistory,
26994
27009
  // checkInit,
26995
27010
  // setScroll,
26996
- // getHistoryApi,
27011
+ getHistoryApi,
26997
27012
  // getProfileApi,
26998
27013
  // getInfoApi,
26999
27014
  // getContactApi,
@@ -27009,27 +27024,27 @@ const AppChat = () => {
27009
27024
  // const [dataProfile, setDataProfile] = useState({})
27010
27025
  // const [sidebarRight, setSidebarRight] = useState(false)
27011
27026
  // const handleSidebarRight = () => setSidebarRight(!sidebarRight)
27012
- // const [tagFilter] = useState<string>('')
27013
- // const [filterTab] = useState<'all' | 'unread' | 'tag'>('all')
27027
+ const [tagFilter] = React.useState('');
27028
+ const [filterTab] = React.useState('all');
27014
27029
  // const [openModalGroupInfo, setOpenModalGroupInfo] = useState(false)
27015
27030
  // const [openModalAddUserGroup, setOpenModalAddUserGroup] = useState(false)
27016
27031
  // const [windowSize, setWindowSize] = useState(getWindowSize())
27017
- // const [search] = useState('')
27032
+ const [search] = React.useState('');
27018
27033
  // const [contact, setContact] = useState([])
27019
27034
  // // ** Set user function for Right Sidebar
27020
27035
  // const handleModalAddUserGroup = () => setOpenModalAddUserGroup(!openModalAddUserGroup)
27021
27036
  // const handleModalGroupInfo = () => setOpenModalGroupInfo(!openModalGroupInfo)
27022
- // const getData = () => {
27023
- // const paging = {
27024
- // keyword: search,
27025
- // filter: filterTab === 'unread' ? 'unread' : '',
27026
- // order: '',
27027
- // pageNumber: 1,
27028
- // pageSize: 20,
27029
- // tag: tagFilter || undefined
27030
- // }
27031
- // getHistoryApi(paging)
27032
- // }
27037
+ const getData = () => {
27038
+ const paging = {
27039
+ keyword: search,
27040
+ filter: filterTab === 'unread' ? 'unread' : '',
27041
+ order: '',
27042
+ pageNumber: 1,
27043
+ pageSize: 20,
27044
+ tag: tagFilter || undefined
27045
+ };
27046
+ getHistoryApi(paging);
27047
+ };
27033
27048
  // const getContact = () => {
27034
27049
  // getContactApi({
27035
27050
  // keyword: search,
@@ -27046,14 +27061,12 @@ const AppChat = () => {
27046
27061
  // .then((rs: any) => setDataProfile(rs))
27047
27062
  // .catch((ex: any) => console.log(ex))
27048
27063
  // }
27049
- // useEffect(() => {
27050
- // if (typeChat !== 'CONTACT') {
27051
- // getData()
27052
- // } else {
27053
- // getContact()
27054
- // }
27055
- // getDataProfile()
27056
- // }, [typeChat, search, checkInit, tagFilter, filterTab])
27064
+ React.useEffect(() => {
27065
+ if (typeChat !== 'CONTACT') {
27066
+ getData();
27067
+ }
27068
+ //getDataProfile()
27069
+ }, [typeChat, search, tagFilter, filterTab]);
27057
27070
  // useEffect(() => {
27058
27071
  // const handleWindowResize = () => {
27059
27072
  // setWindowSize(getWindowSize())