@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.mjs CHANGED
@@ -26801,9 +26801,9 @@ const appChatSlice = createSlice({
26801
26801
  // builder.addCase(update_chat_room_member.fulfilled, (state: IFState) => {
26802
26802
  // state.checkInit = !state.checkInit
26803
26803
  // })
26804
- // builder.addCase(get_history.fulfilled, (state: IFState, action) => {
26805
- // state.listHistory = action.payload?.items
26806
- // })
26804
+ builder.addCase(get_history.fulfilled, (state, action) => {
26805
+ state.listHistory = action.payload?.items;
26806
+ });
26807
26807
  // builder.addCase(getPinMessageChatRoomApi.fulfilled, (state: IFState, action) => {
26808
26808
  // // Backend trả về danh sách PinMessage (mảng / items / data)
26809
26809
  // const payload = action.payload as any
@@ -26834,12 +26834,27 @@ const appChatSlice = createSlice({
26834
26834
  });
26835
26835
  appChatSlice.actions;
26836
26836
 
26837
+ //import * as chatStore from '../store'
26837
26838
  const useChat = () => {
26838
26839
  const dispatch = useAppDispatch();
26839
26840
  const { active, checkInit, chatRoomId, userLogin, listContact, contactId, typeChat, loadChat, messageByGroup, listHistory, listChatType, archiveStore, checkScroll, listGeneralGroup, pinnedMessages, typingUsers } = useAppSelector((state) => state.chat);
26840
26841
  const getHistoryApi = (params) => {
26841
26842
  return dispatch(get_history(params));
26842
26843
  };
26844
+ // const getHistoryApi = async (params: any) => {
26845
+ // const queryString = new URLSearchParams(params).toString()
26846
+ // const response = await fetch(`${CHAT.URL_API.GET_HISTORY_API}?${queryString}`, {
26847
+ // method: 'GET',
26848
+ // headers: {
26849
+ // 'Authorization': `Bearer ${getToken()}`,
26850
+ // 'Content-Type': 'application/json'
26851
+ // }
26852
+ // })
26853
+ // if (!response.ok) {
26854
+ // throw new Error(`HTTP error! status: ${response.status}`)
26855
+ // }
26856
+ // return response.json()
26857
+ // }
26843
26858
  // const get_message_by_group_cursor_api = (params: any) => {
26844
26859
  // return dispatch(chatStore.get_message_by_group_cursor(params))
26845
26860
  // }
@@ -26962,15 +26977,15 @@ const useChat = () => {
26962
26977
  };
26963
26978
 
26964
26979
  const AppChat = () => {
26965
- const { active,
26980
+ const { active,
26966
26981
  // contactId,
26967
- // typeChat,
26982
+ typeChat,
26968
26983
  // chatRoomId,
26969
26984
  // messageByGroup,
26970
26985
  // listHistory,
26971
26986
  // checkInit,
26972
26987
  // setScroll,
26973
- // getHistoryApi,
26988
+ getHistoryApi,
26974
26989
  // getProfileApi,
26975
26990
  // getInfoApi,
26976
26991
  // getContactApi,
@@ -26986,27 +27001,27 @@ const AppChat = () => {
26986
27001
  // const [dataProfile, setDataProfile] = useState({})
26987
27002
  // const [sidebarRight, setSidebarRight] = useState(false)
26988
27003
  // const handleSidebarRight = () => setSidebarRight(!sidebarRight)
26989
- // const [tagFilter] = useState<string>('')
26990
- // const [filterTab] = useState<'all' | 'unread' | 'tag'>('all')
27004
+ const [tagFilter] = useState('');
27005
+ const [filterTab] = useState('all');
26991
27006
  // const [openModalGroupInfo, setOpenModalGroupInfo] = useState(false)
26992
27007
  // const [openModalAddUserGroup, setOpenModalAddUserGroup] = useState(false)
26993
27008
  // const [windowSize, setWindowSize] = useState(getWindowSize())
26994
- // const [search] = useState('')
27009
+ const [search] = useState('');
26995
27010
  // const [contact, setContact] = useState([])
26996
27011
  // // ** Set user function for Right Sidebar
26997
27012
  // const handleModalAddUserGroup = () => setOpenModalAddUserGroup(!openModalAddUserGroup)
26998
27013
  // const handleModalGroupInfo = () => setOpenModalGroupInfo(!openModalGroupInfo)
26999
- // const getData = () => {
27000
- // const paging = {
27001
- // keyword: search,
27002
- // filter: filterTab === 'unread' ? 'unread' : '',
27003
- // order: '',
27004
- // pageNumber: 1,
27005
- // pageSize: 20,
27006
- // tag: tagFilter || undefined
27007
- // }
27008
- // getHistoryApi(paging)
27009
- // }
27014
+ const getData = () => {
27015
+ const paging = {
27016
+ keyword: search,
27017
+ filter: filterTab === 'unread' ? 'unread' : '',
27018
+ order: '',
27019
+ pageNumber: 1,
27020
+ pageSize: 20,
27021
+ tag: tagFilter || undefined
27022
+ };
27023
+ getHistoryApi(paging);
27024
+ };
27010
27025
  // const getContact = () => {
27011
27026
  // getContactApi({
27012
27027
  // keyword: search,
@@ -27023,14 +27038,12 @@ const AppChat = () => {
27023
27038
  // .then((rs: any) => setDataProfile(rs))
27024
27039
  // .catch((ex: any) => console.log(ex))
27025
27040
  // }
27026
- // useEffect(() => {
27027
- // if (typeChat !== 'CONTACT') {
27028
- // getData()
27029
- // } else {
27030
- // getContact()
27031
- // }
27032
- // getDataProfile()
27033
- // }, [typeChat, search, checkInit, tagFilter, filterTab])
27041
+ useEffect(() => {
27042
+ if (typeChat !== 'CONTACT') {
27043
+ getData();
27044
+ }
27045
+ //getDataProfile()
27046
+ }, [typeChat, search, tagFilter, filterTab]);
27034
27047
  // useEffect(() => {
27035
27048
  // const handleWindowResize = () => {
27036
27049
  // setWindowSize(getWindowSize())