| @@ -1,6 +1,6 @@ | |||
| { | |||
| "name": "web", | |||
| "version": "0.1.0", | |||
| "version": "2.0.4", | |||
| "lockfileVersion": 1, | |||
| "requires": true, | |||
| "dependencies": { | |||
| @@ -2398,6 +2398,16 @@ | |||
| } | |||
| } | |||
| }, | |||
| "@rive-app/canvas": { | |||
| "version": "1.0.83", | |||
| "resolved": "https://registry.npmjs.org/@rive-app/canvas/-/canvas-1.0.83.tgz", | |||
| "integrity": "sha512-IARYWsnh1NPWY2wTYZ15TBg8Bbe9LEPGSHHd8TivmCfagK61WtAPiPjApGUN3Fbk0MUWjmbNwtv9aK3x7QRkog==" | |||
| }, | |||
| "@rive-app/webgl": { | |||
| "version": "1.0.79", | |||
| "resolved": "https://registry.npmjs.org/@rive-app/webgl/-/webgl-1.0.79.tgz", | |||
| "integrity": "sha512-zP8q0D1EOvS0bllhRy3iWwwLxsZ6y7Q01HdZNWo4tNui6EDRC7DRNr40mLSMDKqgF79eZo9vf3lkk8/Wai0fsA==" | |||
| }, | |||
| "@rollup/plugin-node-resolve": { | |||
| "version": "7.1.3", | |||
| "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-7.1.3.tgz", | |||
| @@ -15102,6 +15112,15 @@ | |||
| "inherits": "^2.0.1" | |||
| } | |||
| }, | |||
| "rive-react": { | |||
| "version": "3.0.23", | |||
| "resolved": "https://registry.npmjs.org/rive-react/-/rive-react-3.0.23.tgz", | |||
| "integrity": "sha512-CMJaWgnVEZKLAsu5p1bBkBniCbaTLI+kqBh++y3XdK2aG4MCfYgxYr90rHstn/z4VW8/NP/i/l1NRYxrzgSgsw==", | |||
| "requires": { | |||
| "@rive-app/canvas": "1.0.83", | |||
| "@rive-app/webgl": "1.0.79" | |||
| } | |||
| }, | |||
| "rollup": { | |||
| "version": "1.32.1", | |||
| "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.32.1.tgz", | |||
| @@ -41,6 +41,7 @@ | |||
| "redux-persist": "^6.0.0", | |||
| "redux-persist-transform-filter": "0.0.20", | |||
| "redux-saga": "^1.1.3", | |||
| "rive-react": "^3.0.23", | |||
| "sass": "^1.34.1", | |||
| "socket.io": "^4.5.1", | |||
| "socket.io-client": "^4.5.1", | |||
| @@ -73,33 +73,33 @@ const App = () => { | |||
| setIsConnected(false); | |||
| }); | |||
| socket.on("user disconnected", (userID) => { | |||
| console.log(userID); | |||
| }); | |||
| // socket.on("user disconnected", (userID) => { | |||
| // console.log(userID); | |||
| // }); | |||
| // socket.on('emit', (client) => { | |||
| // console.log(client); | |||
| // }) | |||
| socket.on("sokkk", (clg) => { | |||
| console.log(clg); | |||
| }); | |||
| // socket.onAny((event, ...args) => { | |||
| // console.log(event, args); | |||
| // }); | |||
| socket.on("povratna", (data) => { | |||
| console.log(data); | |||
| }); | |||
| socket.on("private_message", (data) => { | |||
| console.log(data); | |||
| }); | |||
| // // socket.on('emit', (client) => { | |||
| // // console.log(client); | |||
| // // }) | |||
| // socket.on("sokkk", (clg) => { | |||
| // console.log(clg); | |||
| // }); | |||
| // // socket.onAny((event, ...args) => { | |||
| // // console.log(event, args); | |||
| // // }); | |||
| // socket.on("povratna", (data) => { | |||
| // console.log(data); | |||
| // }); | |||
| // socket.on("private_message", (data) => { | |||
| // console.log(data); | |||
| // }); | |||
| // socket.open; | |||
| // // socket.open; | |||
| socket.on("pong", () => { | |||
| setLastPong(new Date().toISOString()); | |||
| }); | |||
| // socket.on("pong", () => { | |||
| // setLastPong(new Date().toISOString()); | |||
| // }); | |||
| // socket.connect(); | |||
| // // socket.connect(); | |||
| return () => { | |||
| socket.off("connect"); | |||
| @@ -7,7 +7,7 @@ const Checkbox = (props) => { | |||
| return ( | |||
| <CheckboxButton | |||
| leftText={item.city} | |||
| rightText={item.offerCount} | |||
| // rightText={item.offerCount} | |||
| value={item} | |||
| checked={ | |||
| props.filters.find( | |||
| @@ -48,7 +48,7 @@ const ImagePicker = (props) => { | |||
| setImage(reader.result); | |||
| }; | |||
| reader.onerror = (error) => { | |||
| console.log(error); | |||
| console.dir(error); | |||
| }; | |||
| }; | |||
| const handleDelete = () => { | |||
| @@ -28,7 +28,7 @@ const PasswordField = forwardRef((props, ref) => { | |||
| // }, [formik.isValid]) | |||
| useEffect(() => { | |||
| console.log(error); | |||
| console.dir(error); | |||
| }, [error]) | |||
| return ( | |||
| @@ -44,7 +44,7 @@ const Register = () => { | |||
| }; | |||
| const handleResponseError = (error) => { | |||
| console.log(error); | |||
| console.dir(error); | |||
| const { mail, password, PIB, image } = informations; | |||
| if (error.type === "mail") { | |||
| setInformations({ image }); | |||
| @@ -5,10 +5,11 @@ import { | |||
| RegisterDescription, | |||
| RegisterTitle, | |||
| } from "./RegisterSuccessful.styled"; | |||
| import { ReactComponent as Success } from "../../../assets/images/svg/register-success.svg"; | |||
| import { useTranslation } from "react-i18next"; | |||
| import { useHistory } from "react-router-dom"; | |||
| import { LOGIN_PAGE } from "../../../constants/pages"; | |||
| import { HOME_PAGE } from "../../../constants/pages"; | |||
| import RegisterRiv from "../../../assets/animations/register.riv"; | |||
| import { useRive } from "rive-react"; | |||
| const RegisterSuccessful = () => { | |||
| const { t } = useTranslation(); | |||
| @@ -17,13 +18,18 @@ const RegisterSuccessful = () => { | |||
| //Redirect to Login page when registration is successful | |||
| useEffect(() => { | |||
| setTimeout(() => { | |||
| history.replace(LOGIN_PAGE); | |||
| }, 2500); | |||
| history.replace(HOME_PAGE); | |||
| }, 1700); | |||
| }, []); | |||
| const { RiveComponent } = useRive({ | |||
| src: RegisterRiv, | |||
| autoplay: true, | |||
| }); | |||
| return ( | |||
| <RegisterSuccessfulContainer> | |||
| <Success /> | |||
| <RiveComponent /> | |||
| <RegisterTitle component="h1" variant="h5"> | |||
| {t("register.success")} | |||
| @@ -8,7 +8,11 @@ export const RegisterSuccessfulContainer = styled(Container)` | |||
| flex-direction: column; | |||
| align-items: center; | |||
| width: 536px; | |||
| height: 200px; | |||
| padding: 0; | |||
| & div canvas { | |||
| height: 300px; | |||
| } | |||
| `; | |||
| export const RegisterTitle = styled(Typography)` | |||
| font-family: "Mulish"; | |||
| @@ -4,7 +4,7 @@ import queryString from "qs"; | |||
| const request = axios.create({ | |||
| // baseURL: "http://192.168.88.150:3001/", | |||
| // baseURL: "http://192.168.88.175:3005/", | |||
| baseURL: "https://trampa-api-test.dilig.net/", | |||
| baseURL: "http://192.168.88.143:3001/", | |||
| headers: { | |||
| "Content-Type": "application/json", | |||
| }, | |||
| @@ -13,7 +13,7 @@ import { logoutUser, refreshUserToken } from "../actions/login/loginActions"; | |||
| // import { setUserAccessToken } from "../actions/user/userActions"; | |||
| //Change URL with .env | |||
| const baseURL = "https://trampa-api-test.dilig.net/"; | |||
| const baseURL = "http://192.168.88.143:3001/"; | |||
| // const baseURL = "http://192.168.88.175:3005/"; | |||
| // const baseURL = "http://192.168.88.175:3005/"; | |||
| @@ -14,7 +14,7 @@ function* fetchCategories() { | |||
| yield put(fetchCategoriesSuccess()); | |||
| } catch (e) { | |||
| yield put(fetchCategoriesError()); | |||
| console.log(e); | |||
| console.dir(e); | |||
| } | |||
| } | |||
| @@ -28,7 +28,7 @@ function* fetchChats() { | |||
| yield put(fetchChatsSuccess()); | |||
| } catch (e) { | |||
| yield put(fetchChatsError()); | |||
| console.log(e); | |||
| console.dir(e); | |||
| } | |||
| } | |||
| @@ -40,7 +40,7 @@ function* fetchHeaderChats() { | |||
| yield put(fetchHeaderChatsSuccess()); | |||
| } catch (e) { | |||
| yield put(fetchHeaderChatsError()); | |||
| console.log(e); | |||
| console.dir(e); | |||
| } | |||
| } | |||
| function* fetchOneChat(payload) { | |||
| @@ -59,7 +59,7 @@ function* fetchOneChat(payload) { | |||
| yield put(fetchOneChatSuccess()); | |||
| } catch (e) { | |||
| yield put(fetchOneChatError()); | |||
| console.log(e); | |||
| console.dir(e); | |||
| } | |||
| } | |||
| @@ -82,7 +82,7 @@ function* sendMessage(payload) { | |||
| } | |||
| } catch (e) { | |||
| yield put(sendMessageError()); | |||
| console.log(e); | |||
| console.dir(e); | |||
| } | |||
| } | |||
| function* startNewChat(payload) { | |||
| @@ -102,7 +102,7 @@ function* startNewChat(payload) { | |||
| } | |||
| } catch (e) { | |||
| yield put(startNewChatError()); | |||
| console.log(e); | |||
| console.dir(e); | |||
| } | |||
| } | |||
| @@ -12,7 +12,7 @@ function* increaseCounter(payload) { | |||
| yield put(increaseCounterSuccess()); | |||
| } catch (e) { | |||
| yield put(increaseCounterError()); | |||
| console.log(e); | |||
| console.dir(e); | |||
| } | |||
| } | |||
| @@ -11,7 +11,7 @@ function* fetchExchange(payload) { | |||
| } | |||
| catch (e) { | |||
| yield put(fetchExchangeError()); | |||
| console.log(e); | |||
| console.dir(e); | |||
| } | |||
| } | |||
| @@ -24,7 +24,7 @@ function* validateExchange(payload) { | |||
| } | |||
| catch(e) { | |||
| yield put(validateExchangeError()); | |||
| console.log(e); | |||
| console.dir(e); | |||
| } | |||
| } | |||
| @@ -14,7 +14,7 @@ function* forgotPassword({payload}) { | |||
| } | |||
| } | |||
| catch(e) { | |||
| console.log(e); | |||
| console.dir(e); | |||
| if (payload.handleResponseError) { | |||
| yield call(payload.handleResponseError); | |||
| } | |||
| @@ -111,7 +111,7 @@ function* logout(payload) { | |||
| yield call(payload.payload) | |||
| } | |||
| } catch (error) { | |||
| console.log(error); // eslint-disable-line | |||
| console.dir(error); // eslint-disable-line | |||
| } finally { | |||
| yield call(authScopeClearHelper); | |||
| yield call(removeHeaderToken); | |||
| @@ -132,7 +132,7 @@ function* refreshUserToken({payload}) { | |||
| return true; | |||
| } | |||
| catch(e){ | |||
| console.log(e); | |||
| console.dir(e); | |||
| return false; | |||
| } | |||
| } | |||
| @@ -183,7 +183,7 @@ function* fetchMoreOffers(payload) { | |||
| yield put(fetchMoreOffersSuccess()); | |||
| } catch (e) { | |||
| yield put(fetchMoreOffersError()); | |||
| console.log(e); | |||
| console.dir(e); | |||
| } | |||
| } | |||
| @@ -196,7 +196,7 @@ function* createOffer(payload) { | |||
| } | |||
| } catch (e) { | |||
| yield put(addOfferError()); | |||
| console.log(e); | |||
| console.dir(e); | |||
| } | |||
| } | |||
| @@ -222,7 +222,7 @@ function* fetchMineOffers() { | |||
| yield put(fetchMineOffersSuccess()); | |||
| } catch (e) { | |||
| yield put(fetchMineOffersError()); | |||
| console.log(e); | |||
| console.dir(e); | |||
| } | |||
| } | |||
| @@ -235,7 +235,7 @@ function* fetchProfileOffers(payload) { | |||
| yield put(setProfileOffers(data.data)); | |||
| yield put(fetchProfileOffersSuccess()); | |||
| } catch (e) { | |||
| console.log(e); | |||
| console.dir(e); | |||
| if (e.response.status === 400) { | |||
| yield call(history.push, NOT_FOUND_PAGE); | |||
| } | |||
| @@ -253,7 +253,7 @@ function* removeOffer(payload) { | |||
| } | |||
| } catch (e) { | |||
| yield put(removeOfferError()); | |||
| console.log(e); | |||
| console.dir(e); | |||
| } | |||
| } | |||
| @@ -268,7 +268,7 @@ function* editOffer(payload) { | |||
| } | |||
| } catch (e) { | |||
| yield put(editOfferError()); | |||
| console.log(e); | |||
| console.dir(e); | |||
| } | |||
| } | |||
| @@ -28,7 +28,7 @@ function* fetchProfile(payload) { | |||
| yield put(fetchProfileSuccess()); | |||
| } catch (e) { | |||
| yield put(fetchErrorProfile()); | |||
| console.log(e); | |||
| console.dir(e); | |||
| } | |||
| } | |||
| @@ -40,7 +40,7 @@ function* fetchMineProfile() { | |||
| yield put(fetchMineProfileSuccess()); | |||
| } catch (e) { | |||
| yield put(fetcHMineProfileError()); | |||
| console.log(e); | |||
| console.dir(e); | |||
| } | |||
| } | |||
| @@ -86,7 +86,7 @@ function* changeMineProfile(payload) { | |||
| console.log(data); | |||
| } catch (e) { | |||
| yield put(editMineProfileError()); | |||
| console.log(e); | |||
| console.dir(e); | |||
| } | |||
| } | |||
| @@ -19,7 +19,7 @@ function* setQueryString(payload) { | |||
| const newQueryString = convertQueryStringForBackend(payload.payload); | |||
| yield put(setQueryStringRedux(newQueryString)); | |||
| } catch (e) { | |||
| console.log(e); | |||
| console.dir(e); | |||
| } | |||
| } | |||
| @@ -1,10 +1,23 @@ | |||
| import { all, takeLatest, call, put } from "@redux-saga/core/effects"; | |||
| import { JWT_REFRESH_TOKEN, JWT_TOKEN } from "../../constants/localStorage"; | |||
| import { addHeaderToken } from "../../request"; | |||
| import { attemptLogin } from "../../request/loginRequest"; | |||
| import { attemptFetchProfile } from "../../request/profileRequest"; | |||
| import { attemptRegister } from "../../request/registerRequest"; | |||
| import { authScopeSetHelper } from "../../util/helpers/authScopeHelpers"; | |||
| import { | |||
| fetchUserError, | |||
| fetchUserSuccess, | |||
| } from "../actions/login/loginActions"; | |||
| import { setMineProfile } from "../actions/profile/profileActions"; | |||
| import { REGISTER_USER_FETCH } from "../actions/register/registerActionConstants"; | |||
| import jwt from "jsonwebtoken"; | |||
| import { | |||
| fetchRegisterUserError, | |||
| fetchRegisterUserSuccess, | |||
| } from "../actions/register/registerActions"; | |||
| import { rejectErrorCodeHelper } from "../../util/helpers/rejectErrorCodeHelper"; | |||
| import i18next from "i18next"; | |||
| function* fetchRegisterUser({ payload }) { | |||
| try { | |||
| @@ -32,12 +45,44 @@ function* fetchRegisterUser({ payload }) { | |||
| if (payload.values.website?.length === 0) | |||
| delete requestData.company.contacts.web; | |||
| yield call(attemptRegister, requestData); | |||
| const { data } = yield call(attemptLogin, { | |||
| email: payload.values.mail, | |||
| password: payload.values.password, | |||
| }); | |||
| if (data.token) { | |||
| const token = data.token; | |||
| const refresh = data.refresh; | |||
| const tokenDecoded = jwt.decode(token); | |||
| const refreshDecoded = jwt.decode(refresh); | |||
| const accessToken = { | |||
| token: token, | |||
| exp: tokenDecoded.exp, | |||
| }; | |||
| const refreshToken = { | |||
| token: refresh, | |||
| exp: refreshDecoded.exp, | |||
| }; | |||
| const userId = tokenDecoded._id; | |||
| yield call(authScopeSetHelper, JWT_TOKEN, token); | |||
| yield call(authScopeSetHelper, JWT_REFRESH_TOKEN, refresh); | |||
| yield call(addHeaderToken, token); | |||
| const profileData = yield call(attemptFetchProfile, userId); | |||
| if (profileData) yield put(setMineProfile(profileData.data)); | |||
| yield put( | |||
| fetchUserSuccess({ | |||
| JwtToken: accessToken, | |||
| RefreshToken: refreshToken, | |||
| userId, | |||
| }) | |||
| ); | |||
| } | |||
| if (payload.handleResponseSuccess) { | |||
| yield call(payload.handleResponseSuccess); | |||
| } | |||
| yield put(fetchRegisterUserSuccess()); | |||
| } catch (e) { | |||
| console.log(e); | |||
| console.dir(e); | |||
| let type = "server"; | |||
| if ( | |||
| e?.response?.data?.toString() === "User with email already exists!" || | |||
| @@ -56,6 +101,16 @@ function* fetchRegisterUser({ payload }) { | |||
| if (payload.handleResponseError) { | |||
| yield call(payload.handleResponseError, error); | |||
| } | |||
| if (e.response && e.response.data) { | |||
| console.log(e.response.status); | |||
| let errorMessage = yield call(rejectErrorCodeHelper, e.response.status); | |||
| if (e.response.status === 400 || e.response.status === 404) { | |||
| errorMessage = i18next.t("login.wrongCredentials", { | |||
| lng: "rs", | |||
| }); | |||
| } | |||
| yield put(fetchUserError(errorMessage)); | |||
| } | |||
| yield put(fetchRegisterUserError()); | |||
| } | |||
| } | |||
| @@ -22,7 +22,7 @@ function* fetchReviews(payload) { | |||
| yield put(fetchReviewsSuccess()); | |||
| } catch (e) { | |||
| yield put(fetchReviewsError()); | |||
| console.log(e); | |||
| console.dir(e); | |||
| } | |||
| } | |||
| @@ -35,7 +35,7 @@ function* giveReview(payload) { | |||
| yield put(giveReviewSuccess()); | |||
| } catch (e) { | |||
| yield put(giveReviewError()); | |||
| console.log(e); | |||
| console.dir(e); | |||
| } | |||
| } | |||