浏览代码

Fixed bug

bugfix/1919
Djordje Mitrovic 3 年前
父节点
当前提交
63b4d91249

+ 1
- 1
.env.example 查看文件



REACT_APP_BASE_API_URL=${REACT_APP_BASE_API_URL}
REACT_APP_BASE_API_URL=https://trampa-api-test.dilig.net/

+ 1
- 1
package.json 查看文件

{ {
"name": "web", "name": "web",
"version": "4.0.10",
"version": "4.0.12",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@emotion/react": "^11.5.0", "@emotion/react": "^11.5.0",

+ 5
- 7
src/components/Header/Header.js 查看文件



useEffect(() => { useEffect(() => {
if (logoClicked) { if (logoClicked) {
console.log("clicked");
if (isAdminRoute()) { if (isAdminRoute()) {
history.push({ history.push({
pathname: ADMIN_HOME_PAGE, pathname: ADMIN_HOME_PAGE,
}, },
}); });
} else { } else {
console.log("odje");
history.push({ history.push({
pathname: MARKETPLACE_PAGE, pathname: MARKETPLACE_PAGE,
state: { state: {
// When user clicks logo, he sends specific state so filters can be removed // When user clicks logo, he sends specific state so filters can be removed
const handleLogoClick = () => { const handleLogoClick = () => {
if ( if (
!(
routeMatches(HOME_PAGE) ||
routeMatches(BASE_PAGE) ||
routeMatches(MARKETPLACE_PAGE)
)
((routeMatches(HOME_PAGE) || routeMatches(BASE_PAGE)) && user) ||
routeMatches(MARKETPLACE_PAGE)
) { ) {
dispatch(clearFilters()); dispatch(clearFilters());
setLogoClicked(true);
} }
setLogoClicked(true);
}; };


const handleAddOfferClick = () => { const handleAddOfferClick = () => {
if (!shouldShow) { if (!shouldShow) {
return <></>; return <></>;
} }
console.log(history);


return ( return (
<HeaderContainer> <HeaderContainer>

+ 0
- 1
src/components/TextFields/TextField/TextField.js 查看文件

setIsFieldEmpty(false); setIsFieldEmpty(false);
} }
}, [props.value]); }, [props.value]);
console.log(props);
return ( return (
<TextFieldContainer <TextFieldContainer
style={props.containerStyle} style={props.containerStyle}

+ 3
- 2
src/i18n/resources/rs.js 查看文件

locationError: "Odaberite ispravnu lokaciju!", locationError: "Odaberite ispravnu lokaciju!",
websiteError: "Unesite ispravnu adresu svog website!", websiteError: "Unesite ispravnu adresu svog website!",
websiteRequired: "Website je obavezan!", websiteRequired: "Website je obavezan!",
companyNameError: "Naziv kompanije je zauzet!",
}, },
forgotPassword: { forgotPassword: {
title: "Povrati lozinku", title: "Povrati lozinku",
gray: "Siva", gray: "Siva",
yellow: "Žuta", yellow: "Žuta",
purple: "Ljubičasta", purple: "Ljubičasta",
pink: "Roze"
}
pink: "Roze",
},
}; };

+ 19
- 6
src/pages/RegisterPages/Register/Register.js 查看文件

const [mailErrorMessage, setMailErrorMessage] = useState(""); // Error message caused by typing wrong mail const [mailErrorMessage, setMailErrorMessage] = useState(""); // Error message caused by typing wrong mail
const [PIBError, setPIBError] = useState(""); // Wrong PIB typed const [PIBError, setPIBError] = useState(""); // Wrong PIB typed
const [PIBErrorMessage, setPIBErrorMessage] = useState(""); // Error message caused by typing wrong PIB const [PIBErrorMessage, setPIBErrorMessage] = useState(""); // Error message caused by typing wrong PIB
const [companyNameError, setCompanyNameError] = useState("");
const [imageError, setImageError] = useState(false); // Not picked image const [imageError, setImageError] = useState(false); // Not picked image
const isLoadingRegister = useSelector(selectIsLoadingByActionType(REGISTER_USER_SCOPE));
const isLoadingRegister = useSelector(
selectIsLoadingByActionType(REGISTER_USER_SCOPE)
);


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


const handleResponseError = (error) => { const handleResponseError = (error) => {
console.dir(error); console.dir(error);
const { mail, password, PIB, image } = informations;
console.log("informations", informations);
const { mail, registerPassword, PIB, image } = informations;
if (error.type === "mail") { if (error.type === "mail") {
setInformations({ image }); setInformations({ image });
setCurrentStep(1); setCurrentStep(1);
error?.error?.response?.data?.toString() === error?.error?.response?.data?.toString() ===
"User with PIB already exists!" "User with PIB already exists!"
) { ) {
setInformations({ mail, password, image });
setInformations({ mail, registerPassword, image });
setCurrentStep(2); setCurrentStep(2);
setPIBError(PIB.toString()); setPIBError(PIB.toString());
setPIBErrorMessage(t("register.PIBTaken")); setPIBErrorMessage(t("register.PIBTaken"));
} else {
makeErrorToastMessage(t("register.serverError"));
}
} else if (
error?.error?.response?.data?.toString() ===
"Company with that name already exists!"
) {
setInformations({ mail, registerPassword, image });
setCurrentStep(2);
setCompanyNameError(t("register.companyNameError"));
} else makeErrorToastMessage(t("register.serverError"));
}; };


const registerUser = (values) => { const registerUser = (values) => {
setCompanyNameError("");
setPIBErrorMessage("");
setMailErrorMessage("");
dispatch( dispatch(
fetchRegisterUser({ values, handleResponseSuccess, handleResponseError }) fetchRegisterUser({ values, handleResponseSuccess, handleResponseError })
); );
informations={informations} informations={informations}
error={PIBError} error={PIBError}
errorMessage={PIBErrorMessage} errorMessage={PIBErrorMessage}
companyNameError={companyNameError}
/> />
)} )}
{currentStep === 3 && ( {currentStep === 3 && (

+ 13
- 5
src/pages/RegisterPages/Register/SecondPart/SecondPartOfRegistration.js 查看文件

useEffect(() => { useEffect(() => {
if (props.informations?.nameOfFirm) { if (props.informations?.nameOfFirm) {
formik.setFieldValue("nameOfFirm", props.informations?.nameOfFirm); formik.setFieldValue("nameOfFirm", props.informations?.nameOfFirm);
formik.setFieldValue("PIB", props.informations.PIB)
formik.setFieldValue("PIB", props.informations.PIB);
} }
}, [props.informations])
}, [props.informations]);


const formik = useFormik({ const formik = useFormik({
initialValues: { initialValues: {
margin="normal" margin="normal"
value={formik.values.nameOfFirm} value={formik.values.nameOfFirm}
onChange={formik.handleChange} onChange={formik.handleChange}
error={formik.touched.nameOfFirm && Boolean(formik.errors.nameOfFirm)}
error={
(formik.touched.nameOfFirm && Boolean(formik.errors.nameOfFirm)) ||
props?.companyNameError
}
helperText={formik.touched.nameOfFirm && formik.errors.nameOfFirm} helperText={formik.touched.nameOfFirm && formik.errors.nameOfFirm}
autoFocus autoFocus
fullWidth fullWidth
type="number" type="number"
value={formik.values.PIB} value={formik.values.PIB}
onChange={(event) => { onChange={(event) => {
formik.setFieldValue("PIB", event.target.value)
formik.setFieldValue("PIB", event.target.value);
}} }}
error={ error={
(formik.touched.PIB && Boolean(formik.errors.PIB)) || PIBTakenStatus (formik.touched.PIB && Boolean(formik.errors.PIB)) || PIBTakenStatus
{formik.errors.PIB && formik.touched.PIB && ( {formik.errors.PIB && formik.touched.PIB && (
<ErrorMessage>{formik.errors.PIB}</ErrorMessage> <ErrorMessage>{formik.errors.PIB}</ErrorMessage>
)} )}
{props.error && <ErrorMessage>{props.errorMessage}</ErrorMessage>}
{(props.error || props?.companyNameError) && (
<ErrorMessage>
{props.errorMessage || props?.companyNameError}
</ErrorMessage>
)}


<PrimaryButton <PrimaryButton
type="submit" type="submit"
informations: PropTypes.any, informations: PropTypes.any,
error: PropTypes.string, error: PropTypes.string,
errorMessage: PropTypes.string, errorMessage: PropTypes.string,
companyNameError: PropTypes.string,
}; };


export default SecondPartOfRegistration; export default SecondPartOfRegistration;

正在加载...
取消
保存