| import React from "react"; | |||||
| import React, { useEffect, useState } from "react"; | |||||
| import PropTypes from "prop-types"; | import PropTypes from "prop-types"; | ||||
| import { | import { | ||||
| CheckButton, | CheckButton, | ||||
| MessageIcon, | MessageIcon, | ||||
| OfferImage, | |||||
| // OfferImage, | |||||
| OfferTitle, | OfferTitle, | ||||
| OfferCard, | OfferCard, | ||||
| ChatOffer, | ChatOffer, | ||||
| OfferText, | OfferText, | ||||
| ChatCardContainer, | ChatCardContainer, | ||||
| Col, | Col, | ||||
| UserImage, | |||||
| // UserImage, | |||||
| OfferCardContainer, | |||||
| UserImgWrapper, | |||||
| OfferImgWrapper, | |||||
| UserName, | UserName, | ||||
| LastMessage, | LastMessage, | ||||
| Line, | Line, | ||||
| LocationContainer, | LocationContainer, | ||||
| XSText,LocationIcon | |||||
| XSText, | |||||
| LocationIcon, | |||||
| OfferCardContainerMobile, | |||||
| OfferTextMobile, | |||||
| OfferTitleMobile | |||||
| } from "./ChatCard.styled"; | } from "./ChatCard.styled"; | ||||
| import { ReactComponent as Message } from "../../../assets/images/svg/mail.svg"; | import { ReactComponent as Message } from "../../../assets/images/svg/mail.svg"; | ||||
| import { ReactComponent as Location } from "../../../assets/images/svg/location.svg"; | import { ReactComponent as Location } from "../../../assets/images/svg/location.svg"; | ||||
| import selectedTheme from "../../../themes"; | import selectedTheme from "../../../themes"; | ||||
| import { OfferCardContainer } from "../OfferCard/OfferCard.styled"; | |||||
| //import { useHistory } from "react-router-dom"; | |||||
| import {ReactComponent as DummyImage1} from "../../../assets/images/svg/dummyImages/offer-1.svg"; | |||||
| import { useHistory } from "react-router-dom"; | |||||
| import useScreenDimensions from "../../../hooks/useScreenDimensions"; | |||||
| //import { useSelector } from "react-redux"; | |||||
| const ChatCard = (props) => { | const ChatCard = (props) => { | ||||
| // const history = useHistory(); | |||||
| const history = useHistory(); | |||||
| const dimensions = useScreenDimensions(); | |||||
| const [isMobile,setIsMobile] = useState(dimensions.width < 600); | |||||
| // const userId = useSelector(selectUserId); | |||||
| useEffect(() => { | |||||
| console.log(isMobile); | |||||
| const resize = (e) => { | |||||
| if(e.target.outerWidth < 600 && isMobile) | |||||
| setIsMobile(false) | |||||
| else if ( e.target.outerWidth > 600 && !isMobile) | |||||
| setIsMobile(true) | |||||
| }; | |||||
| window.addEventListener('resize', resize); | |||||
| return () => window.removeEventListener('resize', resize); | |||||
| },[]); | |||||
| // const routeToItem = (userId) => { | |||||
| // history.push(`/messages/${userId}`); | |||||
| // }; | |||||
| const routeToItem = (userId) => { | |||||
| history.push(`/messages/${userId}`); | |||||
| }; | |||||
| return ( | return ( | ||||
| <ChatCardContainer> | |||||
| <ChatCardContainer onClick={isMobile ? () => routeToItem('12') : () => {} }> | |||||
| <Col> | <Col> | ||||
| <UserImage /> | |||||
| {/* <UserImage src={DummyImage1} /> */} | |||||
| <UserImgWrapper><DummyImage1></DummyImage1></UserImgWrapper> | |||||
| <ChatInfo> | <ChatInfo> | ||||
| <UserName>Name</UserName> | <UserName>Name</UserName> | ||||
| {/* Only shows on Mobile */} | |||||
| <OfferCardContainerMobile> | |||||
| <OfferTextMobile>Proizvod:</OfferTextMobile> | |||||
| <OfferTitleMobile>Prazne Flase</OfferTitleMobile> | |||||
| </OfferCardContainerMobile> | |||||
| {/* ^^^^^ */} | |||||
| <LastMessage>Last chat details</LastMessage> | <LastMessage>Last chat details</LastMessage> | ||||
| <LocationContainer> | <LocationContainer> | ||||
| <LocationIcon> | <LocationIcon> | ||||
| <Col> | <Col> | ||||
| <ChatOffer> | <ChatOffer> | ||||
| <OfferImage/> | |||||
| <OfferImgWrapper><DummyImage1></DummyImage1></OfferImgWrapper> | |||||
| {/* <OfferImage/> */} | |||||
| <OfferCardContainer> | <OfferCardContainer> | ||||
| <OfferText>Proizvod:</OfferText> | <OfferText>Proizvod:</OfferText> | ||||
| <OfferTitle>Prazne Flase</OfferTitle> | <OfferTitle>Prazne Flase</OfferTitle> | ||||
| </ChatOffer> | </ChatOffer> | ||||
| </Col> | </Col> | ||||
| <Col> | |||||
| <Commands> | <Commands> | ||||
| <MessageIcon vertical={props.vertical}> | <MessageIcon vertical={props.vertical}> | ||||
| <Message /> | <Message /> | ||||
| buttoncolor={selectedTheme.primaryPurple} | buttoncolor={selectedTheme.primaryPurple} | ||||
| textcolor={"white"} | textcolor={"white"} | ||||
| style={{ fontWeight: "600" }} | style={{ fontWeight: "600" }} | ||||
| onClick={() => routeToItem('12')} | |||||
| > | > | ||||
| Pogledaj caskanje | Pogledaj caskanje | ||||
| </CheckButton> | </CheckButton> | ||||
| </Commands> | </Commands> | ||||
| </Col> | |||||
| </ChatCardContainer> | </ChatCardContainer> | ||||
| position: relative; | position: relative; | ||||
| justify-content: space-between; | justify-content: space-between; | ||||
| @media (max-width: 550px) { | @media (max-width: 550px) { | ||||
| height: 184px; | |||||
| padding: 18px; | |||||
| padding-top: 12px; | |||||
| height: auto; | |||||
| ${(props) => | ${(props) => | ||||
| props.vertical && | props.vertical && | ||||
| ` | ` | ||||
| } | } | ||||
| `; | `; | ||||
| export const UserImgWrapper = styled(Box)` | |||||
| overflow: hidden; | |||||
| border-radius: 50%; | |||||
| width: 144px; | |||||
| height: 144px; | |||||
| @media (max-width: 600px) { | |||||
| width: 90px; | |||||
| height: 90px; | |||||
| } | |||||
| `; | |||||
| export const OfferImgWrapper = styled(Box)` | |||||
| overflow: hidden; | |||||
| border-radius: 4px; | |||||
| width: 72px; | |||||
| height: 72px; | |||||
| `; | |||||
| export const OfferFlexContainer = styled(Container)` | export const OfferFlexContainer = styled(Container)` | ||||
| display: flex; | display: flex; | ||||
| flex-direction: row; | flex-direction: row; | ||||
| } | } | ||||
| `; | `; | ||||
| export const OfferCardContainer = styled(Container)` | |||||
| display: flex; | |||||
| flex-direction: column; | |||||
| box-sizing: border-box; | |||||
| padding: 16px; | |||||
| max-width: 2000px; | |||||
| position: relative; | |||||
| @media (max-width: 550px) { | |||||
| } | |||||
| `; | |||||
| export const OfferCardContainerMobile = styled(Box)` | |||||
| display: none; | |||||
| @media (max-width: 550px) { | |||||
| position: relative; | |||||
| display: flex; | |||||
| flex-direction: column; | |||||
| box-sizing: border-box; | |||||
| } | |||||
| `; | |||||
| export const OfferInfo = styled(Box)` | export const OfferInfo = styled(Box)` | ||||
| display: flex; | display: flex; | ||||
| flex: 2; | flex: 2; | ||||
| flex: 1; | flex: 1; | ||||
| color: ${selectedTheme.primaryPurple}; | color: ${selectedTheme.primaryPurple}; | ||||
| font-weight: 700; | font-weight: 700; | ||||
| font-size: 24px; | |||||
| font-size: 18px; | |||||
| cursor: pointer; | cursor: pointer; | ||||
| @media (max-width: 550px) { | @media (max-width: 550px) { | ||||
| font-size: 18px; | |||||
| font-size: 14px; | |||||
| display: none; | display: none; | ||||
| ${(props) => | ${(props) => | ||||
| props.vertical && | props.vertical && | ||||
| `} | `} | ||||
| } | } | ||||
| `; | `; | ||||
| export const OfferTitleMobile = styled(Typography)` | |||||
| font-family: "Open Sans"; | |||||
| display: none; | |||||
| flex: 1; | |||||
| color: ${selectedTheme.primaryPurple}; | |||||
| font-weight: 700; | |||||
| font-size: 18px; | |||||
| cursor: pointer; | |||||
| @media (max-width: 550px) { | |||||
| display: block; | |||||
| ${(props) => | |||||
| props.vertical && | |||||
| ` | |||||
| display: flex; | |||||
| flex: none; | |||||
| position: relative; | |||||
| line-height: 22px; | |||||
| margin-top: 5px; | |||||
| font-size: 18px; | |||||
| `} | |||||
| } | |||||
| `; | |||||
| export const OfferAuthor = styled(Box)` | export const OfferAuthor = styled(Box)` | ||||
| display: flex; | display: flex; | ||||
| flex: 1; | flex: 1; | ||||
| background-color: ${selectedTheme.primaryPurple} !important; | background-color: ${selectedTheme.primaryPurple} !important; | ||||
| color: white !important; | color: white !important; | ||||
| } | } | ||||
| @media (max-width: 600px) { | |||||
| display: none; | |||||
| } | |||||
| `; | `; | ||||
| export const MessageIcon = styled(IconButton)` | export const MessageIcon = styled(IconButton)` | ||||
| width: 40px; | width: 40px; | ||||
| display: flex; | display: flex; | ||||
| flex-direction: row; | flex-direction: row; | ||||
| align-items: center; | align-items: center; | ||||
| @media (max-width: 600px) { | |||||
| display: none; | |||||
| } | |||||
| `; | |||||
| export const OfferText = styled(Box)` | |||||
| font-family: "Open Sans"; | |||||
| font-size: "12px"; | |||||
| color: ${selectedTheme.primaryText}; | |||||
| `; | `; | ||||
| export const OfferText = styled(Box)``; | |||||
| export const OfferTextMobile = styled(Box)` | |||||
| font-family: "Open Sans"; | |||||
| font-size: "12px"; | |||||
| color: ${selectedTheme.primaryText}; | |||||
| `; | |||||
| export const Commands = styled(Box)` | export const Commands = styled(Box)` | ||||
| display: flex; | display: flex; | ||||
| flex-direction: column; | flex-direction: column; | ||||
| justify-content: space-between; | justify-content: space-between; | ||||
| align-items: flex-end; | align-items: flex-end; | ||||
| @media (max-width: 600px) { | |||||
| align-items: flex-start; | |||||
| } | |||||
| `; | `; | ||||
| export const OfferCard = styled(Box)``; | export const OfferCard = styled(Box)``; | ||||
| export const ChatInfo = styled(Box)` | export const ChatInfo = styled(Box)` | ||||
| height: 100%; | |||||
| display: flex; | display: flex; | ||||
| flex-direction: column; | flex-direction: column; | ||||
| justify-content: space-between; | justify-content: space-between; | ||||
| export const Col = styled(Box)` | export const Col = styled(Box)` | ||||
| display: flex; | display: flex; | ||||
| align-items: center; | |||||
| flex-direction: row; | flex-direction: row; | ||||
| gap: 18px; | gap: 18px; | ||||
| `; | `; | ||||
| font-size: 16px; | font-size: 16px; | ||||
| position: relative; | position: relative; | ||||
| @media (max-width: 600px) { | @media (max-width: 600px) { | ||||
| font-size: 14px; | |||||
| display: none; | |||||
| } | } | ||||
| `; | `; | ||||
| display: flex; | display: flex; | ||||
| flex-direction: row; | flex-direction: row; | ||||
| gap: 2px; | gap: 2px; | ||||
| @media (max-width: 600px) { | |||||
| display: none; | |||||
| } | |||||
| `; | `; | ||||
| export const LocationIcon = styled(Box)` | export const LocationIcon = styled(Box)` | ||||
| position: relative; | position: relative; | ||||
| `; | `; | ||||
| export const OfferCardContainer = styled(Box)` | |||||
| display: flex; | |||||
| flex-direction: column; | |||||
| `; | |||||
| export const OfferImage = styled.img` | export const OfferImage = styled.img` | ||||
| max-width: 72px; | max-width: 72px; | ||||
| max-height: 72px; | max-height: 72px; | ||||
| height: 100px; | height: 100px; | ||||
| width: 0; | width: 0; | ||||
| margin: auto 0; | margin: auto 0; | ||||
| @media (max-width: 600px) { | |||||
| display: none; | |||||
| } | |||||
| `; | `; |
| `; | `; | ||||
| export const TitleSortContainer = styled(Box)` | export const TitleSortContainer = styled(Box)` | ||||
| margin-top: 26px; | |||||
| display: flex; | display: flex; | ||||
| flex-direction: row; | flex-direction: row; | ||||
| justify-content: space-between; | justify-content: space-between; |