| }, | }, | ||||
| "plugins": ["react"], | "plugins": ["react"], | ||||
| "rules": { | "rules": { | ||||
| "max-lines": ["warn", 100] | |||||
| // "max-lines": ["warn", 100] | |||||
| } | } | ||||
| } | } |
| <Router history={history}> | <Router history={history}> | ||||
| <Helmet> | <Helmet> | ||||
| <title>{i18next.t("app.title")}</title> | <title>{i18next.t("app.title")}</title> | ||||
| </Helmet> | </Helmet> | ||||
| <StyledEngineProvider injectFirst> | <StyledEngineProvider injectFirst> | ||||
| {/* <button onClick={handleClick}>Kik</button> */} | {/* <button onClick={handleClick}>Kik</button> */} |
| condition: informations.condition, | condition: informations.condition, | ||||
| category: { | category: { | ||||
| name: informations.category, | name: informations.category, | ||||
| subcategories: subcategories, | |||||
| }, | }, | ||||
| subcategory: informations.subcategory, | subcategory: informations.subcategory, | ||||
| images: newImgs, | images: newImgs, |
| <LocationChoser filters={filters} /> | <LocationChoser filters={filters} /> | ||||
| </ContentContainer> | </ContentContainer> | ||||
| <FilterFooter /> | |||||
| <FilterFooter | |||||
| closeResponsive={props.closeResponsive} | |||||
| responsiveOpen={props.responsiveOpen} | |||||
| /> | |||||
| </FilterCardContainer> | </FilterCardContainer> | ||||
| ); | ); | ||||
| }; | }; |
| if (props.closeResponsive) props.closeResponsive(); | if (props.closeResponsive) props.closeResponsive(); | ||||
| }; | }; | ||||
| return ( | return ( | ||||
| <FilterFooterContainer> | |||||
| <FilterFooterContainer responsiveOpen={props.responsiveOpen}> | |||||
| {props.responsiveOpen && ( | {props.responsiveOpen && ( | ||||
| <PrimaryButton | <PrimaryButton | ||||
| variant="outlined" | variant="outlined" |
| import React, { useState } from "react"; | |||||
| import React, { useMemo, useState } from "react"; | |||||
| import PropTypes from "prop-types"; | import PropTypes from "prop-types"; | ||||
| import { | import { | ||||
| CheckButton, | CheckButton, | ||||
| import selectedTheme from "../../../themes"; | import selectedTheme from "../../../themes"; | ||||
| import { useHistory } from "react-router-dom"; | import { useHistory } from "react-router-dom"; | ||||
| import CreateOffer from "../CreateOfferCard/CreateOffer"; | import CreateOffer from "../CreateOfferCard/CreateOffer"; | ||||
| import { useSelector } from "react-redux"; | |||||
| import { selectUserId } from "../../../store/selectors/loginSelectors"; | |||||
| const OfferCard = (props) => { | const OfferCard = (props) => { | ||||
| const [deleteOfferModal, setDeleteOfferModal] = useState(false); | const [deleteOfferModal, setDeleteOfferModal] = useState(false); | ||||
| const [editOfferModal, setEditOfferModal] = useState(false); | const [editOfferModal, setEditOfferModal] = useState(false); | ||||
| const history = useHistory(); | const history = useHistory(); | ||||
| const userId = useSelector(selectUserId); | |||||
| const routeToItem = (itemId) => { | const routeToItem = (itemId) => { | ||||
| history.push(`/proizvodi/${itemId}`); | history.push(`/proizvodi/${itemId}`); | ||||
| setEditOfferModal(false); | setEditOfferModal(false); | ||||
| }; | }; | ||||
| const showMessageIcon = useMemo(() => { | |||||
| if (userId === props.offer?.userId) { | |||||
| return false; | |||||
| } | |||||
| return true; | |||||
| }, [userId, props.offer]); | |||||
| if (deleteOfferModal || editOfferModal) { | if (deleteOfferModal || editOfferModal) { | ||||
| document.body.style.overflow = "hidden"; | document.body.style.overflow = "hidden"; | ||||
| } else { | } else { | ||||
| </DetailIcon> | </DetailIcon> | ||||
| <DetailText>{props?.offer?.category?.name}</DetailText> | <DetailText>{props?.offer?.category?.name}</DetailText> | ||||
| </OfferCategory> | </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> | </OfferDetails> | ||||
| </OfferInfo> | </OfferInfo> | ||||
| {!props.halfwidth ? ( | {!props.halfwidth ? ( | ||||
| <StarIcon disabled={props.disabledReviews} /> | <StarIcon disabled={props.disabledReviews} /> | ||||
| </StarIconContainer> | </StarIconContainer> | ||||
| ) : ( | ) : ( | ||||
| <MessageIcon vertical={props.vertical} onClick={messageUser}> | |||||
| <MessageIcon | |||||
| showMessageIcon={showMessageIcon} | |||||
| vertical={props.vertical} | |||||
| onClick={messageUser} | |||||
| > | |||||
| <Message /> | <Message /> | ||||
| </MessageIcon> | </MessageIcon> | ||||
| )} | )} |
| } | } | ||||
| `; | `; | ||||
| export const MessageIcon = styled(IconButton)` | export const MessageIcon = styled(IconButton)` | ||||
| ${(props) => !props.showMessageIcon && "display: none;"} | |||||
| width: 40px; | width: 40px; | ||||
| height: 40px; | height: 40px; | ||||
| position: absolute; | position: absolute; | ||||
| `; | `; | ||||
| export const RemoveIcon = styled(Remove)``; | export const RemoveIcon = styled(Remove)``; | ||||
| export const EditIconContainer = styled(MessageIcon)` | export const EditIconContainer = styled(MessageIcon)` | ||||
| display: block; | |||||
| right: 70px; | right: 70px; | ||||
| `; | `; | ||||
| export const EditIcon = styled(Edit)``; | export const EditIcon = styled(Edit)``; | ||||
| export const StarIconContainer = styled(MessageIcon)` | 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; | cursor: initial; | ||||
| & button { | & button { | ||||
| cursor: initial; | cursor: initial; |
| formik.setFieldValue("exchangeSucceed", event.target.value.mainText) | formik.setFieldValue("exchangeSucceed", event.target.value.mainText) | ||||
| } | } | ||||
| > | > | ||||
| {Object.keys(reviewEnum).map((property) => ( | |||||
| {Object.keys(reviewEnum).map((property) => { | |||||
| if (property === "NOT_BAD") return; | |||||
| return ( | |||||
| <SelectOption | <SelectOption | ||||
| key={reviewEnum[property].value} | key={reviewEnum[property].value} | ||||
| value={reviewEnum[property]} | value={reviewEnum[property]} | ||||
| > | > | ||||
| {reviewEnum[property].mainText} | {reviewEnum[property].mainText} | ||||
| </SelectOption> | </SelectOption> | ||||
| ))} | |||||
| )})} | |||||
| </SelectField> | </SelectField> | ||||
| <FieldLabel leftText={t("reviews.comment")} /> | <FieldLabel leftText={t("reviews.comment")} /> |
| const handleSubmit = (values) => { | const handleSubmit = (values) => { | ||||
| const { email, password } = values; | const { email, password } = values; | ||||
| console.log(values); | |||||
| dispatch(clearLoginErrors()); | dispatch(clearLoginErrors()); | ||||
| dispatch( | dispatch( | ||||
| fetchLogin({ | fetchLogin({ | ||||
| handleApiResponseSuccess, | handleApiResponseSuccess, | ||||
| }) | }) | ||||
| ); | ); | ||||
| console.log(values); | |||||
| }; | }; | ||||
| const formik = useFormik({ | const formik = useFormik({ |
| height="48px" | height="48px" | ||||
| fullWidth | fullWidth | ||||
| buttoncolor={selectedTheme.primaryPurple} | buttoncolor={selectedTheme.primaryPurple} | ||||
| onClick={formik.handleSubmit} | |||||
| textcolor="white" | textcolor="white" | ||||
| disabled={ | disabled={ | ||||
| formik.values.email.length === 0 || formik.values.password.length === 0 | formik.values.email.length === 0 || formik.values.password.length === 0 |
| setSelectedLocations([]); | setSelectedLocations([]); | ||||
| setSelectedSubcategory(); | setSelectedSubcategory(); | ||||
| setSelectedCategory(); | setSelectedCategory(); | ||||
| applyFilters(); | |||||
| }; | }; | ||||
| // Helper function | // Helper function |
| const [emailTakenStatus, setEmailTakenStatus] = useState(false); | const [emailTakenStatus, setEmailTakenStatus] = useState(false); | ||||
| const { t } = useTranslation(); | 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(() => { | useEffect(() => { | ||||
| if (props.error.length > 0) { | if (props.error.length > 0) { | ||||
| setEmailTakenStatus(true); | setEmailTakenStatus(true); | ||||
| handleSubmit: PropTypes.func, | handleSubmit: PropTypes.func, | ||||
| error: PropTypes.string, | error: PropTypes.string, | ||||
| errorMessage: PropTypes.string, | errorMessage: PropTypes.string, | ||||
| informations: PropTypes.any, | |||||
| }; | }; | ||||
| export default FirstPartOfRegistration; | export default FirstPartOfRegistration; |
| }; | }; | ||||
| const handleSubmit = (values) => { | const handleSubmit = (values) => { | ||||
| console.log(values); | |||||
| if (currentStep !== 3) { | if (currentStep !== 3) { | ||||
| setCurrentStep((prevState) => prevState + 1); | setCurrentStep((prevState) => prevState + 1); | ||||
| } else { | } else { | ||||
| const goStepBack = (stepNumber) => { | const goStepBack = (stepNumber) => { | ||||
| setCurrentStep(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 ( | return ( | ||||
| {currentStep === 1 && ( | {currentStep === 1 && ( | ||||
| <FirstPartOfRegistration | <FirstPartOfRegistration | ||||
| handleSubmit={handleSubmit} | handleSubmit={handleSubmit} | ||||
| informations={informations} | |||||
| error={mailError} | error={mailError} | ||||
| errorMessage={mailErrorMessage} | errorMessage={mailErrorMessage} | ||||
| /> | /> | ||||
| {currentStep === 2 && ( | {currentStep === 2 && ( | ||||
| <SecondPartOfRegistration | <SecondPartOfRegistration | ||||
| handleSubmit={handleSubmit} | handleSubmit={handleSubmit} | ||||
| informations={informations} | |||||
| error={PIBError} | error={PIBError} | ||||
| errorMessage={PIBErrorMessage} | errorMessage={PIBErrorMessage} | ||||
| /> | /> | ||||
| )} | )} | ||||
| {currentStep === 3 && ( | {currentStep === 3 && ( | ||||
| <ThirdPartOfRegistration handleSubmit={handleSubmit} /> | |||||
| <ThirdPartOfRegistration handleSubmit={handleSubmit} informations={informations} /> | |||||
| )} | )} | ||||
| {imageError && <ErrorMessage>{t("register.imageError")}</ErrorMessage>} | {imageError && <ErrorMessage>{t("register.imageError")}</ErrorMessage>} |
| } | } | ||||
| }, [props.error]); | }, [props.error]); | ||||
| useEffect(() => { | |||||
| if (props.informations?.nameOfFirm) { | |||||
| formik.setFieldValue("nameOfFirm", props.informations?.nameOfFirm); | |||||
| formik.setFieldValue("PIB", props.informations.PIB) | |||||
| } | |||||
| }, [props.informations]) | |||||
| const formik = useFormik({ | const formik = useFormik({ | ||||
| initialValues: { | initialValues: { | ||||
| nameOfFirm: "", | nameOfFirm: "", | ||||
| SecondPartOfRegistration.propTypes = { | SecondPartOfRegistration.propTypes = { | ||||
| children: PropTypes.node, | children: PropTypes.node, | ||||
| handleSubmit: PropTypes.func, | handleSubmit: PropTypes.func, | ||||
| informations: PropTypes.any, | |||||
| error: PropTypes.string, | error: PropTypes.string, | ||||
| errorMessage: PropTypes.string, | errorMessage: PropTypes.string, | ||||
| }; | }; |
| import React from "react"; | |||||
| import React, { useEffect } from "react"; | |||||
| import PropTypes from "prop-types"; | import PropTypes from "prop-types"; | ||||
| import { | import { | ||||
| FormContainer, | FormContainer, | ||||
| const ThirdPartOfRegistration = (props) => { | const ThirdPartOfRegistration = (props) => { | ||||
| const { t } = useTranslation(); | 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({ | const formik = useFormik({ | ||||
| initialValues: { | initialValues: { | ||||
| phoneNumber: "", | phoneNumber: "", | ||||
| website: "", | website: "", | ||||
| }, | }, | ||||
| validationSchema: Yup.object().shape({ | 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, | validateOnBlur: true, | ||||
| enableReinitialize: true, | enableReinitialize: true, | ||||
| }); | }); | ||||
| ThirdPartOfRegistration.propTypes = { | ThirdPartOfRegistration.propTypes = { | ||||
| children: PropTypes.node, | children: PropTypes.node, | ||||
| handleSubmit: PropTypes.func, | handleSubmit: PropTypes.func, | ||||
| informations: PropTypes.any, | |||||
| }; | }; | ||||
| export default ThirdPartOfRegistration; | export default ThirdPartOfRegistration; |
| const request = axios.create({ | const request = axios.create({ | ||||
| // baseURL: "http://192.168.88.150:3001/", | // 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: { | headers: { | ||||
| "Content-Type": "application/json", | "Content-Type": "application/json", | ||||
| }, | }, |
| // import { setUserAccessToken } from "../actions/user/userActions"; | // import { setUserAccessToken } from "../actions/user/userActions"; | ||||
| //Change URL with .env | //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/"; | // const baseURL = "http://192.168.88.175:3005/"; | ||||
| //Interceptor unique name | //Interceptor unique name |
| function* increaseCounter(payload) { | function* increaseCounter(payload) { | ||||
| try { | try { | ||||
| yield call(console.log, payload.payload); | |||||
| yield call(attemptIncreaseCounter(payload.payload)); | |||||
| yield call(attemptIncreaseCounter, payload.payload); | |||||
| } catch(e) { | } catch(e) { | ||||
| console.log(e); | console.log(e); | ||||
| } | } |
| function* fetchLogin({ payload }) { | function* fetchLogin({ payload }) { | ||||
| try { | try { | ||||
| console.log('barem ide') | |||||
| const { data } = yield call(attemptLogin, payload); | const { data } = yield call(attemptLogin, payload); | ||||
| if (data.token) { | if (data.token) { | ||||
| const token = data.token; | const token = data.token; |
| attemptFetchOffers, | attemptFetchOffers, | ||||
| "?" + newQueryString.toString() | "?" + newQueryString.toString() | ||||
| ); | ); | ||||
| console.log('data::::::::: ', data.data) | |||||
| yield put(setTotalOffers(data.data.total)); | yield put(setTotalOffers(data.data.total)); | ||||
| yield put(setOffers(data.data.items.regularOffers)); | yield put(setOffers(data.data.items.regularOffers)); | ||||
| yield put(setPinnedOffers(data.data.items.pinnedOffers)); | yield put(setPinnedOffers(data.data.items.pinnedOffers)); |