jovan.cirkovic 3 лет назад
Родитель
Сommit
0a838fb6bd

+ 13
- 28
src/components/Cards/CreateOfferCard/CreateOffer.js Просмотреть файл

@@ -1,8 +1,6 @@
import React, { useState } from "react";
import PropTypes from "prop-types";
import { useDispatch, useSelector } from "react-redux";
import { useHistory } from "react-router-dom";
import { HOME_PAGE } from "../../../constants/pages";
import {
CreateOfferContainer,
CreateOfferTitle,
@@ -17,6 +15,7 @@ import SecondPartCreateOffer from "./SecondPart/SecondPartCreateOffer";
import ThirdPartCreateOffer from "./ThirdPart/ThirdPartCreateOffer";
import {
addOffer,
fetchOffers,
fetchProfileOffers,
} from "../../../store/actions/offers/offersActions";
import { editOneOffer } from "../../../store/actions/offers/offersActions";
@@ -25,32 +24,19 @@ import { ReactComponent as ArrowBack } from "../../../assets/images/svg/arrow-ba
import { useTranslation } from "react-i18next";
import BackdropComponent from "../../MUI/BackdropComponent";
import CloseButton from "./CloseButton/CloseButton";
import { selectUserId } from "../../../store/selectors/loginSelectors";

const CreateOffer = ({ history, closeCreateOfferModal, editOffer, offer }) => {
const CreateOffer = ({ closeCreateOfferModal, editOffer, offer }) => {
const dispatch = useDispatch();
const [informations, setInformations] = useState({});
const [currentStep, setCurrentStep] = useState(1);
const categories = useSelector((state) => state.categories.categories);
const historyRouter = useHistory();
// const categories = useSelector((state) => state.categories.categories);
const { t } = useTranslation();
const userId = useSelector(selectUserId);

const handleApiResponseSuccess = () => {
if (editOffer === undefined) {
const userId = historyRouter.location.pathname.slice(
9,
historyRouter.location.pathname.length
);
dispatch(fetchProfileOffers(userId));
historyRouter.push({
pathname: HOME_PAGE,
state: {
from: history.location.pathname,
},
});
} else {
const userId = offer.userId;
dispatch(fetchProfileOffers(userId));
}
dispatch(fetchOffers({ queryString: "" }));
dispatch(fetchProfileOffers(userId));
};

const handleNext = (values) => {
@@ -69,12 +55,12 @@ const CreateOffer = ({ history, closeCreateOfferModal, editOffer, offer }) => {
.replace("data:image/png;base64,", "")
);

let subcategories = [];
for (const element of categories) {
if (element.name === informations.category) {
subcategories = element.subcategories.map((item) => item.name);
}
}
// let subcategories = [];
// for (const element of categories) {
// if (element.name === informations.category) {
// subcategories = element.subcategories.map((item) => item.name);
// }
// }

const offerData = {
name: informations.nameOfProduct,
@@ -85,7 +71,6 @@ const CreateOffer = ({ history, closeCreateOfferModal, editOffer, offer }) => {
condition: informations.condition,
category: {
name: informations.category,
subcategories: subcategories,
},
subcategory: informations.subcategory,
images: newImgs,

+ 1
- 1
src/components/Popovers/MyMessages/MyMessages.js Просмотреть файл

@@ -41,7 +41,7 @@ export const MyMessages = () => {
}
}, [chats]);
const goToMessages = () => {
history.push(`messages/${chats[0].chat?._id}`);
history.push(`/messages/${chats[0].chat?._id}`);
};
return (
<HeaderPopover

+ 3
- 4
src/components/ProfileCard/EditProfile/EditProfile.js Просмотреть файл

@@ -25,9 +25,9 @@ import {
editMineProfile,
fetchMineProfile,
} from "../../../store/actions/profile/profileActions";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import { selectUserId } from "../../../store/selectors/loginSelectors";
import useScreenDimensions from "../../../hooks/useScreenDimensions";
import { useRouteMatch } from "react-router-dom";
import editProfileValidation from "../../../validations/editProfileValidation";

const EditProfile = (props) => {
@@ -37,8 +37,7 @@ const EditProfile = (props) => {
const { t } = useTranslation();
const dispatch = useDispatch();
const dimensions = useScreenDimensions();
const routeMatch = useRouteMatch();
const userId = routeMatch.params.idProfile;
const userId = useSelector(selectUserId);

useEffect(() => {
if (dimensions.width < 600) {

Загрузка…
Отмена
Сохранить