Browse Source

Changed port to 3005

pull/2/head
Djordje Mitrovic 3 years ago
parent
commit
cbfc375386

+ 2
- 2
src/components/Cards/OfferCard/OfferCard.js View File

@@ -29,7 +29,7 @@ import selectedTheme from "../../../themes";

const OfferCard = (props) => {
return (
<OfferCardContainer sponsored={props.sponsored ? 1 : 0} halfwidth={props.halfwidth ? 1 : 0}>
<OfferCardContainer sponsored={props.sponsored.toString()} halfwidth={props.halfwidth ? 1 : 0}>
<OfferImage>{props.image}</OfferImage>
<OfferInfo>
<OfferTitle>{props.title}</OfferTitle>
@@ -113,7 +113,7 @@ OfferCard.propTypes = {
};
OfferCard.defaultProps = {
halfwidth: false,
sponsored: true,
sponsored: false,
};

export default OfferCard;

+ 2
- 2
src/components/Cards/OfferCard/OfferCard.styled.js View File

@@ -12,10 +12,10 @@ export const OfferCardContainer = styled(Container)`
box-sizing: border-box;
margin: 10px 0;
background-color: ${(props) =>
props.sponsored ? selectedTheme.backgroundSponsoredColor : "white"};
props.sponsored === 'true' ? selectedTheme.backgroundSponsoredColor : "white"};
border-radius: 4px;
${(props) =>
props.sponsored &&
props.sponsored === 'true' &&
`border: 1px solid ${selectedTheme.borderSponsoredColor};`}
padding: 16px;
max-width: 2000px;

+ 2
- 0
src/components/TextFields/TextField/TextField.js View File

@@ -25,6 +25,7 @@ export const TextField = (props) => {
placeholder={props.placeholder}
width={props.width}
height={props.height}
id={props.id}
name={props.name}
value={props.value}
onChange={props.onChange}
@@ -72,6 +73,7 @@ TextField.propTypes = {
label: PropTypes.string,
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
onChange: PropTypes.func,
id: PropTypes.number,
error: PropTypes.bool,
helperText: PropTypes.string,
autoFocus: PropTypes.bool,

+ 6
- 8
src/pages/RegisterPages/Register/FirstPart/FirstPartOfRegistration.js View File

@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useEffect, useState } from "react";
import PropTypes from "prop-types";
import {
FormContainer,
@@ -19,14 +19,11 @@ const FirstPartOfRegistration = (props) => {
const [emailTakenStatus, setEmailTakenStatus] = useState(false);
const { t } = useTranslation();

const handleForm = (values) => {
// validate email
if (true) { // eslint-disable-line
props.handleSubmit(values)
} else {
useEffect(() => {
if (props.mailError?.length > 0) {
setEmailTakenStatus(true);
}
}
}, [props.mailError]);

const formik = useFormik({
initialValues: {
@@ -37,7 +34,7 @@ const FirstPartOfRegistration = (props) => {
mail: Yup.string().email().required(t("login.usernameRequired")),
password: Yup.string().required(t("login.passwordRequired")).min(8),
}),
onSubmit: handleForm,
onSubmit: props.handleSubmit,
validateOnBlur: true,
enableReinitialize: true,
});
@@ -113,6 +110,7 @@ const FirstPartOfRegistration = (props) => {
FirstPartOfRegistration.propTypes = {
children: PropTypes.node,
handleSubmit: PropTypes.func,
mailError: PropTypes.string,
};

export default FirstPartOfRegistration;

+ 39
- 8
src/pages/RegisterPages/Register/Register.js View File

@@ -11,11 +11,11 @@ import {
RegisterTitle,
} from "./Register.styled";
import { ReactComponent as Logo } from "../../../assets/images/svg/logo-vertical.svg";
import { NavLink } from "react-router-dom";
import { NavLink, useHistory } from "react-router-dom";
import { Trans, useTranslation } from "react-i18next";
import Link from "../../../components/Link/Link";
import StepProgress from "../../../components/StepProgress/StepProgress";
// import { REGISTER_SUCCESSFUL_PAGE } from "../../../constants/pages";
import { REGISTER_SUCCESSFUL_PAGE } from "../../../constants/pages";
import FirstPartOfRegistration from "./FirstPart/FirstPartOfRegistration";
import SecondPartOfRegistration from "./SecondPart/SecondPartOfRegistration";
import ThirdPartOfRegistration from "./ThirdPart/ThirdPartOfRegistration";
@@ -24,20 +24,45 @@ import { fetchRegisterUser } from "../../../store/actions/register/registerActio

const Register = () => {
const { t } = useTranslation();
// const history = useHistory();
const history = useHistory();
const dispatch = useDispatch();
const [currentStep, setCurrentStep] = useState(1);
const [informations, setInformations] = useState({});
const [mailError, setMailError] = useState("");
const [PIBError, setPIBError] = useState("");

const handleResponseSuccess = () => {
history.push(REGISTER_SUCCESSFUL_PAGE);
};

const handleResponseError = (error) => {
console.log(error);
if (error.type === "email") {
const { mail } = informations;
setInformations({});
setCurrentStep(1);
setMailError(mail);
} else {
const { mail, password, PIB } = informations;
setInformations({ mail, password });
setCurrentStep(2);
setPIBError(PIB);
}
};

const registerUser = (values) => {
dispatch(fetchRegisterUser(values));
}
dispatch(
fetchRegisterUser(values),
handleResponseSuccess,
handleResponseError
);
};

const handleSubmit = (values) => {
if (currentStep !== 3) {
setCurrentStep((prevState) => prevState + 1);
} else {
registerUser({...informations, ...values});
registerUser({ ...informations, ...values });
}
setInformations({ ...informations, ...values });
};
@@ -58,10 +83,16 @@ const Register = () => {
</ProgressContainer>

{currentStep === 1 && (
<FirstPartOfRegistration handleSubmit={handleSubmit} />
<FirstPartOfRegistration
handleSubmit={handleSubmit}
error={mailError}
/>
)}
{currentStep === 2 && (
<SecondPartOfRegistration handleSubmit={handleSubmit} />
<SecondPartOfRegistration
handleSubmit={handleSubmit}
error={PIBError}
/>
)}
{currentStep === 3 && (
<ThirdPartOfRegistration handleSubmit={handleSubmit} />

+ 1
- 1
src/request/apiEndpoints.js View File

@@ -1,7 +1,7 @@
export default {
accounts: {
get: 'accounts/{accountUid}',
forgotPassword: 'forgotPassword',
forgotPassword: 'forgot-password',
resetPassword: 'resetPassword',
getCurrentUserPermissions:
'accounts/{currentAccountUid}/users/{currentUserUid}/permissions',

+ 1
- 1
src/request/index.js View File

@@ -2,7 +2,7 @@ import axios from 'axios';
import queryString from 'qs';

const request = axios.create({
baseURL: "http://192.168.88.175:3001/",
baseURL: "http://192.168.88.175:3005/",
headers: {
'Content-Type': 'application/json',
},

+ 12
- 2
src/store/saga/registerSaga.js View File

@@ -5,9 +5,13 @@ import { REGISTER_USER_FETCH } from "../actions/register/registerActionConstants
function* fetchRegisterUser({payload}) {
try {
const requestData = {
name: "Djordje Mitrovic",
email: payload.mail.toString(),
password: payload.password.toString(),
roles: [
{
role: "User"
}
],
company: {
name: payload.nameOfFirm.toString(),
PIB: payload.PIB.toString(),
@@ -22,8 +26,14 @@ function* fetchRegisterUser({payload}) {
console.log(requestData);
const data = yield call(attemptRegister, requestData);
console.log(data);
if (payload.handleResponseSuccess) {
yield call(payload.handleResponseSuccess);
}
} catch (e) {
console.log(e);
console.log(e.response);
if (payload.handleResponseError) {
yield call(payload.handleResponseError);
}
}
}


Loading…
Cancel
Save