| @@ -7,6 +7,7 @@ import { | |||
| MarketplaceIcon, | |||
| } from "./MarketplaceButton.styled"; | |||
| import { useTranslation } from "react-i18next"; | |||
| import history from "../../../../store/utils/history"; | |||
| const MarketplaceButton = () => { | |||
| const { t } = useTranslation(); | |||
| @@ -27,8 +27,6 @@ const ChatCard = (props) => { | |||
| const routeToItem = () => { | |||
| props.navigateToChat(chat?._id); | |||
| }; | |||
| console.log(chat) | |||
| const interlocutor = useMemo(() => { | |||
| return userId === chat?.participants[0]._id ? 1 : 0; | |||
| }, [userId, chat]); | |||
| @@ -21,10 +21,8 @@ const CategoryChoser = forwardRef((props, ref) => { | |||
| const handleSelectCategory = (category) => { | |||
| filters.category.setSelectedCategory(category); | |||
| filters.subcategory.setSelectedSubcategory({}); | |||
| console.log("category 1") | |||
| props.offers.applyFilters(); | |||
| }; | |||
| console.log(props); | |||
| useImperativeHandle(ref, () => ({ | |||
| closeSection: () => { | |||
| setIsOpened(false); | |||
| @@ -15,8 +15,6 @@ const LocationChoser = forwardRef((props, ref) => { | |||
| const [isOpened, setIsOpened] = useState(false); | |||
| const filters = props.filters; | |||
| console.log(props); | |||
| const allLocations = useMemo( | |||
| () => filters.locations.allLocations || [], | |||
| [filters.locations] | |||
| @@ -34,7 +34,6 @@ const SubcategoryChoser = forwardRef((props, ref) => { | |||
| const handleSelectSubcategory = (subcategory) => { | |||
| filters.subcategory.setSelectedSubcategory(subcategory, !props.myOffers); | |||
| console.log("props.offers") | |||
| // if (props.myOffers) props.offers?.applyFilters(); | |||
| }; | |||
| @@ -17,7 +17,6 @@ const CheckboxDropdownList = (props) => { | |||
| const [isOpened, setIsOpened] = useState(false); | |||
| const handleDelete = (item) => { | |||
| props.setItemsSelected([...props.filters.filter((p) => p !== item)]); | |||
| console.log("dropdown 1") | |||
| props.offers.applyFilters(); | |||
| }; | |||
| const handleOpen = () => { | |||
| @@ -9,7 +9,6 @@ const FilterCheckboxDropdown = (props) => { | |||
| const [isOpened, setIsOpened] = useState(false); | |||
| const [toSearch, setToSearch] = useState(""); | |||
| const { data } = props; | |||
| console.log(props); | |||
| useEffect(() => { | |||
| setDataToShow([...data]); | |||
| @@ -55,7 +54,6 @@ const FilterCheckboxDropdown = (props) => { | |||
| props.setItemsSelected([...props.filters, item]); | |||
| props.offers.applyFilters(); | |||
| } | |||
| console.log("filter checkbox 1"); | |||
| } | |||
| }; | |||
| const handleOpen = () => { | |||
| @@ -55,7 +55,6 @@ const FilterSmallDropdown = (props) => { | |||
| props.offers.applyFilters(); | |||
| } | |||
| } | |||
| console.log("dropdown 2") | |||
| }; | |||
| const setDropdownHandler = () => { | |||
| @@ -27,7 +27,6 @@ const OfferDetails = (props) => { | |||
| const [images, setImages] = useState([]); | |||
| const [imagesCarouselModal, setImagesCarouselModal] = useState(false); | |||
| console.log(offer); | |||
| useEffect(() => { | |||
| if (props?.offer?.images) { | |||
| @@ -49,12 +48,10 @@ const OfferDetails = (props) => { | |||
| }); | |||
| } | |||
| }, [props?.offer?.images]); | |||
| console.log(images); | |||
| const date = formatDateLocale(new Date(offer?._created)); | |||
| const onModalClose = () => { | |||
| setImagesCarouselModal(false); | |||
| }; | |||
| console.log(props); | |||
| return ( | |||
| <> | |||
| <Details | |||
| @@ -9,8 +9,14 @@ import { | |||
| import { useTranslation } from "react-i18next"; | |||
| import { acceptExchangeSocket } from "../../../../socket/socket"; | |||
| import { useDispatch, useSelector } from "react-redux"; | |||
| import { selectExchange, selectRequester } from "../../../../store/selectors/exchangeSelector"; | |||
| import { acceptExchange, setRequester } from "../../../../store/actions/exchange/exchangeActions"; | |||
| import { | |||
| selectExchange, | |||
| selectRequester, | |||
| } from "../../../../store/selectors/exchangeSelector"; | |||
| import { | |||
| acceptExchange, | |||
| setRequester, | |||
| } from "../../../../store/actions/exchange/exchangeActions"; | |||
| import { addNewMessage } from "../../../../store/actions/chat/chatActions"; | |||
| import { convertLocalDateToUTCDate } from "../../../../util/helpers/dateHelpers"; | |||
| import requesterStatus from "../../../../constants/requesterStatus"; | |||
| @@ -36,7 +42,9 @@ const RequestExchangeMessage = (props) => { | |||
| addNewMessage({ | |||
| _id: props.chatId, | |||
| message: { | |||
| userId: props.userId, | |||
| user: { | |||
| _id: props.userId, | |||
| }, | |||
| text: "", | |||
| isAcceptRequest: true, | |||
| _created: convertLocalDateToUTCDate(new Date()), | |||
| @@ -65,7 +73,9 @@ const RequestExchangeMessage = (props) => { | |||
| onClick={handleAcceptExchange} | |||
| disabled={props.haveIAccepted} | |||
| > | |||
| {props.haveIAccepted ? t("messages.acceptedRequest") : t("messages.acceptRequest")} | |||
| {props.haveIAccepted | |||
| ? t("messages.acceptedRequest") | |||
| : t("messages.acceptRequest")} | |||
| </RequestExchangeMessageButton> | |||
| </RequestExchangeMessageButtonsContainer> | |||
| </RequestExchangeMessageContainer> | |||
| @@ -61,6 +61,8 @@ export const ChatColumn = (props) => { | |||
| return; | |||
| } | |||
| addMessageListener(({ succeed, data }) => { | |||
| console.log(data); | |||
| if (succeed) { | |||
| dispatch( | |||
| addNewMessage({ | |||
| @@ -109,7 +109,6 @@ const DirectChat = () => { | |||
| }, [exchange, amIBuyer]); | |||
| const interlocutorObject = useMemo(() => { | |||
| console.log(offer); | |||
| if (location?.state?.offerId) { | |||
| return offer?.user; | |||
| } | |||
| @@ -131,6 +130,7 @@ const DirectChat = () => { | |||
| // Listener to socket.IO chat | |||
| useEffect(() => { | |||
| addMessageListener(({ succeed, data }) => { | |||
| console.log(data); | |||
| if (succeed) { | |||
| if ( | |||
| [...allChats].find((item) => { | |||
| @@ -170,11 +170,11 @@ const DirectChat = () => { | |||
| } | |||
| }; | |||
| const handleAcceptExchange = () => { | |||
| console.log(chat) | |||
| let interlocutor = userId === chat?.participants[0]._id ? 1 : 0; | |||
| acceptExchangeSocket( | |||
| chat?._id, | |||
| userId, | |||
| chat?.interlocutor?._id, | |||
| chat?.participants[interlocutor]._id, | |||
| () => { | |||
| dispatch( | |||
| acceptExchange({ | |||
| @@ -185,7 +185,9 @@ const DirectChat = () => { | |||
| addNewMessage({ | |||
| _id: chat?._id, | |||
| message: { | |||
| userId, | |||
| user: { | |||
| _id: userId | |||
| }, | |||
| isAcceptRequest: true, | |||
| text: "", | |||
| _created: convertLocalDateToUTCDate(new Date()), | |||
| @@ -34,12 +34,11 @@ const DirectChatContent = (props) => { | |||
| behaviour: "smooth", | |||
| }); | |||
| window.scrollTo({ top: document.body.scrollHeight, behavior: "smooth" }); | |||
| }, [props?.chat?.chat?.messages, messagesRef, isLoadingChatContent]); | |||
| }, [props?.chat?.messages, messagesRef, isLoadingChatContent]); | |||
| const handleRefresh = () => { | |||
| props.refreshChat(); | |||
| }; | |||
| console.log(props); | |||
| return ( | |||
| <> | |||
| {isLoadingChatContent || isLoadingChatContent === undefined ? ( | |||
| @@ -52,7 +51,7 @@ const DirectChatContent = (props) => { | |||
| /> | |||
| <MessagesList ref={messagesRef} exchangeState={props?.exchangeState}> | |||
| {messages?.map((item) => { | |||
| const isMyMessage = userId === item.userId; | |||
| const isMyMessage = userId === item.user?._id; | |||
| const image = isMyMessage | |||
| ? myProfileImage | |||
| : interlocutorProfileImage; | |||
| @@ -32,7 +32,6 @@ const DirectChatContentHeader = (props) => { | |||
| const [phonePopoverAnchorEl, setPhonePopoverAnchorEl] = useState(null); | |||
| const { isMobile } = useIsMobile(); | |||
| const mineProfileBlocked = useSelector(selectAmIBlocked); | |||
| console.log(props) | |||
| const togglePhonePopover = (event) => { | |||
| if (props.interlocutor?.company?.contacts?.telephone) { | |||
| setShowPhonePopover((prevState) => !prevState); | |||
| @@ -50,7 +49,6 @@ const DirectChatContentHeader = (props) => { | |||
| }) | |||
| ); | |||
| }; | |||
| console.log("in", props); | |||
| return ( | |||
| <> | |||
| <DirectChatContentHeaderContainer> | |||
| @@ -32,10 +32,8 @@ const DirectChatNewMessage = (props) => { | |||
| const location = useLocation(); | |||
| const history = useHistory(); | |||
| const userId = useSelector(selectUserId); | |||
| console.log(props) | |||
| const handleSend = useCallback( | |||
| (newChatId = undefined) => { | |||
| console.log(props?.chat?._id); | |||
| if (typedValue?.length === 0) return; | |||
| if (props?.chat?._id) { | |||
| const chatId = props.chat?._id || newChatId; | |||
| @@ -44,7 +42,9 @@ const DirectChatNewMessage = (props) => { | |||
| addNewMessage({ | |||
| _id: chatId, | |||
| message: { | |||
| userId, | |||
| user: { | |||
| _id: userId, | |||
| }, | |||
| text: typedValue, | |||
| _created: convertLocalDateToUTCDate(new Date()), | |||
| }, | |||
| @@ -62,7 +62,6 @@ const DirectChatNewMessage = (props) => { | |||
| }, | |||
| [typedValue, props.chat?._id, userId, props.interlocutor] | |||
| ); | |||
| console.log(exchange); | |||
| const handleMessageSendSuccess = (newChatId) => { | |||
| history.replace(`${newChatId}`); | |||
| }; | |||
| @@ -86,7 +85,7 @@ const DirectChatNewMessage = (props) => { | |||
| startNewChat({ | |||
| offerId, | |||
| message: typedValue, | |||
| interlocutorUserId: props.interlocutor.userId, | |||
| interlocutorUserId: props.interlocutor._id, | |||
| handleMessageSendSuccess, | |||
| }) | |||
| ); | |||
| @@ -35,7 +35,6 @@ const ItemDetailsHeaderCard = (props) => { | |||
| const { t } = useTranslation(); | |||
| const offer = useMemo(() => { | |||
| if (props.offer) { | |||
| console.log("itemDetailsHeader: ", props.offer) | |||
| if (props.offer._id === routeMatch.params.offerId) { | |||
| return props.offer; | |||
| } | |||
| @@ -31,12 +31,10 @@ const TooltipHeader = (props) => { | |||
| const handleClickCategory = () => { | |||
| props?.offers?.filters?.locations.clear(); | |||
| props?.offers?.filters?.subcategory.clear(); | |||
| console.log("tooltip 1") | |||
| props?.offers?.applyFilters(); | |||
| }; | |||
| const handleClickSubcategory = () => { | |||
| props?.offers?.filters?.locations.clear(); | |||
| console.log("tooltip 2") | |||
| props?.offers?.applyFilters(); | |||
| }; | |||
| const goBack = () => { | |||
| @@ -52,10 +52,12 @@ const EditCategory = (props) => { | |||
| // }; | |||
| const closeModalHandler = () => { | |||
| console.log("closed") | |||
| dispatch(closeModal()); | |||
| }; | |||
| const handleApiResponseSuccess = () => { | |||
| console.log("succes") | |||
| if (clickedOnNext) { | |||
| formik.resetForm(); | |||
| inputRef.current.focus(); | |||
| @@ -41,7 +41,6 @@ export const MyMessages = (props) => { | |||
| } | |||
| }, [userId]); | |||
| useEffect(() => { | |||
| console.log(chats); | |||
| if (chats?.length > 0) { | |||
| setLastChats([...convertMessages(chats)]); | |||
| } | |||
| @@ -11,7 +11,6 @@ const SearchField = (props) => { | |||
| // Event keycode 13 = ENTER keycode | |||
| if (event.keyCode === 13) { | |||
| event.preventDefault(); | |||
| console.log("iz search1") | |||
| handleSearch(); | |||
| } | |||
| }, | |||
| @@ -27,7 +26,6 @@ const SearchField = (props) => { | |||
| searchRef.current.removeEventListener("keyup", listener); | |||
| }; | |||
| const handleSearch = () => { | |||
| console.log("iz search 2") | |||
| if (props.isAdmin) { | |||
| if (props.handleSearch) props.handleSearch(searchRef.current.value); | |||
| else search.searchOffersImmediately(searchRef.current.value); | |||
| @@ -20,7 +20,6 @@ import { useRouteMatch } from "react-router-dom"; | |||
| import { | |||
| fetchReviews, | |||
| setReviews, | |||
| fetchReviewsAsAdmin, | |||
| } from "../../store/actions/review/reviewActions"; | |||
| import { selectIsLoadingByActionType } from "../../store/selectors/loadingSelectors"; | |||
| import SkeletonUserReviews from "./SkeletonUserReviews/SkeletonUserReviews"; | |||
| @@ -54,15 +53,10 @@ const UserReviews = (props) => { | |||
| ) | |||
| ); | |||
| useEffect(() => { | |||
| let idProfile = routeMatch.params?.profileId; | |||
| if (idProfile) { | |||
| if (props.isAdmin) { | |||
| dispatch(fetchReviewsAsAdmin(idProfile)); | |||
| } else { | |||
| dispatch(fetchReviews(idProfile)); | |||
| } | |||
| dispatch(fetchReviews(idProfile)); | |||
| } | |||
| // if (props.profileReviews && routeMatch.params?.profileId) { | |||
| @@ -17,7 +17,6 @@ const useCategoryFilter = () => { | |||
| useEffect(() => { | |||
| setSelectedCategoryLocally(selectedCategory); | |||
| console.log("sleectedCat") | |||
| }, [selectedCategory]); | |||
| // Set selected category locally in state | |||
| @@ -21,7 +21,6 @@ const useFilters = (clearAll = false, applyFilters = () => {}) => { | |||
| if (category.selectedCategoryLocally?._id) sumOfFiltersChosen++; | |||
| if (subcategory.selectedSubcategoryLocally?._id) sumOfFiltersChosen++; | |||
| sumOfFiltersChosen += locations.selectedLocationsLocally.length; | |||
| console.log("numOfFiltersChosen"); | |||
| return sumOfFiltersChosen; | |||
| }, [ | |||
| category.selectedCategoryLocally, | |||
| @@ -39,7 +39,6 @@ const useMyOffers = () => { | |||
| // Filter, search and sort all mine offers | |||
| const allOffersToShow = useMemo(() => { | |||
| let mineOffersFiltered = [...mineOffers]; | |||
| console.log(filters) | |||
| // Filter mine offers by category | |||
| if (filters.category.selectedCategoryLocally?.name) | |||
| mineOffersFiltered = mineOffersFiltered.filter( | |||
| @@ -46,7 +46,6 @@ const useOffers = () => { | |||
| sorting | |||
| ); | |||
| dispatch(setQueryString(convertQueryStringForBackend(newQueryString))); | |||
| console.log("useoff apply") | |||
| }; | |||
| const filters = useFilters(false, apply); | |||
| @@ -71,7 +70,6 @@ const useOffers = () => { | |||
| dispatch(setHeaderString(makeHeaderStringHelper({}))); | |||
| history.location.state = {}; | |||
| } | |||
| console.log("history.log"); | |||
| }, [history.location]); | |||
| // On every change of query string, new header string should be created | |||
| @@ -79,12 +77,10 @@ const useOffers = () => { | |||
| useEffect(() => { | |||
| const headerStringLocal = makeHeaderStringHelper(filters); | |||
| dispatch(setHeaderString(headerStringLocal)); | |||
| console.log("queryStringHook.queryString, filtersCleared") | |||
| }, [queryStringHook.queryString, filtersCleared]); | |||
| // Initially set category, location and subcategory based on query string | |||
| useEffect(() => { | |||
| console.log("!!!!!!!!!!queryStringHook.isInitiallyLoaded") | |||
| if (queryStringHook.isInitiallyLoaded) { | |||
| const queryObject = queryStringHook.queryObject; | |||
| if (KEY_CATEGORY in queryObject) { | |||
| @@ -139,28 +135,23 @@ const useOffers = () => { | |||
| setFiltersCleared(false); | |||
| apply(); | |||
| } | |||
| console.log("filtersCleared") | |||
| }, [filtersCleared]); | |||
| const applyFilters = () => { | |||
| console.log("applyfilters") | |||
| setFiltersCleared(true); | |||
| }; | |||
| const clearFiltersAndApply = () => { | |||
| console.log("applyfilters") | |||
| clear(); | |||
| setFiltersCleared(true); | |||
| }; | |||
| const applySorting = () => { | |||
| console.log("applyfilters") | |||
| paging.changePage(1); | |||
| setFiltersCleared(true); | |||
| }; | |||
| const applySearch = () => { | |||
| console.log("applyfilters") | |||
| paging.changePage(1); | |||
| setFiltersCleared(true); | |||
| }; | |||
| @@ -175,7 +166,6 @@ const useOffers = () => { | |||
| if (queryStringHook.isInitiallyLoaded) { | |||
| search.searchOffers(search.searchString); | |||
| } | |||
| console.log("search log") | |||
| }, [search.searchString]); | |||
| // Clears only filters(does not clear sorting and search) | |||
| @@ -183,7 +173,6 @@ const useOffers = () => { | |||
| filters.clear(); | |||
| paging.changePage(1); | |||
| setFiltersCleared(true); | |||
| console.log("clear log") | |||
| }; | |||
| const clear = () => { | |||
| @@ -8,7 +8,6 @@ const usePaging = (applyAllFilters, disableScroll) => { | |||
| // except on initial load | |||
| useEffect(() => { | |||
| if (isInitallyLoaded && applyAllFilters) { | |||
| console.log("paging apply") | |||
| applyAllFilters(); | |||
| } | |||
| if (!disableScroll) { | |||
| @@ -33,7 +33,6 @@ const useQueryString = () => { | |||
| } else { | |||
| setHistoryStateCleared(true); | |||
| } | |||
| console.log("history location querystr") | |||
| }, [history.location]); | |||
| // Set initially loaded to true on initial load | |||
| @@ -45,7 +44,6 @@ const useQueryString = () => { | |||
| ) { | |||
| setIsInitallyLoaded(true); | |||
| } | |||
| console.log("querystr") | |||
| }, [queryString]); | |||
| // Updating offers on query string change | |||
| @@ -59,7 +57,6 @@ const useQueryString = () => { | |||
| search: convertQueryStringForFrontend(queryString), | |||
| }); | |||
| } | |||
| console.log("querystr, isinit") | |||
| }, [queryString, isInitiallyLoaded]); | |||
| return { | |||
| @@ -33,13 +33,9 @@ const useSubcategoryFilter = (applyFilters = () => {}) => { | |||
| // if (immediateApply) { | |||
| dispatch(setFilteredSubcategory(subcategory)); | |||
| // } | |||
| console.log("funk"); | |||
| }; | |||
| const apply = () => { | |||
| console.log("apply"); | |||
| console.log("SELECTED SUB", selectedSubcategory); | |||
| console.log("SELECTED SUBLOCALLY", selectedSubcategoryLocally); | |||
| if ( | |||
| Number(selectedSubcategory?._id) !== | |||
| Number(selectedSubcategoryLocally?._id) | |||
| @@ -48,7 +44,6 @@ const useSubcategoryFilter = (applyFilters = () => {}) => { | |||
| }; | |||
| const clear = () => { | |||
| console.log("clear"); | |||
| setSelectedSubcategoryLocally(initialOption); | |||
| dispatch(setFilteredSubcategory(initialOption)); | |||
| }; | |||
| @@ -17,7 +17,6 @@ const HomePage = () => { | |||
| const toggleFilters = () => { | |||
| setFiltersOpened((prevFiltersOpened) => !prevFiltersOpened); | |||
| }; | |||
| console.log("rerender") | |||
| return ( | |||
| <HomePageContainer> | |||
| <MainLayout | |||
| @@ -1,8 +1,8 @@ | |||
| import io from "socket.io-client"; | |||
| export const socket = io("https://trampa-api-test.dilig.net/", { | |||
| // export const socket = io("http://localhost:3001/", { | |||
| // export const socket = io(process.env.REACT_APP_BASE_API_URL, { | |||
| // export const socket = io("http://localhost:3001/", { | |||
| // export const socket = io(process.env.REACT_APP_BASE_API_URL, { | |||
| transports: ["websocket"], | |||
| reconnectionAttempts: 5, | |||
| }); | |||
| @@ -20,19 +20,28 @@ export const sendMessage = (chatId, userId, text, receiverUserId) => { | |||
| chatId, | |||
| receiverUserId, | |||
| message: { | |||
| userId, | |||
| user: { | |||
| _id: userId, | |||
| }, | |||
| text, | |||
| }, | |||
| }); | |||
| }; | |||
| export const acceptExchangeSocket = (chatId, userId, receiverUserId, callbackFn) => { | |||
| export const acceptExchangeSocket = ( | |||
| chatId, | |||
| userId, | |||
| receiverUserId, | |||
| callbackFn | |||
| ) => { | |||
| socket.emit("private_message", { | |||
| chatId, | |||
| receiverUserId, | |||
| message: { | |||
| userId, | |||
| user: { | |||
| _id: userId | |||
| }, | |||
| isAcceptRequest: true, | |||
| text: "" | |||
| text: "", | |||
| }, | |||
| }); | |||
| callbackFn(); | |||
| @@ -47,24 +47,25 @@ function clearChats() { | |||
| } | |||
| function addNewMessage(state, { payload }) { | |||
| let allChats = [...state.latestChats]; | |||
| console.log(state); | |||
| console.log("state", state); | |||
| let chat = allChats.find((item) => item._id === payload._id); | |||
| console.log("chat: ", chat); | |||
| if (chat) { | |||
| chat = { | |||
| ...chat, | |||
| messages: [...chat.messages, payload.message], | |||
| }; | |||
| console.log("newchat: ", chat); | |||
| allChats = allChats.filter((item) => item._id !== chat._id); | |||
| console.log("allchats1: ", allChats); | |||
| allChats = [chat, ...allChats]; | |||
| console.log("allchats2: ", allChats); | |||
| } | |||
| let newSelectedChat = {}; | |||
| if (state.selectedChat.chat) { | |||
| newSelectedChat = { ...state.selectedChat }; | |||
| if (newSelectedChat._id === chat._id) | |||
| newSelectedChat = { ...newSelectedChat, chat: chat }; | |||
| } else { | |||
| newSelectedChat = { ...chat }; | |||
| } | |||
| if (state.selectedChat.chat) newSelectedChat = { ...state.selectedChat }; | |||
| console.log("newSelectedChat1: ", newSelectedChat); | |||
| newSelectedChat = { ...chat }; | |||
| console.log("newSelectedChat2: ", newSelectedChat); | |||
| return { | |||
| ...state, | |||
| latestChats: [...allChats], | |||
| @@ -91,7 +91,7 @@ function* fetchOneChat(payload) { | |||
| chatData.data.messages.forEach((item) => { | |||
| if (requester !== requesterStatus.NOONE) return; | |||
| if (item.isAcceptRequest) { | |||
| if (item.userId === userId) requester = requesterStatus.ME; | |||
| if (item.user._id === userId) requester = requesterStatus.ME; | |||
| else requester = requesterStatus.interlocutor; | |||
| } | |||
| }); | |||
| @@ -113,7 +113,7 @@ function* sendMessage(payload) { | |||
| const exchange = yield select(selectExchange); | |||
| const userId = yield select(selectUserId); | |||
| yield call(attemptSendMessage, payload.payload.chatId, messageObject); | |||
| if (chat?.offer?.offer?.userId === userId && exchange.valid === false) { | |||
| if (chat?.offer?.user._id === userId && exchange.valid === false) { | |||
| yield put(validateExchange(exchange._id)); | |||
| } | |||
| yield call(fetchChats); | |||
| @@ -128,6 +128,7 @@ function* sendMessage(payload) { | |||
| } | |||
| function* startNewChat(payload) { | |||
| try { | |||
| console.log(payload) | |||
| const userId = yield select(selectUserId); | |||
| const newChatData = yield call(attemptCreateNewChat, { | |||
| offerId: payload.payload.offerId, | |||
| @@ -150,7 +151,9 @@ function* startNewChat(payload) { | |||
| addNewMessage({ | |||
| _id: newChatId, | |||
| message: { | |||
| userId, | |||
| user: { | |||
| _id: userId | |||
| }, | |||
| text: payload.payload.message, | |||
| _created: new Date().toISOString(), | |||
| }, | |||