| { | { | ||||
| "name": "web", | "name": "web", | ||||
| "version": "4.0.8", | |||||
| "version": "4.0.9", | |||||
| "private": true, | "private": true, | ||||
| "dependencies": { | "dependencies": { | ||||
| "@emotion/react": "^11.5.0", | "@emotion/react": "^11.5.0", |
| bottom: 9px; | bottom: 9px; | ||||
| right: 9px; | right: 9px; | ||||
| &:hover button { | &:hover button { | ||||
| background-color: ${selectedTheme.colors.primaryPurple} !important; | |||||
| color: white !important; | |||||
| background-color: ${props => !props.disabled && `${selectedTheme.colors.primaryPurple} !important`}; | |||||
| color: ${props => !props.disabled && `white !important`}; | |||||
| } | } | ||||
| @media (max-width: 1150px) { | @media (max-width: 1150px) { | ||||
| display: none; | display: none; |
| return true; | return true; | ||||
| }, [userId, props.offer]); | }, [userId, props.offer]); | ||||
| console.log("props", props); | |||||
| return ( | return ( | ||||
| <React.Fragment> | <React.Fragment> | ||||
| <OfferCardContainer | <OfferCardContainer | ||||
| </LikeIconContainer> | </LikeIconContainer> | ||||
| ) : ( | ) : ( | ||||
| <AcceptIconContainer // MENJATI | <AcceptIconContainer // MENJATI | ||||
| customDisabled={ | |||||
| props.exchangeState === exchangeStatus.I_OFFERED | |||||
| // customDisabled={ | |||||
| // props.exchangeState === exchangeStatus.I_OFFERED || | |||||
| // props.disabledReviews | |||||
| // } | |||||
| disabled={ | |||||
| props.exchangeState === exchangeStatus.I_OFFERED || | |||||
| props.disabledReviews | |||||
| } | } | ||||
| disabled={props.exchangeState === exchangeStatus.I_OFFERED} | |||||
| onClick={acceptExchange} | onClick={acceptExchange} | ||||
| > | > | ||||
| <AcceptIcon | <AcceptIcon | ||||
| disabled={props.exchangeState === exchangeStatus.I_OFFERED} | |||||
| disabled={ | |||||
| props.disabledReviews || | |||||
| props.exchangeState === exchangeStatus.I_OFFERED | |||||
| } | |||||
| /> | /> | ||||
| </AcceptIconContainer> | </AcceptIconContainer> | ||||
| ) | ) |
| & path { | & path { | ||||
| stroke: ${(props) => | stroke: ${(props) => | ||||
| props.disabled | props.disabled | ||||
| ? selectedTheme.colors.primaryPurpleDisabled | |||||
| ? selectedTheme.colors.primaryPurple | |||||
| : selectedTheme.colors.primaryPurple}; | : selectedTheme.colors.primaryPurple}; | ||||
| } | } | ||||
| @media (max-width: 600px) { | @media (max-width: 600px) { | ||||
| & path { | & path { | ||||
| fill: ${(props) => | fill: ${(props) => | ||||
| props.disabled | props.disabled | ||||
| ? selectedTheme.colors.primaryPurpleDisabled | |||||
| ? selectedTheme.colors.primaryPurple | |||||
| : selectedTheme.colors.primaryPurple}; | : selectedTheme.colors.primaryPurple}; | ||||
| } | } | ||||
| @media (max-width: 600px) { | @media (max-width: 600px) { |
| max-height: 425px; | max-height: 425px; | ||||
| height: ${(props) => | height: ${(props) => | ||||
| props.exchangeState === exchangeStatus.ACCEPTED || | props.exchangeState === exchangeStatus.ACCEPTED || | ||||
| props.exchangeState === exchangeStatus.I_OFFERED | |||||
| props.exchangeState === exchangeStatus.I_OFFERED || | |||||
| props.exchangeState === exchangeStatus.REVIEWED | |||||
| ? "385px" | ? "385px" | ||||
| : "425px"}; | : "425px"}; | ||||
| overflow-y: auto; | overflow-y: auto; |
| import MiniChatCard from "../../Cards/MiniChatCard/MiniChatCard"; | import MiniChatCard from "../../Cards/MiniChatCard/MiniChatCard"; | ||||
| import { useDispatch, useSelector } from "react-redux"; | import { useDispatch, useSelector } from "react-redux"; | ||||
| import { | import { | ||||
| selectChatsTotal, | |||||
| selectLatestChats, | selectLatestChats, | ||||
| selectSelectedChat, | selectSelectedChat, | ||||
| } from "../../../store/selectors/chatSelectors"; | } from "../../../store/selectors/chatSelectors"; | ||||
| const MiniChatColumn = () => { | const MiniChatColumn = () => { | ||||
| const chats = useSelector(selectLatestChats); | const chats = useSelector(selectLatestChats); | ||||
| const total = useSelector(selectChatsTotal); | |||||
| const selectedChat = useSelector(selectSelectedChat); | const selectedChat = useSelector(selectSelectedChat); | ||||
| const offer = useSelector(selectOffer); | const offer = useSelector(selectOffer); | ||||
| const location = useLocation(); | const location = useLocation(); | ||||
| elementsPerPage={6} | elementsPerPage={6} | ||||
| customPaging | customPaging | ||||
| current={paging.currentPage} | current={paging.currentPage} | ||||
| pages={ | |||||
| chats.length === 6 ? paging.currentPage + 1 : paging.currentPage | |||||
| } | |||||
| totalElements={total} | |||||
| changePage={handleChangePage} | changePage={handleChangePage} | ||||
| > | > | ||||
| <ChatPagingText> | <ChatPagingText> |
| export const MiniChatColumnContainer = styled(Box)` | export const MiniChatColumnContainer = styled(Box)` | ||||
| position: relative; | position: relative; | ||||
| padding-bottom: 50px; | padding-bottom: 50px; | ||||
| @media (max-width: 600px) { | |||||
| @media (max-width: 900px) { | |||||
| display: none; | display: none; | ||||
| } | } | ||||
| `; | `; |
| ) : ( | ) : ( | ||||
| <Tooltip title={t("messages.tooltip")}> | <Tooltip title={t("messages.tooltip")}> | ||||
| <TooltipInnerContainer> | <TooltipInnerContainer> | ||||
| <MessageIcon disabled onClick={() => messageUser(offer)}> | |||||
| <MessageIcon onClick={() => messageUser(offer)}> | |||||
| <MessageColor /> | <MessageColor /> | ||||
| </MessageIcon> | </MessageIcon> | ||||
| </TooltipInnerContainer> | </TooltipInnerContainer> |
| import { MarketPlaceContainer } from "./MarketPlace.styled"; | import { MarketPlaceContainer } from "./MarketPlace.styled"; | ||||
| import Header from "./Header/Header"; | import Header from "./Header/Header"; | ||||
| import Offers from "./Offers/Offers"; | import Offers from "./Offers/Offers"; | ||||
| import { useDispatch } from "react-redux"; | |||||
| import { useEffect } from "react"; | |||||
| import { fetchChats } from "../../store/actions/chat/chatActions"; | |||||
| const MarketPlace = (props) => { | const MarketPlace = (props) => { | ||||
| const [isGrid, setIsGrid] = useState(false); | const [isGrid, setIsGrid] = useState(false); | ||||
| const dispatch = useDispatch(); | |||||
| useEffect(() => { | |||||
| dispatch(fetchChats({ | |||||
| currentPage: 1, | |||||
| })); | |||||
| }, []) | |||||
| const offers = props.offers; | const offers = props.offers; | ||||
| return ( | return ( | ||||
| <MarketPlaceContainer> | <MarketPlaceContainer> |
| export const CHAT_NEW_FETCH_ERROR = createErrorType(CHAT_NEW_SCOPE); | export const CHAT_NEW_FETCH_ERROR = createErrorType(CHAT_NEW_SCOPE); | ||||
| export const CHAT_SET = createSetType("CHAT_SET"); | export const CHAT_SET = createSetType("CHAT_SET"); | ||||
| export const CHAT_TOTAL_SET = createSetType("CHAT_TOTAL_SET"); | |||||
| export const CHAT_ONE_SET = createSetType("CHAT_ONE_SET"); | export const CHAT_ONE_SET = createSetType("CHAT_ONE_SET"); | ||||
| export const CHAT_CLEAR = createSetType("CHAT_CLEAR"); | export const CHAT_CLEAR = createSetType("CHAT_CLEAR"); | ||||
| export const CHAT_ADD_MESSAGE = createSetType("CHAT_ADD_MESSAGE"); | export const CHAT_ADD_MESSAGE = createSetType("CHAT_ADD_MESSAGE"); |
| CHAT_SEND_FETCH, | CHAT_SEND_FETCH, | ||||
| CHAT_SEND_SUCCESS, | CHAT_SEND_SUCCESS, | ||||
| CHAT_SET, | CHAT_SET, | ||||
| CHAT_TOTAL_SET, | |||||
| } from "./chatActionConstants"; | } from "./chatActionConstants"; | ||||
| export const fetchChats = (payload) => ({ | export const fetchChats = (payload) => ({ | ||||
| type: CHAT_SET, | type: CHAT_SET, | ||||
| payload, | payload, | ||||
| }); | }); | ||||
| export const setChatsTotal = (payload) => ({ | |||||
| type: CHAT_TOTAL_SET, | |||||
| payload, | |||||
| }); | |||||
| export const fetchOneChat = (payload) => ({ | export const fetchOneChat = (payload) => ({ | ||||
| type: CHAT_ONE_FETCH, | type: CHAT_ONE_FETCH, | ||||
| payload, | payload, |
| CHAT_CLEAR, | CHAT_CLEAR, | ||||
| CHAT_ONE_SET, | CHAT_ONE_SET, | ||||
| CHAT_SET, | CHAT_SET, | ||||
| CHAT_TOTAL_SET, | |||||
| } from "../../actions/chat/chatActionConstants"; | } from "../../actions/chat/chatActionConstants"; | ||||
| import createReducer from "../../utils/createReducer"; | import createReducer from "../../utils/createReducer"; | ||||
| const initialState = { | const initialState = { | ||||
| latestChats: [], | latestChats: [], | ||||
| selectedChat: {}, | selectedChat: {}, | ||||
| total: 0, | |||||
| }; | }; | ||||
| export default createReducer( | export default createReducer( | ||||
| { | { | ||||
| [CHAT_SET]: setChats, | [CHAT_SET]: setChats, | ||||
| [CHAT_TOTAL_SET]: setChatsTotal, | |||||
| [CHAT_ONE_SET]: setOneChat, | [CHAT_ONE_SET]: setOneChat, | ||||
| [CHAT_CLEAR]: clearChats, | [CHAT_CLEAR]: clearChats, | ||||
| [CHAT_ADD_MESSAGE]: addNewMessage, | [CHAT_ADD_MESSAGE]: addNewMessage, | ||||
| latestChats: [...action.payload], | latestChats: [...action.payload], | ||||
| }; | }; | ||||
| } | } | ||||
| function setChatsTotal(state, action) { | |||||
| return { | |||||
| ...state, | |||||
| total: action.payload | |||||
| }; | |||||
| } | |||||
| function setOneChat(state, action) { | function setOneChat(state, action) { | ||||
| return { | return { | ||||
| ...state, | ...state, |
| sendMessageError, | sendMessageError, | ||||
| sendMessageSuccess, | sendMessageSuccess, | ||||
| setChats, | setChats, | ||||
| setChatsTotal, | |||||
| setOneChat, | setOneChat, | ||||
| startNewChatError, | startNewChatError, | ||||
| startNewChatSuccess, | startNewChatSuccess, | ||||
| }); | }); | ||||
| yield call(console.dir, data); | yield call(console.dir, data); | ||||
| yield put(setChats([...data.data.chatsWithData])); | yield put(setChats([...data.data.chatsWithData])); | ||||
| yield put(setChatsTotal(data.data.total)) | |||||
| yield put(fetchChatsSuccess()); | yield put(fetchChatsSuccess()); | ||||
| } catch (e) { | } catch (e) { | ||||
| yield put(fetchChatsError()); | yield put(fetchChatsError()); | ||||
| }); | }); | ||||
| const queryString = yield select(selectQueryString); | const queryString = yield select(selectQueryString); | ||||
| const data = yield call(attemptFetchChats, { userId, queryString }); | const data = yield call(attemptFetchChats, { userId, queryString }); | ||||
| yield put(setChats([...data.data])); | |||||
| yield put(setChats([...data.data.chatsWithData])); | |||||
| yield put(setChatsTotal(data.data.total)) | |||||
| console.log(data); | |||||
| const newChatId = newChatData.data.chatId; | const newChatId = newChatData.data.chatId; | ||||
| yield put(startNewChatSuccess()); | yield put(startNewChatSuccess()); | ||||
| yield call( | yield call( |
| chatSelector, | chatSelector, | ||||
| (state) => state.latestChats | (state) => state.latestChats | ||||
| ) | ) | ||||
| export const selectChatsTotal = createSelector( | |||||
| chatSelector, | |||||
| (state) => state.total | |||||
| ) | |||||
| export const selectSelectedChat = createSelector( | export const selectSelectedChat = createSelector( | ||||
| chatSelector, | chatSelector, | ||||
| (state) => state.selectedChat | (state) => state.selectedChat |