| @@ -13,6 +13,6 @@ | |||
| }, | |||
| "plugins": ["react"], | |||
| "rules": { | |||
| "max-lines": ["warn", 100] | |||
| // "max-lines": ["warn", 100] | |||
| } | |||
| } | |||
| @@ -76,6 +76,7 @@ const App = () => { | |||
| <Router history={history}> | |||
| <Helmet> | |||
| <title>{i18next.t("app.title")}</title> | |||
| </Helmet> | |||
| <StyledEngineProvider injectFirst> | |||
| {/* <button onClick={handleClick}>Kik</button> */} | |||
| @@ -137,7 +137,6 @@ const CreateOffer = ({ history, closeCreateOfferModal, editOffer, offer }) => { | |||
| condition: informations.condition, | |||
| category: { | |||
| name: informations.category, | |||
| subcategories: subcategories, | |||
| }, | |||
| subcategory: informations.subcategory, | |||
| images: newImgs, | |||
| @@ -33,7 +33,10 @@ const FilterCard = (props) => { | |||
| <LocationChoser filters={filters} /> | |||
| </ContentContainer> | |||
| <FilterFooter /> | |||
| <FilterFooter | |||
| closeResponsive={props.closeResponsive} | |||
| responsiveOpen={props.responsiveOpen} | |||
| /> | |||
| </FilterCardContainer> | |||
| ); | |||
| }; | |||
| @@ -14,7 +14,7 @@ const FilterFooter = (props) => { | |||
| if (props.closeResponsive) props.closeResponsive(); | |||
| }; | |||
| return ( | |||
| <FilterFooterContainer> | |||
| <FilterFooterContainer responsiveOpen={props.responsiveOpen}> | |||
| {props.responsiveOpen && ( | |||
| <PrimaryButton | |||
| variant="outlined" | |||
| @@ -1,4 +1,4 @@ | |||
| import React, { useState } from "react"; | |||
| import React, { useMemo, useState } from "react"; | |||
| import PropTypes from "prop-types"; | |||
| import { | |||
| CheckButton, | |||
| @@ -36,11 +36,14 @@ import { ReactComponent as Message } from "../../../assets/images/svg/mail.svg"; | |||
| import selectedTheme from "../../../themes"; | |||
| import { useHistory } from "react-router-dom"; | |||
| import CreateOffer from "../CreateOfferCard/CreateOffer"; | |||
| import { useSelector } from "react-redux"; | |||
| import { selectUserId } from "../../../store/selectors/loginSelectors"; | |||
| const OfferCard = (props) => { | |||
| const [deleteOfferModal, setDeleteOfferModal] = useState(false); | |||
| const [editOfferModal, setEditOfferModal] = useState(false); | |||
| const history = useHistory(); | |||
| const userId = useSelector(selectUserId); | |||
| const routeToItem = (itemId) => { | |||
| history.push(`/proizvodi/${itemId}`); | |||
| @@ -62,6 +65,13 @@ const OfferCard = (props) => { | |||
| setEditOfferModal(false); | |||
| }; | |||
| const showMessageIcon = useMemo(() => { | |||
| if (userId === props.offer?.userId) { | |||
| return false; | |||
| } | |||
| return true; | |||
| }, [userId, props.offer]); | |||
| if (deleteOfferModal || editOfferModal) { | |||
| document.body.style.overflow = "hidden"; | |||
| } else { | |||
| @@ -114,12 +124,16 @@ const OfferCard = (props) => { | |||
| </DetailIcon> | |||
| <DetailText>{props?.offer?.category?.name}</DetailText> | |||
| </OfferCategory> | |||
| {props.dontShowViews ? (<></>) : (<OfferViews vertical={props.vertical}> | |||
| <DetailIcon color="black" component="span" size="16px"> | |||
| <EyeIcon /> | |||
| </DetailIcon> | |||
| <DetailText>{props?.offer?.views?.count}</DetailText> | |||
| </OfferViews>)} | |||
| {props.dontShowViews ? ( | |||
| <></> | |||
| ) : ( | |||
| <OfferViews vertical={props.vertical}> | |||
| <DetailIcon color="black" component="span" size="16px"> | |||
| <EyeIcon /> | |||
| </DetailIcon> | |||
| <DetailText>{props?.offer?.views?.count}</DetailText> | |||
| </OfferViews> | |||
| )} | |||
| </OfferDetails> | |||
| </OfferInfo> | |||
| {!props.halfwidth ? ( | |||
| @@ -171,7 +185,11 @@ const OfferCard = (props) => { | |||
| <StarIcon disabled={props.disabledReviews} /> | |||
| </StarIconContainer> | |||
| ) : ( | |||
| <MessageIcon vertical={props.vertical} onClick={messageUser}> | |||
| <MessageIcon | |||
| showMessageIcon={showMessageIcon} | |||
| vertical={props.vertical} | |||
| onClick={messageUser} | |||
| > | |||
| <Message /> | |||
| </MessageIcon> | |||
| )} | |||
| @@ -254,6 +254,7 @@ export const CheckButton = styled(PrimaryButton)` | |||
| } | |||
| `; | |||
| export const MessageIcon = styled(IconButton)` | |||
| ${(props) => !props.showMessageIcon && "display: none;"} | |||
| width: 40px; | |||
| height: 40px; | |||
| position: absolute; | |||
| @@ -331,12 +332,16 @@ export const RemoveIconContainer = styled(MessageIcon)` | |||
| `; | |||
| export const RemoveIcon = styled(Remove)``; | |||
| export const EditIconContainer = styled(MessageIcon)` | |||
| display: block; | |||
| right: 70px; | |||
| `; | |||
| export const EditIcon = styled(Edit)``; | |||
| export const StarIconContainer = styled(MessageIcon)` | |||
| opacity: ${props => props.disabled ? "0.4" : "1"}; | |||
| ${props => props.disabled && ` | |||
| display: block; | |||
| opacity: ${(props) => (props.disabled ? "0.4" : "1")}; | |||
| ${(props) => | |||
| props.disabled && | |||
| ` | |||
| cursor: initial; | |||
| & button { | |||
| cursor: initial; | |||
| @@ -89,14 +89,16 @@ const FirstStepCreateReview = (props) => { | |||
| formik.setFieldValue("exchangeSucceed", event.target.value.mainText) | |||
| } | |||
| > | |||
| {Object.keys(reviewEnum).map((property) => ( | |||
| {Object.keys(reviewEnum).map((property) => { | |||
| if (property === "NOT_BAD") return; | |||
| return ( | |||
| <SelectOption | |||
| key={reviewEnum[property].value} | |||
| value={reviewEnum[property]} | |||
| > | |||
| {reviewEnum[property].mainText} | |||
| </SelectOption> | |||
| ))} | |||
| )})} | |||
| </SelectField> | |||
| <FieldLabel leftText={t("reviews.comment")} /> | |||
| @@ -42,7 +42,6 @@ const Login = () => { | |||
| const handleSubmit = (values) => { | |||
| const { email, password } = values; | |||
| console.log(values); | |||
| dispatch(clearLoginErrors()); | |||
| dispatch( | |||
| fetchLogin({ | |||
| @@ -51,6 +50,7 @@ const Login = () => { | |||
| handleApiResponseSuccess, | |||
| }) | |||
| ); | |||
| console.log(values); | |||
| }; | |||
| const formik = useFormik({ | |||
| @@ -14,6 +14,7 @@ const LoginButton = (props) => { | |||
| height="48px" | |||
| fullWidth | |||
| buttoncolor={selectedTheme.primaryPurple} | |||
| onClick={formik.handleSubmit} | |||
| textcolor="white" | |||
| disabled={ | |||
| formik.values.email.length === 0 || formik.values.password.length === 0 | |||
| @@ -95,6 +95,7 @@ const useFilters = (myOffers) => { | |||
| setSelectedLocations([]); | |||
| setSelectedSubcategory(); | |||
| setSelectedCategory(); | |||
| applyFilters(); | |||
| }; | |||
| // Helper function | |||
| @@ -20,6 +20,15 @@ const FirstPartOfRegistration = (props) => { | |||
| const [emailTakenStatus, setEmailTakenStatus] = useState(false); | |||
| const { t } = useTranslation(); | |||
| useEffect(() => { | |||
| console.log(props.informations) | |||
| if (props.informations?.mail) { | |||
| console.log(props.informations) | |||
| formik.setFieldValue("mail", props.informations.mail); | |||
| formik.setFieldValue("password", props.informations.password) | |||
| } | |||
| }, [props.informations]) | |||
| useEffect(() => { | |||
| if (props.error.length > 0) { | |||
| setEmailTakenStatus(true); | |||
| @@ -122,6 +131,7 @@ FirstPartOfRegistration.propTypes = { | |||
| handleSubmit: PropTypes.func, | |||
| error: PropTypes.string, | |||
| errorMessage: PropTypes.string, | |||
| informations: PropTypes.any, | |||
| }; | |||
| export default FirstPartOfRegistration; | |||
| @@ -72,6 +72,7 @@ const Register = () => { | |||
| }; | |||
| const handleSubmit = (values) => { | |||
| console.log(values); | |||
| if (currentStep !== 3) { | |||
| setCurrentStep((prevState) => prevState + 1); | |||
| } else { | |||
| @@ -94,13 +95,13 @@ const Register = () => { | |||
| const goStepBack = (stepNumber) => { | |||
| setCurrentStep(stepNumber); | |||
| const { mail, password, image } = informations; | |||
| if (stepNumber === 1) { | |||
| setInformations({ image }); | |||
| } | |||
| if (stepNumber === 2) { | |||
| setInformations({ mail, password, image }); | |||
| } | |||
| // const { mail, password, image } = informations; | |||
| // if (stepNumber === 1) { | |||
| // setInformations({ image }); | |||
| // } | |||
| // if (stepNumber === 2) { | |||
| // setInformations({ mail, password, image }); | |||
| // } | |||
| }; | |||
| return ( | |||
| @@ -131,6 +132,7 @@ const Register = () => { | |||
| {currentStep === 1 && ( | |||
| <FirstPartOfRegistration | |||
| handleSubmit={handleSubmit} | |||
| informations={informations} | |||
| error={mailError} | |||
| errorMessage={mailErrorMessage} | |||
| /> | |||
| @@ -138,12 +140,13 @@ const Register = () => { | |||
| {currentStep === 2 && ( | |||
| <SecondPartOfRegistration | |||
| handleSubmit={handleSubmit} | |||
| informations={informations} | |||
| error={PIBError} | |||
| errorMessage={PIBErrorMessage} | |||
| /> | |||
| )} | |||
| {currentStep === 3 && ( | |||
| <ThirdPartOfRegistration handleSubmit={handleSubmit} /> | |||
| <ThirdPartOfRegistration handleSubmit={handleSubmit} informations={informations} /> | |||
| )} | |||
| {imageError && <ErrorMessage>{t("register.imageError")}</ErrorMessage>} | |||
| @@ -22,6 +22,13 @@ const SecondPartOfRegistration = (props) => { | |||
| } | |||
| }, [props.error]); | |||
| useEffect(() => { | |||
| if (props.informations?.nameOfFirm) { | |||
| formik.setFieldValue("nameOfFirm", props.informations?.nameOfFirm); | |||
| formik.setFieldValue("PIB", props.informations.PIB) | |||
| } | |||
| }, [props.informations]) | |||
| const formik = useFormik({ | |||
| initialValues: { | |||
| nameOfFirm: "", | |||
| @@ -96,6 +103,7 @@ const SecondPartOfRegistration = (props) => { | |||
| SecondPartOfRegistration.propTypes = { | |||
| children: PropTypes.node, | |||
| handleSubmit: PropTypes.func, | |||
| informations: PropTypes.any, | |||
| error: PropTypes.string, | |||
| errorMessage: PropTypes.string, | |||
| }; | |||
| @@ -1,4 +1,4 @@ | |||
| import React from "react"; | |||
| import React, { useEffect } from "react"; | |||
| import PropTypes from "prop-types"; | |||
| import { | |||
| FormContainer, | |||
| @@ -14,6 +14,29 @@ import selectedTheme from "../../../../themes"; | |||
| const ThirdPartOfRegistration = (props) => { | |||
| const { t } = useTranslation(); | |||
| useEffect(() => { | |||
| if (props.informations?.phoneNumber) { | |||
| formik.setFieldValue("phoneNumber", props.informations?.phoneNumber) | |||
| } | |||
| if (props.informations?.location) { | |||
| formik.setFieldValue("location", props.informations?.location) | |||
| } | |||
| if (props.informations?.website) { | |||
| formik.setFieldValue("website", props.informations?.website) | |||
| } | |||
| }, [props.informations]) | |||
| const handleSubmit = () => { | |||
| if (!formik.values.website.matches( | |||
| /^((ftp|http|https):\/\/)?(www.)?(?!.*(ftp|http|https|www.))[a-zA-Z0-9_-]+(\.[a-zA-Z]+)+((\/)[\w#]+)*(\/\w+\?[a-zA-Z0-9_]+=\w+(&[a-zA-Z0-9_]+=\w+)*)?$/gm | |||
| )) { | |||
| formik.setFieldError("website"); | |||
| } else{ | |||
| props.handleSubmit(formik.values); | |||
| } | |||
| } | |||
| const formik = useFormik({ | |||
| initialValues: { | |||
| phoneNumber: "", | |||
| @@ -21,13 +44,11 @@ const ThirdPartOfRegistration = (props) => { | |||
| website: "", | |||
| }, | |||
| validationSchema: Yup.object().shape({ | |||
| phoneNumber: Yup.number().required(t("login.usernameRequired")), | |||
| location: Yup.string().required(t("login.passwordRequired")), | |||
| website: Yup.string().matches( | |||
| /^((ftp|http|https):\/\/)?(www.)?(?!.*(ftp|http|https|www.))[a-zA-Z0-9_-]+(\.[a-zA-Z]+)+((\/)[\w#]+)*(\/\w+\?[a-zA-Z0-9_]+=\w+(&[a-zA-Z0-9_]+=\w+)*)?$/gm | |||
| ), | |||
| phoneNumber: Yup.number(), | |||
| location: Yup.string(), | |||
| website: Yup.string() | |||
| }), | |||
| onSubmit: props.handleSubmit, | |||
| onSubmit: handleSubmit, | |||
| validateOnBlur: true, | |||
| enableReinitialize: true, | |||
| }); | |||
| @@ -99,6 +120,7 @@ const ThirdPartOfRegistration = (props) => { | |||
| ThirdPartOfRegistration.propTypes = { | |||
| children: PropTypes.node, | |||
| handleSubmit: PropTypes.func, | |||
| informations: PropTypes.any, | |||
| }; | |||
| export default ThirdPartOfRegistration; | |||
| @@ -3,7 +3,9 @@ import queryString from "qs"; | |||
| const request = axios.create({ | |||
| // baseURL: "http://192.168.88.150:3001/", | |||
| baseURL: "http://192.168.88.175:3005/", | |||
| // baseURL: "http://192.168.88.175:3005/", | |||
| baseURL: "https://trampa-api.dilig.net/", | |||
| headers: { | |||
| "Content-Type": "application/json", | |||
| }, | |||
| @@ -13,7 +13,8 @@ import { logoutUser, refreshUserToken } from "../actions/login/loginActions"; | |||
| // import { setUserAccessToken } from "../actions/user/userActions"; | |||
| //Change URL with .env | |||
| const baseURL = "http://192.168.88.175:3005/"; | |||
| const baseURL = "https://trampa-api.dilig.net/"; | |||
| // const baseURL = "http://192.168.88.175:3005/"; | |||
| // const baseURL = "http://192.168.88.175:3005/"; | |||
| //Interceptor unique name | |||
| @@ -4,8 +4,7 @@ import { COUNTER_INCREASE } from "../actions/counter/counterActionConstants"; | |||
| function* increaseCounter(payload) { | |||
| try { | |||
| yield call(console.log, payload.payload); | |||
| yield call(attemptIncreaseCounter(payload.payload)); | |||
| yield call(attemptIncreaseCounter, payload.payload); | |||
| } catch(e) { | |||
| console.log(e); | |||
| } | |||
| @@ -39,6 +39,7 @@ import { clearChat } from "../actions/chat/chatActions"; | |||
| function* fetchLogin({ payload }) { | |||
| try { | |||
| console.log('barem ide') | |||
| const { data } = yield call(attemptLogin, payload); | |||
| if (data.token) { | |||
| const token = data.token; | |||
| @@ -57,6 +57,7 @@ function* fetchOffers(payload) { | |||
| attemptFetchOffers, | |||
| "?" + newQueryString.toString() | |||
| ); | |||
| console.log('data::::::::: ', data.data) | |||
| yield put(setTotalOffers(data.data.total)); | |||
| yield put(setOffers(data.data.items.regularOffers)); | |||
| yield put(setPinnedOffers(data.data.items.pinnedOffers)); | |||