Selaa lähdekoodia

Finished isFetching indicator

feature/587
Djordje Mitrovic 3 vuotta sitten
vanhempi
commit
6ff3ebd103
56 muutettua tiedostoa jossa 500 lisäystä ja 620 poistoa
  1. 2
    1
      src/components/Cards/FilterCard/FilterCard.js
  2. 1
    0
      src/components/Cards/FilterCard/FilterCard.styled.js
  3. 2
    2
      src/components/Cards/FilterCard/FilterFooter/FilterFooter.js
  4. 3
    3
      src/components/Cards/FilterCard/FilterHeader/FilterHeader.js
  5. 4
    52
      src/components/Cards/FilterCard/Skeleton/SkeletonChooserHeader/SkeletonChooserHeader.styled.js
  6. 4
    36
      src/components/Cards/FilterCard/Skeleton/SkeletonChooserTitle/SkeletonChooserTitle.styled.js
  7. 5
    52
      src/components/Cards/FilterCard/Skeleton/SkeletonFilterCard.styled.js
  8. 4
    52
      src/components/Cards/FilterCard/Skeleton/SkeletonSection/SkeletonSectionOption/SkeletonSectionOption.styled.js
  9. 2
    1
      src/components/Cards/OfferCard/SkeletonOfferCard/SkeletonOfferCard.styled.js
  10. 2
    1
      src/components/MarketPlace/Header/Header.js
  11. 5
    4
      src/components/MarketPlace/Header/SkeletonHeader/SkeletonHeader.js
  12. 4
    3
      src/components/MarketPlace/Header/SkeletonHeader/SkeletonHeader.styled.js
  13. 13
    7
      src/hooks/useFilters.js
  14. 3
    2
      src/store/actions/categories/categoriesActionConstants.js
  15. 4
    1
      src/store/actions/categories/categoriesActions.js
  16. 9
    4
      src/store/actions/chat/chatActionConstants.js
  17. 16
    1
      src/store/actions/chat/chatActions.js
  18. 8
    2
      src/store/actions/counter/counterActionConstants.js
  19. 7
    1
      src/store/actions/counter/counterActions.js
  20. 17
    4
      src/store/actions/exchange/exchangeActionConstants.js
  21. 13
    1
      src/store/actions/exchange/exchangeActions.js
  22. 6
    6
      src/store/actions/filters/filtersActionConstants.js
  23. 3
    2
      src/store/actions/locations/locationsActionConstants.js
  24. 4
    1
      src/store/actions/locations/locationsActions.js
  25. 6
    5
      src/store/actions/login/loginActionConstants.js
  26. 26
    16
      src/store/actions/offers/offersActionConstants.js
  27. 88
    43
      src/store/actions/offers/offersActions.js
  28. 0
    5
      src/store/actions/products/productsActionConstants.js
  29. 0
    32
      src/store/actions/products/productsActions.js
  30. 9
    6
      src/store/actions/profile/profileActionConstants.js
  31. 28
    18
      src/store/actions/profile/profileActions.js
  32. 4
    2
      src/store/actions/queryString/queryStringActionConstants.js
  33. 0
    5
      src/store/actions/randomData/randomDataActionConstants.js
  34. 0
    32
      src/store/actions/randomData/randomDataActions.js
  35. 9
    2
      src/store/actions/register/registerActionConstants.js
  36. 7
    1
      src/store/actions/register/registerActions.js
  37. 8
    4
      src/store/actions/review/reviewActionConstants.js
  38. 13
    1
      src/store/actions/review/reviewActions.js
  39. 16
    6
      src/store/actions/user/userActionConstants.js
  40. 33
    15
      src/store/actions/user/userActions.js
  41. 0
    18
      src/store/reducers/index.js
  42. 1
    1
      src/store/reducers/loading/loadingReducer.js
  43. 0
    0
      src/store/reducers/products/productsReducer.js
  44. 0
    103
      src/store/reducers/randomData/randomDataReducer.js
  45. 3
    2
      src/store/saga/categoriesSaga.js
  46. 6
    5
      src/store/saga/chatSaga.js
  47. 4
    1
      src/store/saga/counterSaga.js
  48. 5
    1
      src/store/saga/exchangeSaga.js
  49. 4
    2
      src/store/saga/forgotPasswordSaga.js
  50. 12
    6
      src/store/saga/locationsSaga.js
  51. 1
    4
      src/store/saga/loginSaga.js
  52. 23
    9
      src/store/saga/offersSaga.js
  53. 8
    8
      src/store/saga/profileSaga.js
  54. 1
    3
      src/store/saga/queryStringSaga.js
  55. 7
    0
      src/store/saga/registerSaga.js
  56. 37
    25
      src/store/saga/reviewSaga.js

+ 2
- 1
src/components/Cards/FilterCard/FilterCard.js Näytä tiedosto

@@ -24,7 +24,7 @@ const FilterCard = (props) => {
{/* Header title for my offers */}
{props.myOffers && <HeaderBack />}

<FilterHeader />
<FilterHeader filters={filters} />

<ContentContainer>
{/* Categories */}
@@ -40,6 +40,7 @@ const FilterCard = (props) => {
<FilterFooter
closeResponsive={props.closeResponsive}
responsiveOpen={props.responsiveOpen}
filters={filters}
/>
</FilterCardContainer>
);

+ 1
- 0
src/components/Cards/FilterCard/FilterCard.styled.js Näytä tiedosto

@@ -24,6 +24,7 @@ export const FilterCardContainer = styled(Box)`
z-index: 9;
margin-top: -24px;
transition: all ease-in-out 1s;
transition: padding 0s;

& header {
position: absolute;

+ 2
- 2
src/components/Cards/FilterCard/FilterFooter/FilterFooter.js Näytä tiedosto

@@ -4,11 +4,10 @@ import { FilterFooterContainer } from "./FilterFooter.styled";
import selectedTheme from "../../../../themes";
import { PrimaryButton } from "../../../Buttons/PrimaryButton/PrimaryButton";
import { useTranslation } from "react-i18next";
import useFilters from "../../../../hooks/useFilters";

const FilterFooter = (props) => {
const { t } = useTranslation();
const filters = useFilters();
const filters = props.filters;
const handleFilters = () => {
filters.applyFilters();
if (props.closeResponsive) props.closeResponsive();
@@ -53,6 +52,7 @@ const FilterFooter = (props) => {
(FilterFooter.propTypes = {
responsiveOpen: PropTypes.bool,
closeResponsive: PropTypes.func,
filters: PropTypes.any,
}),
(FilterFooter.defaultProps = {
responsiveOpen: false,

+ 3
- 3
src/components/Cards/FilterCard/FilterHeader/FilterHeader.js Näytä tiedosto

@@ -2,11 +2,10 @@ import React from "react";
import PropTypes from "prop-types";
import { FilterHeaderContainer, Title } from "./FilterHeader.styled";
import { useTranslation } from "react-i18next";
import useFilters from "../../../../hooks/useFilters";
import Link from "../../../Link/Link";

const FilterHeader = () => {
const filters = useFilters();
const FilterHeader = (props) => {
const filters = props.filters;
const { t } = useTranslation();
const clearFilters = () => {
filters.clearFilters();
@@ -23,6 +22,7 @@ const FilterHeader = () => {

FilterHeader.propTypes = {
children: PropTypes.node,
filters: PropTypes.any,
};

export default FilterHeader;

+ 4
- 52
src/components/Cards/FilterCard/Skeleton/SkeletonChooserHeader/SkeletonChooserHeader.styled.js Näytä tiedosto

@@ -1,6 +1,6 @@
import { Box } from "@mui/material";
import styled from "styled-components";
import selectedTheme from "../../../../../themes";
import { ItemsTransition } from "../../../OfferCard/SkeletonOfferCard/SkeletonOfferCard.styled";

export const SkeletonChooserContainer = styled(Box)`
display: flex;
@@ -10,69 +10,21 @@ export const SkeletonChooserContainer = styled(Box)`
margin-bottom: 3px;
`;

export const CircleOne = styled(Box)`
export const CircleOne = styled(ItemsTransition)`
width: 24px;
height: 24px;
transition: ${(props) => (props.animationStage === 3 ? "0.9s" : "0")};
background: linear-gradient(
to left,
${selectedTheme.filterSkeletonItems} 20%,
${selectedTheme.filterSkeletonItems},
${selectedTheme.filterSkeletonItemsSecond},
${selectedTheme.filterSkeletonItemsSecond} 40%,
${selectedTheme.filterSkeletonItemsSecond} 60%,
${selectedTheme.filterSkeletonItemsSecond},
${selectedTheme.filterSkeletonItems},
${selectedTheme.filterSkeletonItems} 80%
)
right;
background-size: 500% 100%;
background-position: ${(props) =>
props.animationStage !== 2 ? "left" : "right"};
border-radius: 100% !important;
position: relative;
bottom: 3px;
`;
export const Line = styled(Box)`
export const Line = styled(ItemsTransition)`
width: 117px;
height: 18px;
transition: ${(props) => (props.animationStage === 3 ? "0.9s" : "0")};
background: linear-gradient(
to left,
${selectedTheme.filterSkeletonItems} 20%,
${selectedTheme.filterSkeletonItems},
${selectedTheme.filterSkeletonItemsSecond},
${selectedTheme.filterSkeletonItemsSecond} 40%,
${selectedTheme.filterSkeletonItemsSecond} 60%,
${selectedTheme.filterSkeletonItemsSecond},
${selectedTheme.filterSkeletonItems},
${selectedTheme.filterSkeletonItems} 80%
)
right;
background-size: 500% 100%;
background-position: ${(props) =>
props.animationStage !== 2 ? "left" : "right"};
`;
export const CircleSecond = styled(Box)`
export const CircleSecond = styled(ItemsTransition)`
width: 18px;
height: 18px;
border-radius: 100% !important;
transition: ${(props) => (props.animationStage === 3 ? "0.9s" : "0")};
background: linear-gradient(
to left,
${selectedTheme.filterSkeletonItems} 20%,
${selectedTheme.filterSkeletonItems},
${selectedTheme.filterSkeletonItemsSecond},
${selectedTheme.filterSkeletonItemsSecond} 40%,
${selectedTheme.filterSkeletonItemsSecond} 60%,
${selectedTheme.filterSkeletonItemsSecond},
${selectedTheme.filterSkeletonItems},
${selectedTheme.filterSkeletonItems} 80%
)
right;
background-size: 500% 100%;
background-position: ${(props) =>
props.animationStage !== 2 ? "left" : "right"};
`;
export const LeftContainer = styled(Box)`
display: flex;

+ 4
- 36
src/components/Cards/FilterCard/Skeleton/SkeletonChooserTitle/SkeletonChooserTitle.styled.js Näytä tiedosto

@@ -1,48 +1,16 @@
import { Box } from "@mui/material";
import styled from "styled-components";
import selectedTheme from "../../../../../themes";
import { BackgroundTransition } from "../../../../MarketPlace/Header/SkeletonHeader/SkeletonHeader.styled";
import { ItemsTransition } from "../../../OfferCard/SkeletonOfferCard/SkeletonOfferCard.styled";

export const SkeletonChooserTitleContainer = styled(Box)`
export const SkeletonChooserTitleContainer = styled(ItemsTransition)`
margin-top: ${(props) => (props.center ? "44px" : "18px")};
width: 100%;
transition: ${(props) => (props.animationStage === 3 ? "0.9s" : "0")};
background: linear-gradient(
to left,
${selectedTheme.filterSkeletonItems} 20%,
${selectedTheme.filterSkeletonItems},
${selectedTheme.filterSkeletonItemsSecond},
${selectedTheme.filterSkeletonItemsSecond} 40%,
${selectedTheme.filterSkeletonItemsSecond} 60%,
${selectedTheme.filterSkeletonItemsSecond},
${selectedTheme.filterSkeletonItems},
${selectedTheme.filterSkeletonItems} 80%
)
right;
background-size: 500% 100%;
background-position: ${(props) =>
props.animationStage !== 2 ? "left" : "right"};
height: 40px;
padding: 13px 18px;
`;
export const SkeletonChooserTitleLine = styled(Box)`
export const SkeletonChooserTitleLine = styled(BackgroundTransition)`
width: 108px;
height: 14px;
transition: ${(props) => (props.animationStage === 3 ? "0.9s" : "0")};
background: linear-gradient(
to left,
${selectedTheme.filterSkeletonBackground} 20%,
${selectedTheme.filterSkeletonBackground},
${selectedTheme.filterSkeletonBackgroundSecond},
${selectedTheme.filterSkeletonBackgroundSecond} 40%,
${selectedTheme.filterSkeletonBackgroundSecond} 60%,
${selectedTheme.filterSkeletonBackgroundSecond},
${selectedTheme.filterSkeletonBackground},
${selectedTheme.filterSkeletonBackground} 80%
)
right;
background-size: 500% 100%;
background-position: ${(props) =>
props.animationStage !== 2 ? "left" : "right"};
${(props) =>
props.center &&
`

+ 5
- 52
src/components/Cards/FilterCard/Skeleton/SkeletonFilterCard.styled.js Näytä tiedosto

@@ -1,28 +1,13 @@
import { Box } from "@mui/material";
import styled from "styled-components";
import selectedTheme from "../../../../themes";
import { BackgroundTransition } from "../../../MarketPlace/Header/SkeletonHeader/SkeletonHeader.styled";
import { ItemsTransition } from "../../OfferCard/SkeletonOfferCard/SkeletonOfferCard.styled";

export const SkeletonFilterCardContainer = styled(Box)`
export const SkeletonFilterCardContainer = styled(BackgroundTransition)`
display: ${props => props.skeleton ? "block" : "none"};
background: linear-gradient(
to left,
${selectedTheme.filterSkeletonBackground} 20%,
${selectedTheme.filterSkeletonBackground},
${selectedTheme.filterSkeletonBackgroundSecond},
${selectedTheme.filterSkeletonBackgroundSecond} 40%,
${selectedTheme.filterSkeletonBackgroundSecond} 60%,
${selectedTheme.filterSkeletonBackgroundSecond},
${selectedTheme.filterSkeletonBackground},
${selectedTheme.filterSkeletonBackground} 80%
)
right;
background-size: 500% 100%;
background-position: ${(props) =>
props.animationStage !== 2 ? "left" : "right"};
width: 100%;
height: 100%;
padding: 36px;
transition: ${(props) => (props.animationStage === 3 ? "0.9s" : "0")};
& * {
display: flex;
border-radius: 4px;
@@ -33,45 +18,13 @@ export const SkeletonHeader = styled(Box)`
flex-direction: row;
justify-content: space-between;
`;
export const SkeletonHeaderLineOne = styled(Box)`
export const SkeletonHeaderLineOne = styled(ItemsTransition)`
width: 90px;
height: 27px;
transition: ${(props) => (props.animationStage === 3 ? "0.9s" : "0")};
background: linear-gradient(
to left,
${selectedTheme.filterSkeletonItems} 20%,
${selectedTheme.filterSkeletonItems},
${selectedTheme.filterSkeletonItemsSecond},
${selectedTheme.filterSkeletonItemsSecond} 40%,
${selectedTheme.filterSkeletonItemsSecond} 60%,
${selectedTheme.filterSkeletonItemsSecond},
${selectedTheme.filterSkeletonItems},
${selectedTheme.filterSkeletonItems} 80%
)
right;
background-size: 500% 100%;
background-position: ${(props) =>
props.animationStage !== 2 ? "left" : "right"};
`;
export const SkeletonHeaderLineSecond = styled(Box)`
export const SkeletonHeaderLineSecond = styled(ItemsTransition)`
width: 78px;
height: 14px;
position: relative;
top: 7px;
transition: ${(props) => (props.animationStage === 3 ? "0.9s" : "0")};
background: linear-gradient(
to left,
${selectedTheme.filterSkeletonItems} 20%,
${selectedTheme.filterSkeletonItems},
${selectedTheme.filterSkeletonItemsSecond},
${selectedTheme.filterSkeletonItemsSecond} 40%,
${selectedTheme.filterSkeletonItemsSecond} 60%,
${selectedTheme.filterSkeletonItemsSecond},
${selectedTheme.filterSkeletonItems},
${selectedTheme.filterSkeletonItems} 80%
)
right;
background-size: 500% 100%;
background-position: ${(props) =>
props.animationStage !== 2 ? "left" : "right"};
`;

+ 4
- 52
src/components/Cards/FilterCard/Skeleton/SkeletonSection/SkeletonSectionOption/SkeletonSectionOption.styled.js Näytä tiedosto

@@ -1,6 +1,6 @@
import { Box } from "@mui/material";
import styled from "styled-components";
import selectedTheme from "../../../../../../themes";
import { ItemsTransition } from "../../../../OfferCard/SkeletonOfferCard/SkeletonOfferCard.styled";

export const SkeletonSectionOptionContainer = styled(Box)`
display: flex;
@@ -12,64 +12,16 @@ export const OptionLeftContainer = styled(Box)`
flex-direction: row;
gap: 9px;
`;
export const Circle = styled(Box)`
export const Circle = styled(ItemsTransition)`
width: 14px;
height: 14px;
transition: ${(props) => (props.animationStage === 3 ? "0.9s" : "0")};
background: linear-gradient(
to left,
${selectedTheme.filterSkeletonItems} 20%,
${selectedTheme.filterSkeletonItems},
${selectedTheme.filterSkeletonItemsSecond},
${selectedTheme.filterSkeletonItemsSecond} 40%,
${selectedTheme.filterSkeletonItemsSecond} 60%,
${selectedTheme.filterSkeletonItemsSecond},
${selectedTheme.filterSkeletonItems},
${selectedTheme.filterSkeletonItems} 80%
)
right;
background-size: 500% 100%;
background-position: ${(props) =>
props.animationStage !== 2 ? "left" : "right"};
border-radius: 100% !important;
`;
export const Line = styled(Box)`
export const Line = styled(ItemsTransition)`
width: 86px;
height: 14px;
transition: ${(props) => (props.animationStage === 3 ? "0.9s" : "0")};
background: linear-gradient(
to left,
${selectedTheme.filterSkeletonItems} 20%,
${selectedTheme.filterSkeletonItems},
${selectedTheme.filterSkeletonItemsSecond},
${selectedTheme.filterSkeletonItemsSecond} 40%,
${selectedTheme.filterSkeletonItemsSecond} 60%,
${selectedTheme.filterSkeletonItemsSecond},
${selectedTheme.filterSkeletonItems},
${selectedTheme.filterSkeletonItems} 80%
)
right;
background-size: 500% 100%;
background-position: ${(props) =>
props.animationStage !== 2 ? "left" : "right"};
`;
export const EndLine = styled(Box)`
export const EndLine = styled(ItemsTransition)`
width: 23px;
height: 14px;
transition: ${(props) => (props.animationStage === 3 ? "0.9s" : "0")};
background: linear-gradient(
to left,
${selectedTheme.filterSkeletonItems} 20%,
${selectedTheme.filterSkeletonItems},
${selectedTheme.filterSkeletonItemsSecond},
${selectedTheme.filterSkeletonItemsSecond} 40%,
${selectedTheme.filterSkeletonItemsSecond} 60%,
${selectedTheme.filterSkeletonItemsSecond},
${selectedTheme.filterSkeletonItems},
${selectedTheme.filterSkeletonItems} 80%
)
right;
background-size: 500% 100%;
background-position: ${(props) =>
props.animationStage !== 2 ? "left" : "right"};
`;

+ 2
- 1
src/components/Cards/OfferCard/SkeletonOfferCard/SkeletonOfferCard.styled.js Näytä tiedosto

@@ -4,7 +4,8 @@ import selectedTheme from "../../../../themes";
import { BackgroundTransition } from "../../../MarketPlace/Header/SkeletonHeader/SkeletonHeader.styled";

export const ItemsTransition = styled(Box)`
transition: 0.4s;
transition-duration: 0.4s;
transition-property: background-color;
background-color: ${props => props.animationStage === 1 ? selectedTheme.filterSkeletonItems : selectedTheme.filterSkeletonItemsSecond} !important;
`;


+ 2
- 1
src/components/MarketPlace/Header/Header.js Näytä tiedosto

@@ -93,7 +93,7 @@ const Header = (props) => {

return (
<>
<SkeletonHeader skeleton={props.skeleton} />
<SkeletonHeader skeleton={props.skeleton} animationStage={props.animationStage} />
<HeaderContainer skeleton={props.skeleton}>
{/* Setting appropriate header title if page is market place or my offers */}
<Tooltip title={headerString}>
@@ -177,6 +177,7 @@ Header.propTypes = {
category: PropTypes.string,
myOffers: PropTypes.bool,
skeleton: PropTypes.bool,
animationStage: PropTypes.number,
};
Header.defaultProps = {
isGrid: false,

+ 5
- 4
src/components/MarketPlace/Header/SkeletonHeader/SkeletonHeader.js Näytä tiedosto

@@ -5,13 +5,13 @@ import { CircleGroup, SkeletonHeaderCircle, SkeletonHeaderContainer, SkeletonHea
const SkeletonHeader = (props) => {
return (
<SkeletonHeaderContainer skeleton={props.skeleton}>
<SkeletonHeaderLine />
<SkeletonHeaderLine animationStage={props.animationStage} />
<SkeletonRowGroup>
<CircleGroup>
<SkeletonHeaderCircle />
<SkeletonHeaderCircle />
<SkeletonHeaderCircle animationStage={props.animationStage} />
<SkeletonHeaderCircle animationStage={props.animationStage} />
</CircleGroup>
<SkeletonHeaderRightLine />
<SkeletonHeaderRightLine animationStage={props.animationStage} />
</SkeletonRowGroup>
</SkeletonHeaderContainer>
)
@@ -19,6 +19,7 @@ const SkeletonHeader = (props) => {

SkeletonHeader.propTypes = {
skeleton: PropTypes.bool,
animationStage: PropTypes.number,
}

export default SkeletonHeader

+ 4
- 3
src/components/MarketPlace/Header/SkeletonHeader/SkeletonHeader.styled.js Näytä tiedosto

@@ -3,7 +3,8 @@ import styled from "styled-components";
import selectedTheme from "../../../../themes";

export const BackgroundTransition = styled(Box)`
transition: 0.4s;
transition-duration: 0.4s;
transition-property: background-color;
background-color: ${props => props.animationStage === 1 ? selectedTheme.filterSkeletonBackground : selectedTheme.filterSkeletonBackgroundSecond} !important;
`;

@@ -11,7 +12,7 @@ export const SkeletonHeaderContainer = styled(Box)`
display: ${(props) => (props.skeleton ? "flex" : "none")};
flex-direction: row;
justify-content: space-between;
margin-top: 47px;
margin-top: 36px;
`;
export const SkeletonHeaderLine = styled(BackgroundTransition)`
background-color: ${selectedTheme.filterSkeletonBackground};
@@ -32,7 +33,7 @@ export const CircleGroup = styled(Box)`
gap: 18px;
position: relative;
top: -3px;
margin-right: 36px;
margin-right: 46px;
`;
export const SkeletonHeaderCircle = styled(BackgroundTransition)`
width: 40px;

+ 13
- 7
src/hooks/useFilters.js Näytä tiedosto

@@ -1,4 +1,5 @@
import { useEffect, useState } from "react";
import _ from "lodash";
import { useCallback, useEffect, useState } from "react";
import { useDispatch } from "react-redux";
import { useSelector } from "react-redux";
import { fetchCategories } from "../store/actions/categories/categoriesActions";
@@ -27,7 +28,6 @@ const useFilters = (myOffers) => {
const selectedSubcategory = useSelector(selectSelectedSubcategory);
const selectedLocations = useSelector(selectSelectedLocations);
const [loadedFromQS, setLoadedFromQS] = useState(false);
const [loaded, setLoadedStatus] = useState(false);
const isApplied = useSelector(selectAppliedStatus);
const categories = useSelector(selectCategories);
const subcategories = useSelector(
@@ -36,13 +36,19 @@ const useFilters = (myOffers) => {
const locations = useSelector(selectLocations);
const dispatch = useDispatch();
const queryStringHook = useQueryString();
useEffect(() => {
if (!loaded) {

const fetchCategoriesAndLocations = useCallback(
_.once(() => {
dispatch(fetchCategories());
dispatch(fetchLocations());
setLoadedStatus(true);
}
}, [categories, locations]);
console.log("once pozvan");
}),
[]
);

useEffect(() => {
fetchCategoriesAndLocations();
}, []);

useEffect(() => {
const queryObject = new URLSearchParams(queryStringHook.queryString);

+ 3
- 2
src/store/actions/categories/categoriesActionConstants.js Näytä tiedosto

@@ -1,7 +1,8 @@
import { createFetchType, createSuccessType } from "../actionHelpers";
import { createErrorType, createFetchType, createSetType, createSuccessType } from "../actionHelpers";

const CATEGORIES_SCOPE = "CATEGORIES";
export const CATEGORIES_FETCH = createFetchType(CATEGORIES_SCOPE);
export const CATEGORIES_FETCH_SUCCESS = createSuccessType(CATEGORIES_SCOPE);
export const CATEGORIES_FETCH_ERROR = createErrorType(CATEGORIES_SCOPE);

export const CATEGORIES_SET = "CATEGORIES_SET";
export const CATEGORIES_SET = createSetType("CATEGORIES_SET");

+ 4
- 1
src/store/actions/categories/categoriesActions.js Näytä tiedosto

@@ -1,4 +1,4 @@
import { CATEGORIES_FETCH, CATEGORIES_FETCH_SUCCESS, CATEGORIES_SET } from "./categoriesActionConstants";
import { CATEGORIES_FETCH, CATEGORIES_FETCH_ERROR, CATEGORIES_FETCH_SUCCESS, CATEGORIES_SET } from "./categoriesActionConstants";

export const fetchCategories = () => ({
type: CATEGORIES_FETCH
@@ -10,4 +10,7 @@ export const setCategories = (payload) => ({
})
export const fetchCategoriesSuccess = () => ({
type: CATEGORIES_FETCH_SUCCESS
})
export const fetchCategoriesError = () => ({
type: CATEGORIES_FETCH_ERROR
})

+ 9
- 4
src/store/actions/chat/chatActionConstants.js Näytä tiedosto

@@ -1,4 +1,4 @@
import { createFetchType, createSuccessType } from "../actionHelpers";
import { createErrorType, createFetchType, createSetType, createSuccessType } from "../actionHelpers";

const CHAT_SCOPE = "CHAT_SCOPE";
const CHAT_HEADER_SCOPE = "CHAT_HEADER_SCOPE";
@@ -8,20 +8,25 @@ const CHAT_NEW_SCOPE = "CHAT_NEW_SCOPE";

export const CHAT_FETCH = createFetchType(CHAT_SCOPE);
export const CHAT_FETCH_SUCCESS = createSuccessType(CHAT_SCOPE);
export const CHAT_FETCH_ERROR = createErrorType(CHAT_SCOPE);

export const CHAT_SEND_FETCH = createFetchType(CHAT_SEND_SCOPE);
export const CHAT_SEND_SUCCESS = createSuccessType(CHAT_SEND_SCOPE);
export const CHAT_SEND_ERROR = createErrorType(CHAT_SEND_SCOPE);

export const CHAT_HEADER_FETCH = createFetchType(CHAT_HEADER_SCOPE);
export const CHAT_HEADER_FETCH_SUCCESS = createSuccessType(CHAT_HEADER_SCOPE);
export const CHAT_HEADER_FETCH_ERROR = createErrorType(CHAT_HEADER_SCOPE);

export const CHAT_ONE_FETCH = createFetchType(CHAT_ONE_SCOPE);
export const CHAT_ONE_FETCH_SUCCESS = createSuccessType(CHAT_ONE_SCOPE);
export const CHAT_ONE_FETCH_ERROR = createErrorType(CHAT_ONE_SCOPE);

export const CHAT_NEW_FETCH = createFetchType(CHAT_NEW_SCOPE);
export const CHAT_NEW_FETCH_SUCCESS = createSuccessType(CHAT_NEW_SCOPE);
export const CHAT_NEW_FETCH_ERROR = createErrorType(CHAT_NEW_SCOPE);

export const CHAT_SET = "CHAT_SET";
export const CHAT_ONE_SET = "CHAT_ONE_SET";
export const CHAT_CLEAR = "CHAT_CLEAR";
export const CHAT_SET = createSetType("CHAT_SET");
export const CHAT_ONE_SET = createSetType("CHAT_ONE_SET");
export const CHAT_CLEAR = createSetType("CHAT_CLEAR");
// export const ADD_ONE_CHAT = "CHAT_ONE_ADD";

+ 16
- 1
src/store/actions/chat/chatActions.js Näytä tiedosto

@@ -1,4 +1,4 @@
import { CHAT_CLEAR, CHAT_FETCH, CHAT_FETCH_SUCCESS, CHAT_HEADER_FETCH, CHAT_HEADER_FETCH_SUCCESS, CHAT_NEW_FETCH, CHAT_NEW_FETCH_SUCCESS, CHAT_ONE_FETCH, CHAT_ONE_FETCH_SUCCESS, CHAT_ONE_SET, CHAT_SEND_FETCH, CHAT_SEND_SUCCESS, CHAT_SET } from "./chatActionConstants";
import { CHAT_CLEAR, CHAT_FETCH, CHAT_FETCH_ERROR, CHAT_FETCH_SUCCESS, CHAT_HEADER_FETCH, CHAT_HEADER_FETCH_ERROR, CHAT_HEADER_FETCH_SUCCESS, CHAT_NEW_FETCH, CHAT_NEW_FETCH_ERROR, CHAT_NEW_FETCH_SUCCESS, CHAT_ONE_FETCH, CHAT_ONE_FETCH_ERROR, CHAT_ONE_FETCH_SUCCESS, CHAT_ONE_SET, CHAT_SEND_ERROR, CHAT_SEND_FETCH, CHAT_SEND_SUCCESS, CHAT_SET } from "./chatActionConstants";

export const fetchChats = (payload) => ({
type: CHAT_FETCH,
@@ -45,4 +45,19 @@ export const sendMessageSuccess = () => ({
})
export const startNewChatSuccess = () => ({
type: CHAT_NEW_FETCH_SUCCESS
})
export const fetchChatsError = () => ({
type: CHAT_FETCH_ERROR
})
export const fetchHeaderChatsError = () => ({
type: CHAT_HEADER_FETCH_ERROR
})
export const fetchOneChatError = () => ({
type: CHAT_ONE_FETCH_ERROR
})
export const sendMessageError = () => ({
type: CHAT_SEND_ERROR
})
export const startNewChatError = () => ({
type: CHAT_NEW_FETCH_ERROR
})

+ 8
- 2
src/store/actions/counter/counterActionConstants.js Näytä tiedosto

@@ -1,4 +1,10 @@
import { createFetchType } from "../actionHelpers";
import {
createErrorType,
createFetchType,
createSuccessType,
} from "../actionHelpers";

const COUNTER_SCOPE = "COUNTER_SCOPE";
export const COUNTER_INCREASE = createFetchType(COUNTER_SCOPE);
export const COUNTER_INCREASE = createFetchType(COUNTER_SCOPE);
export const COUNTER_INCREASE_SUCCESS = createSuccessType(COUNTER_SCOPE);
export const COUNTER_INCREASE_ERROR = createErrorType(COUNTER_SCOPE);

+ 7
- 1
src/store/actions/counter/counterActions.js Näytä tiedosto

@@ -1,6 +1,12 @@
import { COUNTER_INCREASE } from "./counterActionConstants";
import { COUNTER_INCREASE, COUNTER_INCREASE_ERROR, COUNTER_INCREASE_SUCCESS } from "./counterActionConstants";

export const increaseCounter = (payload) => ({
type: COUNTER_INCREASE,
payload,
})
export const increaseCounterSuccess = () => ({
type: COUNTER_INCREASE_SUCCESS
})
export const increaseCounterError = () => ({
type: COUNTER_INCREASE_ERROR
})

+ 17
- 4
src/store/actions/exchange/exchangeActionConstants.js Näytä tiedosto

@@ -1,9 +1,22 @@
import { createFetchType } from "../actionHelpers";
import {
createErrorType,
createFetchType,
createSetType,
createSuccessType,
} from "../actionHelpers";

const EXCHANGE_SCOPE = "EXCHANGE_SCOPE";
const EXCHANGE_VALIDATE_SCOPE = "EXCHANGE_VALIDATE_SCOPE";
export const EXCHANGE_FETCH = createFetchType(EXCHANGE_SCOPE);
export const EXCHANGE_VALIDATE_FETCH = createFetchType(EXCHANGE_VALIDATE_SCOPE);
export const EXCHANGE_FETCH_SUCCESS = createSuccessType(EXCHANGE_SCOPE);
export const EXCHANGE_FETCH_ERROR = createErrorType(EXCHANGE_SCOPE);

const EXCHANGE_VALIDATE_SCOPE = "EXCHANGE_VALIDATE_SCOPE";
export const EXCHANGE_VALIDATE_FETCH = createFetchType(EXCHANGE_VALIDATE_SCOPE);
export const EXCHANGE_VALIDATE_FETCH_SUCCESS = createSuccessType(
EXCHANGE_VALIDATE_SCOPE
);
export const EXCHANGE_VALIDATE_FETCH_ERROR = createErrorType(
EXCHANGE_VALIDATE_SCOPE
);

export const EXCHANGE_SET = "EXCHANGE_SET";
export const EXCHANGE_SET = createSetType("EXCHANGE_SET");

+ 13
- 1
src/store/actions/exchange/exchangeActions.js Näytä tiedosto

@@ -1,4 +1,4 @@
import { EXCHANGE_FETCH, EXCHANGE_SET, EXCHANGE_VALIDATE_FETCH } from "./exchangeActionConstants";
import { EXCHANGE_FETCH, EXCHANGE_FETCH_ERROR, EXCHANGE_FETCH_SUCCESS, EXCHANGE_SET, EXCHANGE_VALIDATE_FETCH, EXCHANGE_VALIDATE_FETCH_ERROR, EXCHANGE_VALIDATE_FETCH_SUCCESS } from "./exchangeActionConstants";

export const fetchExchange = (payload) => ({
type: EXCHANGE_FETCH,
@@ -11,4 +11,16 @@ export const setExchange = (payload) => ({
export const validateExchange = (payload) => ({
type: EXCHANGE_VALIDATE_FETCH,
payload,
})
export const fetchExchangeSuccess = () => ({
type: EXCHANGE_FETCH_SUCCESS
})
export const fetchExchangeError = () => ({
type: EXCHANGE_FETCH_ERROR
})
export const validateExchangeSuccess = () => ({
type: EXCHANGE_VALIDATE_FETCH_SUCCESS
})
export const validateExchangeError = () => ({
type: EXCHANGE_VALIDATE_FETCH_ERROR
})

+ 6
- 6
src/store/actions/filters/filtersActionConstants.js Näytä tiedosto

@@ -3,9 +3,9 @@ import { createClearType, createSetType } from "../actionHelpers"
const FILTERS_SCOPE = "FILTERS"
export const SET_FILTERS = createSetType(FILTERS_SCOPE);
export const CLEAR_FILTERS = createClearType(FILTERS_SCOPE);
export const SET_CATEGORY = "FILTERS_SET_CATEGORY";
export const SET_SUBCATEGORY = "FILTERS_SET_SUBCATEGORY";
export const SET_LOCATIONS = "FILTERS_SET_LOCATIONS";
export const SET_SORT_OPTION = "FILTERS_SET_SORT_OPTION";
export const SET_IS_APPLIED = "FILTERS_SET_IS_APPLIED";
export const SET_QUERY_STRING = "FILTERS_SET_QUERY_STRING";
export const SET_CATEGORY = createSetType("FILTERS_SET_CATEGORY");
export const SET_SUBCATEGORY = createSetType("FILTERS_SET_SUBCATEGORY");
export const SET_LOCATIONS = createSetType("FILTERS_SET_LOCATIONS");
export const SET_SORT_OPTION = createSetType("FILTERS_SET_SORT_OPTION");
export const SET_IS_APPLIED = createSetType("FILTERS_SET_IS_APPLIED");
export const SET_QUERY_STRING = createSetType("FILTERS_SET_QUERY_STRING");

+ 3
- 2
src/store/actions/locations/locationsActionConstants.js Näytä tiedosto

@@ -1,7 +1,8 @@
import { createFetchType, createSuccessType } from "../actionHelpers";
import { createErrorType, createFetchType, createSetType, createSuccessType } from "../actionHelpers";

const LOCATIONS_SCOPE = "LOCATIONS_SCOPE";
export const LOCATIONS_FETCH = createFetchType(LOCATIONS_SCOPE);
export const LOCATIONS_FETCH_SUCCESS = createSuccessType(LOCATIONS_SCOPE);
export const LOCATIONS_FETCH_ERROR = createErrorType(LOCATIONS_SCOPE);

export const LOCATIONS_SET = "LOCATIONS_SET";
export const LOCATIONS_SET = createSetType("LOCATIONS_SET");

+ 4
- 1
src/store/actions/locations/locationsActions.js Näytä tiedosto

@@ -1,4 +1,4 @@
import { LOCATIONS_FETCH, LOCATIONS_FETCH_SUCCESS, LOCATIONS_SET } from "./locationsActionConstants";
import { LOCATIONS_FETCH, LOCATIONS_FETCH_ERROR, LOCATIONS_FETCH_SUCCESS, LOCATIONS_SET } from "./locationsActionConstants";

export const fetchLocations = () => ({
type: LOCATIONS_FETCH,
@@ -10,4 +10,7 @@ export const setLocations = (payload) => ({
})
export const fetchLocationsSuccess = () => ({
type: LOCATIONS_FETCH_SUCCESS
})
export const fetchLocationsError = () => ({
type: LOCATIONS_FETCH_ERROR
})

+ 6
- 5
src/store/actions/login/loginActionConstants.js Näytä tiedosto

@@ -5,6 +5,7 @@ import {
createLoadingType,
createSuccessType,
createSubmitType,
createUpdateType,
} from '../actionHelpers';


@@ -18,11 +19,11 @@ export const CLEAR_LOGIN_USER_ERROR = createClearType(
export const LOGIN_USER_LOADING = createLoadingType(LOGIN_USER_SCOPE);


export const UPDATE_USER_JWT_TOKEN = 'UPDATE_USER_JWT_TOKEN';
export const RESET_LOGIN_STATE = 'RESET_LOGIN_STATE';
export const AUTHENTICATE_USER = 'AUTHENTICATE_USER';
export const LOGOUT_USER = 'LOGOUT_USER';
export const REFRESH_TOKEN = 'REFRESH_TOKEN';
export const UPDATE_USER_JWT_TOKEN = createUpdateType('UPDATE_USER_JWT_TOKEN');
export const RESET_LOGIN_STATE = createClearType('UPDATE_USER_JWT_TOKEN');
export const AUTHENTICATE_USER = createUpdateType('AUTHENTICATE_USER');
export const LOGOUT_USER = createUpdateType('LOGOUT_USER');
export const REFRESH_TOKEN = createUpdateType('REFRESH_TOKEN');

const GENERATE_TOKEN_SCOPE = 'GENERATE_TOKEN';
export const GENERATE_TOKEN = createSubmitType(GENERATE_TOKEN_SCOPE);

+ 26
- 16
src/store/actions/offers/offersActionConstants.js Näytä tiedosto

@@ -2,47 +2,57 @@ import {
createClearType,
createErrorType,
createFetchType,
createSetType,
createSuccessType,
} from "../actionHelpers";

const OFFERS_SCOPE = "OFFERS_SCOPE";
const ONE_OFFER_SCOPE = "ONE_OFFER_SCOPE";
export const OFFERS_FETCH = createFetchType(OFFERS_SCOPE);
export const OFFERS_SUCCESS = createSuccessType(OFFERS_SCOPE);
export const OFFERS_ERROR = createErrorType(OFFERS_SCOPE);
export const OFFERS_CLEAR = createClearType(OFFERS_SCOPE);

const OFFERS_MORE_SCOPE = "OFFERS_MORE_SCOPE";
export const OFFERS_FETCH_MORE = createFetchType(OFFERS_MORE_SCOPE);
export const OFFERS_FETCH_MORE_SUCCESS = createSuccessType(OFFERS_MORE_SCOPE)
export const OFFERS_FETCH_MORE_ERROR = createErrorType(OFFERS_MORE_SCOPE)

const OFFERS_MINE_SCOPE = "OFFERS_MINE_SCOPE";
export const OFFERS_MINE_FETCH = createFetchType(OFFERS_MINE_SCOPE);
export const OFFERS_FETCH = createFetchType(OFFERS_SCOPE);
export const OFFERS_SUCCESS = createSuccessType(OFFERS_SCOPE);
export const OFFERS_ERROR = createErrorType(OFFERS_SCOPE);
export const OFFERS_CLEAR = createClearType(OFFERS_SCOPE);
export const OFFERS_MINE_FETCH_SUCCESS = createSuccessType(OFFERS_MINE_SCOPE);
export const OFFERS_MINE_FETCH_ERROR = createErrorType(OFFERS_MINE_SCOPE);

const OFFERS_PROFILE_SCOPE = "OFFERS_PROFILE_SCOPE";
export const OFFERS_PROFILE_FETCH = createFetchType(OFFERS_PROFILE_SCOPE);
export const OFFERS_PROFILE_SUCCESS = createSuccessType(OFFERS_PROFILE_SCOPE);
export const OFFERS_PROFILE_ERROR = createErrorType(OFFERS_PROFILE_SCOPE);

const ONE_OFFER_SCOPE = "ONE_OFFER_SCOPE";
export const ONE_OFFER_FETCH = createFetchType(ONE_OFFER_SCOPE);
export const ONE_OFFER_SUCCESS = createSuccessType(ONE_OFFER_FETCH);
export const ONE_OFFER_SUCCESS = createSuccessType(ONE_OFFER_SCOPE);
export const ONE_OFFER_ERROR = createErrorType(ONE_OFFER_SCOPE);

export const OFFERS_PINNED_SET = "OFFERS_PINNED_SET";
export const OFFERS_PINNED_ADD = "OFFERS_PINNED_ADD";
export const OFFERS_SET = "OFFERS_SET";
export const OFFER_SET = "OFFER_SET";
export const OFFERS_ADD = "OFFERS_ADD";
export const OFFERS_NO_MORE = "OFFERS_NO_MORE";
export const OFFERS_SET_TOTAL = createSuccessType(OFFERS_SCOPE);
export const OFFERS_MINE_SET = "OFFERS_MY_ADD";
export const OFFERS_PINNED_SET = createSetType("OFFERS_PINNED_SET");
export const OFFERS_PINNED_ADD = createSetType("OFFERS_PINNED_ADD");
export const OFFERS_SET = createSetType("OFFERS_SET");
export const OFFER_SET = createSetType("OFFER_SET");
export const OFFERS_ADD = createSetType("OFFERS_ADD");
export const OFFERS_NO_MORE = createSetType("OFFERS_NO_MORE");
export const OFFERS_SET_TOTAL = createSetType("OFFERS_SET_TOTAL");
export const OFFERS_PROFILE_SET = createSetType("OFFERS_PROFILE_SET");
export const OFFERS_MINE_SET = createSetType("OFFERS_MY_ADD");

const OFFER_ADD_SCOPE = "OFFER_ADD_SCOPE";
export const OFFER_ADD = createFetchType(OFFER_ADD_SCOPE);
export const OFFER_ADD_SUCCESS = createSuccessType(OFFER_ADD_SCOPE)
export const OFFERS_PROFILE_SET = "OFFERS_PROFILE_SET";
export const OFFER_ADD_SUCCESS = createSuccessType(OFFER_ADD_SCOPE);
export const OFFER_ADD_ERROR = createErrorType(OFFER_ADD_SCOPE);

const OFFER_REMOVE_SCOPE = "OFFER_REMOVE_SCOPE";
export const OFFER_REMOVE = createFetchType(OFFER_REMOVE_SCOPE);
export const OFFER_REMOVE_SUCCESS = createSuccessType(OFFER_REMOVE_SCOPE);
export const OFFER_REMOVE_ERROR = createErrorType(OFFER_REMOVE_SCOPE);

const OFFER_EDIT_SCOPE = "OFFER_EDIT_SCOPE";
export const OFFER_EDIT = createFetchType(OFFER_EDIT_SCOPE);
export const OFFER_EDIT_SUCCESS = createSuccessType(OFFER_EDIT_SCOPE);
export const OFFER_EDIT_ERROR = createErrorType(OFFER_EDIT_SCOPE);

+ 88
- 43
src/store/actions/offers/offersActions.js Näytä tiedosto

@@ -4,11 +4,16 @@ import {
OFFERS_ERROR,
OFFERS_FETCH,
OFFERS_FETCH_MORE,
OFFERS_FETCH_MORE_ERROR,
OFFERS_FETCH_MORE_SUCCESS,
OFFERS_MINE_FETCH,
OFFERS_MINE_FETCH_ERROR,
OFFERS_MINE_FETCH_SUCCESS,
OFFERS_MINE_SET,
OFFERS_NO_MORE,
OFFERS_PINNED_ADD,
OFFERS_PINNED_SET,
OFFERS_PROFILE_ERROR,
OFFERS_PROFILE_FETCH,
OFFERS_PROFILE_SET,
OFFERS_PROFILE_SUCCESS,
@@ -16,10 +21,13 @@ import {
OFFERS_SET_TOTAL,
OFFERS_SUCCESS,
OFFER_ADD,
OFFER_ADD_ERROR,
OFFER_ADD_SUCCESS,
OFFER_EDIT,
OFFER_EDIT_ERROR,
OFFER_EDIT_SUCCESS,
OFFER_REMOVE,
OFFER_REMOVE_ERROR,
OFFER_REMOVE_SUCCESS,
OFFER_SET,
ONE_OFFER_ERROR,
@@ -27,6 +35,7 @@ import {
ONE_OFFER_SUCCESS,
} from "./offersActionConstants";

// Fetch offers
export const fetchOffers = (payload) => ({
type: OFFERS_FETCH,
payload,
@@ -42,57 +51,111 @@ export const fetchOffersError = (payload) => ({
export const clearOffers = () => ({
type: OFFERS_CLEAR,
});
export const setOffers = (payload) => ({
type: OFFERS_SET,

// Fetch more offers
export const fetchMoreOffers = (payload) => ({
type: OFFERS_FETCH_MORE,
payload,
});
export const setPinnedOffers = (payload) => ({
type: OFFERS_PINNED_SET,
export const fetchMoreOffersSuccess = () => ({
type: OFFERS_FETCH_MORE_SUCCESS,
});
export const fetchMoreOffersError = () => ({
type: OFFERS_FETCH_MORE_ERROR,
});

// Fetch mine offers
export const fetchMineOffers = () => ({
type: OFFERS_MINE_FETCH,
});
export const fetchMineOffersSuccess = () => ({
type: OFFERS_MINE_FETCH_SUCCESS,
});
export const fetchMineOffersError = () => ({
type: OFFERS_MINE_FETCH_ERROR,
});

// Fetch profile offers
export const fetchProfileOffers = (payload) => ({
type: OFFERS_PROFILE_FETCH,
payload,
});
export const addPinnedOffers = (payload) => ({
type: OFFERS_PINNED_ADD,
export const fetchProfileOffersSuccess = () => ({
type: OFFERS_PROFILE_SUCCESS,
});
export const fetchProfileOffersError = () => ({
type: OFFERS_PROFILE_ERROR,
});

// One offer
export const fetchOneOffer = (payload) => ({
type: ONE_OFFER_FETCH,
payload,
});
export const addOffers = (payload) => ({
type: OFFERS_ADD,
export const fetchOneOfferError = (payload) => ({
type: ONE_OFFER_ERROR,
payload,
});
export const fetchOneOfferSuccess = (payload) => ({
type: ONE_OFFER_SUCCESS,
payload,
});

// Add offer
export const addOffer = (payload) => ({
type: OFFER_ADD,
payload,
});
export const addOfferSuccess = () => ({
type: OFFER_ADD_SUCCESS,
});
export const addOfferError = () => ({
type: OFFER_ADD_ERROR,
});

// Remove offer
export const removeOffer = (payload) => ({
type: OFFER_REMOVE,
payload,
});
export const removeOfferSuccess = () => ({
type: OFFER_REMOVE_SUCCESS,
});
export const removeOfferError = () => ({
type: OFFER_REMOVE_ERROR
})

// Edit offer
export const editOneOffer = (payload) => ({
type: OFFER_EDIT,
payload,
});
export const editOfferSuccess = () => ({
type: OFFER_EDIT_SUCCESS,
});
export const editOfferError = () => ({
type: OFFER_EDIT_ERROR
})

export const fetchOneOffer = (payload) => ({
type: ONE_OFFER_FETCH,


export const setOffers = (payload) => ({
type: OFFERS_SET,
payload,
});
export const fetchOneOfferError = (payload) => ({
type: ONE_OFFER_ERROR,
export const setPinnedOffers = (payload) => ({
type: OFFERS_PINNED_SET,
payload,
});
export const fetchOneOfferSuccess = (payload) => ({
type: ONE_OFFER_SUCCESS,
export const addPinnedOffers = (payload) => ({
type: OFFERS_PINNED_ADD,
payload,
});

export const setOffer = (payload) => ({
type: OFFER_SET,
export const addOffers = (payload) => ({
type: OFFERS_ADD,
payload,
});

export const fetchMoreOffers = (payload) => ({
type: OFFERS_FETCH_MORE,
payload,
});
export const setNoMoreOffersStatus = (payload) => ({
type: OFFERS_NO_MORE,
payload,
@@ -101,33 +164,15 @@ export const setTotalOffers = (payload) => ({
type: OFFERS_SET_TOTAL,
payload,
});
export const fetchMineOffers = () => ({
type: OFFERS_MINE_FETCH,
});
export const setMineOffers = (payload) => ({
type: OFFERS_MINE_SET,
payload,
});
export const fetchProfileOffers = (payload) => ({
type: OFFERS_PROFILE_FETCH,
payload,
});
export const setProfileOffers = (payload) => ({
type: OFFERS_PROFILE_SET,
payload,
});
export const createOfferSuccess = () => ({
type: OFFER_ADD_SUCCESS
})
export const fetchMineOffersSuccess = () => ({
type: OFFERS_SUCCESS
})
export const fetchProfileOffersSuccess = () => ({
type: OFFERS_PROFILE_SUCCESS
})
export const removeOfferSuccess = () => ({
type: OFFER_REMOVE_SUCCESS
})
export const editOfferSuccess = () => ({
type: OFFER_EDIT_SUCCESS
})
export const setOffer = (payload) => ({
type: OFFER_SET,
payload,
});

+ 0
- 5
src/store/actions/products/productsActionConstants.js Näytä tiedosto

@@ -1,5 +0,0 @@
export const LOAD_DATA = 'LOAD_DATA';
export const UPDATE_PAGE = 'UPDATE_PAGE';
export const UPDATE_ITEMS_PER_PAGE = 'UPDATE_ITEMS_PER_PAGE';
export const UPDATE_FILTER = 'UPDATE_FILTER';
export const UPDATE_SORT = 'UPDATE_SORT';

+ 0
- 32
src/store/actions/products/productsActions.js Näytä tiedosto

@@ -1,32 +0,0 @@
import {
LOAD_DATA,
UPDATE_PAGE,
UPDATE_ITEMS_PER_PAGE,
UPDATE_FILTER,
UPDATE_SORT
} from './randomDataActionConstants';

export const loadData = (payload) => ({
type: LOAD_DATA,
payload,
});

export const updatePage = (payload) => ({
type: UPDATE_PAGE,
payload,
});

export const updateItemsPerPage = (payload) => ({
type: UPDATE_ITEMS_PER_PAGE,
payload,
});

export const updateFilter = (payload) => ({
type: UPDATE_FILTER,
payload,
})

export const updateSort = (payload) => ({
type: UPDATE_SORT,
payload,
})

+ 9
- 6
src/store/actions/profile/profileActionConstants.js Näytä tiedosto

@@ -1,8 +1,9 @@
import {
createClearType,
createErrorType,
createFetchType,
createSetType,
createSuccessType,
createUpdateType,
} from "../actionHelpers";

const PROFILE_SCOPE = "PROFILE_SCOPE";
@@ -13,12 +14,14 @@ export const PROFILE_ERROR = createErrorType(PROFILE_SCOPE);
const PROFILE_MINE_SCOPE = "PROFILE_MINE_SCOPE";
export const PROFILE_MINE_FETCH = createFetchType(PROFILE_MINE_SCOPE);
export const PROFILE_MINE_FETCH_SUCCESS = createSuccessType(PROFILE_MINE_SCOPE);
export const PROFILE_MINE_FETCH_ERROR = createErrorType(PROFILE_MINE_SCOPE);

export const PROFILE_SET = "PROFILE_SET";
export const PROFILE_MINE_SET = "PROFILE_MINE_SET";
export const PROFILE_SET = createSetType("PROFILE_SET");
export const PROFILE_MINE_SET = createSetType("PROFILE_MINE_SET");

const PROFILE_EDIT_SCOPE = "PROFILE_EDIT_SCOPE";
export const PROFILE_EDIT = createUpdateType(PROFILE_EDIT_SCOPE);
export const PROFILE_EDIT_SUCCESS = createFetchType(PROFILE_EDIT_SCOPE)
export const PROFILE_EDIT = createFetchType(PROFILE_EDIT_SCOPE);
export const PROFILE_EDIT_SUCCESS = createSuccessType(PROFILE_EDIT_SCOPE)
export const PROFILE_EDIT_ERROR = createErrorType(PROFILE_EDIT_SCOPE);

export const PROFILE_CLEAR = "PROFILE_CLEAR";
export const PROFILE_CLEAR = createClearType("PROFILE_CLEAR");

+ 28
- 18
src/store/actions/profile/profileActions.js Näytä tiedosto

@@ -1,5 +1,6 @@
import {
PROFILE_CLEAR, PROFILE_ERROR,
PROFILE_CLEAR,
PROFILE_ERROR,
PROFILE_FETCH,
PROFILE_MINE_FETCH,
PROFILE_MINE_SET,
@@ -8,6 +9,8 @@ import {
PROFILE_EDIT,
PROFILE_MINE_FETCH_SUCCESS,
PROFILE_EDIT_SUCCESS,
PROFILE_MINE_FETCH_ERROR,
PROFILE_EDIT_ERROR,
} from "./profileActionConstants";

export const fetchProfile = (payload) => ({
@@ -18,33 +21,40 @@ export const fetchProfileSuccess = (payload) => ({
type: PROFILE_SUCCESS,
payload,
});

export const fetchErrorProfile = (payload) => ({
type: PROFILE_ERROR,
payload,
});
export const setProfile = (payload) => ({
type: PROFILE_SET,
payload,
});
export const setMineProfile = (payload) => ({
type: PROFILE_MINE_SET,
payload,
});

export const fetchMineProfile = () => ({
type: PROFILE_MINE_FETCH,
});
export const fetchMineProfileSuccess = () => ({
type: PROFILE_MINE_FETCH_SUCCESS,
});
export const fetcHMineProfileError = () => ({
type: PROFILE_MINE_FETCH_ERROR,
});

export const editMineProfile = (payload) => ({
type: PROFILE_EDIT,
payload,
});
export const editMineProfileSuccess = () => ({
type: PROFILE_EDIT_SUCCESS,
});
export const editMineProfileError = () => ({
type: PROFILE_EDIT_ERROR,
});

export const clearProfile = () => ({
type: PROFILE_CLEAR
})
export const fetchMineProfileSuccess = () => ({
type: PROFILE_MINE_FETCH_SUCCESS
})
export const editMineProfileSuccess = () => ({
type: PROFILE_EDIT_SUCCESS
})
type: PROFILE_CLEAR,
});
export const setProfile = (payload) => ({
type: PROFILE_SET,
payload,
});
export const setMineProfile = (payload) => ({
type: PROFILE_MINE_SET,
payload,
});

+ 4
- 2
src/store/actions/queryString/queryStringActionConstants.js Näytä tiedosto

@@ -1,2 +1,4 @@
export const QUERY_STRING_SET = "QUERY_STRING_SET";
export const QUERY_STRING_SET_REDUX = "QUERY_STRING_SET_REDUX";
import { createSetType } from "../actionHelpers";

export const QUERY_STRING_SET = createSetType("QUERY_STRING_SET");
export const QUERY_STRING_SET_REDUX = createSetType("QUERY_STRING_SET_REDUX");

+ 0
- 5
src/store/actions/randomData/randomDataActionConstants.js Näytä tiedosto

@@ -1,5 +0,0 @@
export const LOAD_DATA = 'LOAD_DATA';
export const UPDATE_PAGE = 'UPDATE_PAGE';
export const UPDATE_ITEMS_PER_PAGE = 'UPDATE_ITEMS_PER_PAGE';
export const UPDATE_FILTER = 'UPDATE_FILTER';
export const UPDATE_SORT = 'UPDATE_SORT';

+ 0
- 32
src/store/actions/randomData/randomDataActions.js Näytä tiedosto

@@ -1,32 +0,0 @@
import {
LOAD_DATA,
UPDATE_PAGE,
UPDATE_ITEMS_PER_PAGE,
UPDATE_FILTER,
UPDATE_SORT
} from './randomDataActionConstants';

export const loadData = (payload) => ({
type: LOAD_DATA,
payload,
});

export const updatePage = (payload) => ({
type: UPDATE_PAGE,
payload,
});

export const updateItemsPerPage = (payload) => ({
type: UPDATE_ITEMS_PER_PAGE,
payload,
});

export const updateFilter = (payload) => ({
type: UPDATE_FILTER,
payload,
})

export const updateSort = (payload) => ({
type: UPDATE_SORT,
payload,
})

+ 9
- 2
src/store/actions/register/registerActionConstants.js Näytä tiedosto

@@ -1,4 +1,11 @@
import { createFetchType } from "../actionHelpers";
import {
createErrorType,
createFetchType,
createSuccessType,
} from "../actionHelpers";

const REGISTER_USER_SCOPE = "REGISTER_USER";
export const REGISTER_USER_FETCH = createFetchType(REGISTER_USER_SCOPE);
export const REGISTER_USER_FETCH = createFetchType(REGISTER_USER_SCOPE);
export const REGISTER_USER_FETCH_ERROR = createErrorType(REGISTER_USER_SCOPE);
export const REGISTER_USER_FETCH_SUCCESS =
createSuccessType(REGISTER_USER_SCOPE);

+ 7
- 1
src/store/actions/register/registerActions.js Näytä tiedosto

@@ -1,6 +1,12 @@
import { REGISTER_USER_FETCH } from "./registerActionConstants";
import { REGISTER_USER_FETCH, REGISTER_USER_FETCH_ERROR, REGISTER_USER_FETCH_SUCCESS } from "./registerActionConstants";

export const fetchRegisterUser = (payload) => ({
type: REGISTER_USER_FETCH,
payload
})
export const fetchRegisterUserSuccess = () => ({
type: REGISTER_USER_FETCH_SUCCESS
})
export const fetchRegisterUserError = () => ({
type: REGISTER_USER_FETCH_ERROR
})

+ 8
- 4
src/store/actions/review/reviewActionConstants.js Näytä tiedosto

@@ -1,9 +1,13 @@
import { createFetchType } from "../actionHelpers";
import { createErrorType, createFetchType, createSetType, createSuccessType } from "../actionHelpers";

const REVIEW_GIVE_SCOPE = "REVIEW_GIVE_SCOPE";
const REVIEW_GET_SCOPE = "REVIEW_GET_SCOPE";

export const REVIEW_GIVE = createFetchType(REVIEW_GIVE_SCOPE);
export const REVIEW_GIVE_SUCCESS = createSuccessType(REVIEW_GIVE_SCOPE);
export const REVIEW_GIVE_ERROR = createErrorType(REVIEW_GIVE_SCOPE);

const REVIEW_GET_SCOPE = "REVIEW_GET_SCOPE";
export const REVIEW_GET = createFetchType(REVIEW_GET_SCOPE);
export const REVIEW_GET_SUCCESS = createSuccessType(REVIEW_GET_SCOPE);
export const REVIEW_GET_ERROR = createErrorType(REVIEW_GET_SCOPE);

export const REVIEW_SET = "REVIEW_SET";
export const REVIEW_SET = createSetType("REVIEW_SET");

+ 13
- 1
src/store/actions/review/reviewActions.js Näytä tiedosto

@@ -1,13 +1,25 @@
import { REVIEW_GET, REVIEW_GIVE, REVIEW_SET } from "./reviewActionConstants";
import { REVIEW_GET, REVIEW_GET_ERROR, REVIEW_GET_SUCCESS, REVIEW_GIVE, REVIEW_GIVE_ERROR, REVIEW_GIVE_SUCCESS, REVIEW_SET } from "./reviewActionConstants";

export const fetchReviews = (payload) => ({
type: REVIEW_GET,
payload,
})
export const fetchReviewsSuccess = () => ({
type: REVIEW_GET_SUCCESS
})
export const fetchReviewsError = () => ({
type: REVIEW_GET_ERROR
})
export const giveReview = (payload) => ({
type: REVIEW_GIVE,
payload,
})
export const giveReviewSuccess = () => ({
type: REVIEW_GIVE_SUCCESS
})
export const giveReviewError = () => ({
type: REVIEW_GIVE_ERROR
})
export const setReviews = (payload) => ({
type: REVIEW_SET,
payload,

+ 16
- 6
src/store/actions/user/userActionConstants.js Näytä tiedosto

@@ -1,7 +1,17 @@
import { createErrorType, createFetchType, createSetType, createSuccessType } from "../actionHelpers";

export const SET_USER = 'SET_USER';
export const SET_USER_ERROR = 'SET_USER_ERROR';
export const FORGOT_PASSWORD = "FORGOT_PASSWORD";
export const RESET_PASSWORD = "RESET_PASSWORD";
export const SET_USER_ACCESS_TOKEN = "SET_USER_ACCESS_TOKEN";
export const SET_USER_REFRESH_TOKEN = "SET_USER_REFRESH_TOKEN";

const FORGOT_PASSWORD_SCOPE = "FORGOT_PASSWORD"
export const FORGOT_PASSWORD = createFetchType(FORGOT_PASSWORD_SCOPE);
export const FORGOT_PASSWORD_SUCCESS = createSuccessType(FORGOT_PASSWORD_SCOPE);
export const FORGOT_PASSWORD_ERROR = createErrorType(FORGOT_PASSWORD_SCOPE);

const RESET_PASSWORD_SCOPE = "RESET_PASSWORD";
export const RESET_PASSWORD = createFetchType(RESET_PASSWORD_SCOPE);
export const RESET_PASSWORD_SUCCESS = createSuccessType(RESET_PASSWORD_SCOPE);
export const RESET_PASSWORD_ERROR = createErrorType(RESET_PASSWORD_SCOPE);

export const SET_USER_ACCESS_TOKEN = createSetType("SET_USER_ACCESS_TOKEN");
export const SET_USER_REFRESH_TOKEN = createSetType("SET_USER_REFRESH_TOKEN");
export const SET_USER = createSetType('SET_USER');
export const SET_USER_ERROR = createSetType('SET_USER_ERROR');

+ 33
- 15
src/store/actions/user/userActions.js Näytä tiedosto

@@ -1,34 +1,52 @@
import {
FORGOT_PASSWORD,
FORGOT_PASSWORD_ERROR,
FORGOT_PASSWORD_SUCCESS,
RESET_PASSWORD,
RESET_PASSWORD_ERROR,
RESET_PASSWORD_SUCCESS,
SET_USER,
SET_USER_ACCESS_TOKEN,
SET_USER_ERROR,
SET_USER_REFRESH_TOKEN,
} from './userActionConstants';
} from "./userActionConstants";

export const setUser = (payload) => ({
type: SET_USER,
export const forgotPassword = (payload) => ({
type: FORGOT_PASSWORD,
payload,
});
export const forgotPasswordSuccess = () => ({
type: FORGOT_PASSWORD_SUCCESS
})
export const forgotPasswordError = () => ({
type: FORGOT_PASSWORD_ERROR
})

export const setUserError = (payload) => ({
type: SET_USER_ERROR,
export const resetPassword = (payload) => ({
type: RESET_PASSWORD,
payload,
});
export const forgotPassword = (payload) => ({
type: FORGOT_PASSWORD,
payload
export const resetPasswordSuccess = () => ({
type: RESET_PASSWORD_SUCCESS
})
export const resetPassword = (payload) => ({
type: RESET_PASSWORD,
payload
export const resetPasswordError = () => ({
type: RESET_PASSWORD_ERROR
})

export const setUserAccessToken = (payload) => ({
type: SET_USER_ACCESS_TOKEN,
payload
})
payload,
});
export const setUserRefreshToken = (payload) => ({
type: SET_USER_REFRESH_TOKEN,
payload
})
payload,
});
export const setUser = (payload) => ({
type: SET_USER,
payload,
});

export const setUserError = (payload) => ({
type: SET_USER_ERROR,
payload,
});

+ 0
- 18
src/store/reducers/index.js Näytä tiedosto

@@ -2,7 +2,6 @@ import { combineReducers } from "redux";
import loginReducer from "./login/loginReducer";
import loadingReducer from "./loading/loadingReducer";
import userReducer from "./user/userReducer";
import randomDataReducer from "./randomData/randomDataReducer";
import storage from "redux-persist/lib/storage";
import createFilter from "redux-persist-transform-filter";
import persistReducer from "redux-persist/es/persistReducer";
@@ -28,22 +27,6 @@ const userPersistConfig = {
transform: [createFilter("user", ["user"])],
};

const randomDataPersistConfig = {
key: "randomData",
storage: storage,
transform: [
createFilter("randomData", [
"items",
"filteredItems",
"count",
"page",
"itemsPerPage",
"filter",
"sort",
]),
],
};

const categoriesPersistConfig = {
key: "categories",
storage: storage,
@@ -71,7 +54,6 @@ export default combineReducers({
user: persistReducer(userPersistConfig, userReducer),
loading: loadingReducer,
filters: filtersReducer,
randomData: persistReducer(randomDataPersistConfig, randomDataReducer),
offers: offersReducer,
categories: persistReducer(categoriesPersistConfig, categoriesReducer),
locations: persistReducer(locationsPersistConfig, locationsReducer),

+ 1
- 1
src/store/reducers/loading/loadingReducer.js Näytä tiedosto

@@ -17,7 +17,7 @@ export default createReducer(
);

function addLoader(state, action) {
console.log("ADD", "state: ", state, "action: ", action);
// console.log("ADD", "state: ", state, "action: ", action);
let loaderCount = state.loaderCount;
let actionType = action.payload.replace("[FETCH]", "");
if (!state[actionType]) {

+ 0
- 0
src/store/reducers/products/productsReducer.js Näytä tiedosto


+ 0
- 103
src/store/reducers/randomData/randomDataReducer.js Näytä tiedosto

@@ -1,103 +0,0 @@
import createReducer from '../../utils/createReducer';
import {
LOAD_DATA,
UPDATE_PAGE,
UPDATE_ITEMS_PER_PAGE,
UPDATE_FILTER,
UPDATE_SORT,
} from '../../actions/randomData/randomDataActionConstants.js';
import generate from '../../../util/helpers/randomData';

const initialState = {
items: [],
filteredItems: [],
count: 0,
page: 0,
itemsPerPage: 12,
filter: '',
sort: '',
};

export default createReducer(
{
[LOAD_DATA]: loadRandomData,
[UPDATE_PAGE]: updatePage,
[UPDATE_ITEMS_PER_PAGE]: updateItemsPerPage,
[UPDATE_FILTER]: updateFilter,
[UPDATE_SORT]: updateSort,
},
initialState
);

function loadRandomData(state, action) {
const count = action.payload;
const items = generate(count);

return {
...state,
items,
filteredItems: items,
count: items.length,
};
}

function updatePage(state, action) {
const page = action.payload;

return {
...state,
page,
};
}

function updateItemsPerPage(state, action) {
const itemsPerPage = action.payload;

return {
...state,
itemsPerPage,
};
}

function updateFilter(state, action) {
const filter = action.payload;
const filteredItems = filter
? state.items.filter((item) => item.name.toLowerCase().includes(filter.toLowerCase())) : state.items;

return {
...state,
filter,
filteredItems,
count: filteredItems.length,
};
}

function updateSort(state, action) {
const sort = action.payload;
const [field, direction] = sort.split('-');

const sortDirection = direction === 'asc' ? 1 : -1;
const dataItems = state.filteredItems.length
? state.filteredItems
: state.items;

const sorted = dataItems.sort((a, b) => {
if (a[field] > b[field]) {
return sortDirection;
}
if (b[field] > a[field]) {
return sortDirection * -1;
}
return 0;
});

const filteredItems = state.filteredItems.length
? sorted
: state.filteredItems;

return {
...state,
sort,
filteredItems,
};
}

+ 3
- 2
src/store/saga/categoriesSaga.js Näytä tiedosto

@@ -1,7 +1,7 @@
import { all, call, put, takeLatest } from "@redux-saga/core/effects";
import { attemptFetchCategories } from "../../request/categoriesRequest";
import { CATEGORIES_FETCH } from "../actions/categories/categoriesActionConstants";
import { fetchCategoriesSuccess, setCategories } from "../actions/categories/categoriesActions";
import { fetchCategoriesError, fetchCategoriesSuccess, setCategories } from "../actions/categories/categoriesActions";

function* fetchCategories() {
try {
@@ -9,7 +9,8 @@ function* fetchCategories() {
yield put(setCategories(data));
yield put(fetchCategoriesSuccess());
} catch(e) {
console.log(e)
yield put(fetchCategoriesError());
console.log(e);
}
}


+ 6
- 5
src/store/saga/chatSaga.js Näytä tiedosto

@@ -14,7 +14,7 @@ import {
CHAT_ONE_FETCH,
CHAT_SEND_FETCH,
} from "../actions/chat/chatActionConstants";
import { fetchChatsSuccess, fetchHeaderChatsSuccess, fetchOneChatSuccess, sendMessageSuccess, setChats, setOneChat, startNewChatSuccess } from "../actions/chat/chatActions";
import { fetchChatsError, fetchChatsSuccess, fetchHeaderChatsError, fetchHeaderChatsSuccess, fetchOneChatError, fetchOneChatSuccess, sendMessageError, sendMessageSuccess, setChats, setOneChat, startNewChatError, startNewChatSuccess } from "../actions/chat/chatActions";
import { validateExchange } from "../actions/exchange/exchangeActions";
import { selectSelectedChat } from "../selectors/chatSelectors";
import { selectExchange } from "../selectors/exchangeSelector";
@@ -27,6 +27,7 @@ function* fetchChats() {
yield put(setChats([...data.data]));
yield put(fetchChatsSuccess());
} catch (e) {
yield put(fetchChatsError());
console.log(e);
}
}
@@ -38,14 +39,13 @@ function* fetchHeaderChats() {
yield put(setChats([...data.data]));
yield put(fetchHeaderChatsSuccess());
} catch (e) {
yield put(fetchHeaderChatsError());
console.log(e);
}
}
function* fetchOneChat(payload) {
try {
console.log(payload.payload);
const chatData = yield call(attemptFetchOneChat, payload.payload);
console.log(chatData.data.chat.offerId);
const offerData = yield call(
attemptFetchOneOffer,
chatData.data.chat.offerId
@@ -58,6 +58,7 @@ function* fetchOneChat(payload) {
yield put(setOneChat(chat));
yield put(fetchOneChatSuccess());
} catch (e) {
yield put(fetchOneChatError());
console.log(e);
}
}
@@ -80,17 +81,16 @@ function* sendMessage(payload) {
yield call(payload.payload.handleApiResponseSuccess);
}
} catch (e) {
yield put(sendMessageError());
console.log(e);
}
}
function* startNewChat(payload) {
try {
yield call(console.log, payload);
const newChatData = yield call(
attemptCreateNewChat,
payload.payload.offerId
);
yield call(console.log, newChatData);
const newChatId = newChatData.data.chatId;
const messageObject = {
text: payload.payload.message,
@@ -101,6 +101,7 @@ function* startNewChat(payload) {
yield call(payload.payload.handleMessageSendSuccess, newChatId);
}
} catch (e) {
yield put(startNewChatError());
console.log(e);
}
}

+ 4
- 1
src/store/saga/counterSaga.js Näytä tiedosto

@@ -1,11 +1,14 @@
import { all, takeLatest, call } from "@redux-saga/core/effects";
import { all, takeLatest, call, put } from "@redux-saga/core/effects";
import { attemptIncreaseCounter } from "../../request/counterRequest";
import { COUNTER_INCREASE } from "../actions/counter/counterActionConstants";
import { increaseCounterError, increaseCounterSuccess } from "../actions/counter/counterActions";

function* increaseCounter(payload) {
try {
yield call(attemptIncreaseCounter, payload.payload);
yield put(increaseCounterSuccess());
} catch(e) {
yield put(increaseCounterError());
console.log(e);
}
}

+ 5
- 1
src/store/saga/exchangeSaga.js Näytä tiedosto

@@ -1,14 +1,16 @@
import { all, takeLatest, call, put } from "@redux-saga/core/effects";
import { attemptFetchExchange, attemptValidateExchange } from "../../request/exchangeRequest";
import { EXCHANGE_FETCH, EXCHANGE_VALIDATE_FETCH } from "../actions/exchange/exchangeActionConstants";
import { setExchange } from "../actions/exchange/exchangeActions";
import { fetchExchangeError, fetchExchangeSuccess, setExchange, validateExchangeError, validateExchangeSuccess } from "../actions/exchange/exchangeActions";

function* fetchExchange(payload) {
try {
const data = yield call(attemptFetchExchange, payload.payload);
yield put(setExchange(data.data));
yield put(fetchExchangeSuccess());
}
catch (e) {
yield put(fetchExchangeError());
console.log(e);
}
}
@@ -18,8 +20,10 @@ function* validateExchange(payload) {
yield call(attemptValidateExchange, payload.payload);
const data = yield call(attemptFetchExchange, payload.payload);
yield put(setExchange(data.data));
yield put(validateExchangeSuccess());
}
catch(e) {
yield put(validateExchangeError());
console.log(e);
}
}

+ 4
- 2
src/store/saga/forgotPasswordSaga.js Näytä tiedosto

@@ -1,12 +1,13 @@
import { all, takeLatest, call } from "@redux-saga/core/effects";
import { all, takeLatest, call, put } from "@redux-saga/core/effects";
import { forgotPasswordRequest, resetPasswordRequest } from "../../request/forgotPasswordRequest";
import { FORGOT_PASSWORD, RESET_PASSWORD } from "../actions/user/userActionConstants";
import { forgotPasswordError, forgotPasswordSuccess } from "../actions/user/userActions";

function* forgotPassword({payload}) {
try {
const data = yield call(forgotPasswordRequest, payload.email);
console.log(data);
if (data) {
yield put(forgotPasswordSuccess());
if (payload.handleResponseSuccess) {
yield call(payload.handleResponseSuccess);
}
@@ -17,6 +18,7 @@ function* forgotPassword({payload}) {
if (payload.handleResponseError) {
yield call(payload.handleResponseError);
}
yield put(forgotPasswordError());
}
}
function* resetPassword({payload}) {

+ 12
- 6
src/store/saga/locationsSaga.js Näytä tiedosto

@@ -1,16 +1,22 @@
import { all, call, put, takeLatest } from "@redux-saga/core/effects";
import { attemptFetchLocations } from "../../request/locationsRequest";
import { LOCATIONS_FETCH } from "../actions/locations/locationsActionConstants";
import { fetchLocationsSuccess, setLocations } from "../actions/locations/locationsActions";
import {
fetchLocationsError,
fetchLocationsSuccess,
setLocations,
} from "../actions/locations/locationsActions";

function* fetchLocations() {
const {data} = yield call(attemptFetchLocations)
try {
const { data } = yield call(attemptFetchLocations);
yield put(setLocations(data));
yield put(fetchLocationsSuccess());
} catch (e) {
yield put(fetchLocationsError());
}
}

export default function* locationsSaga() {
yield all([
takeLatest(LOCATIONS_FETCH, fetchLocations)
])
}
yield all([takeLatest(LOCATIONS_FETCH, fetchLocations)]);
}

+ 1
- 4
src/store/saga/loginSaga.js Näytä tiedosto

@@ -39,7 +39,6 @@ import { clearChat } from "../actions/chat/chatActions";

function* fetchLogin({ payload }) {
try {
console.log('barem ide')
const { data } = yield call(attemptLogin, payload);
if (data.token) {
const token = data.token;
@@ -58,9 +57,9 @@ function* fetchLogin({ payload }) {
yield call(authScopeSetHelper, JWT_TOKEN, token);
yield call(authScopeSetHelper, JWT_REFRESH_TOKEN, refresh);
yield call(addHeaderToken, token);
yield put(fetchUserSuccess({JwtToken: accessToken, RefreshToken: refreshToken, userId}));
const profileData = yield call(attemptFetchProfile, userId);
if (profileData) yield put(setMineProfile(profileData.data));
yield put(fetchUserSuccess({JwtToken: accessToken, RefreshToken: refreshToken, userId}));
if (payload.handleApiResponseSuccess) {
yield call(payload.handleApiResponseSuccess);
}
@@ -106,7 +105,6 @@ function* logout(payload) {
try {
const JwtToken = yield call(authScopeStringGetHelper, JWT_TOKEN);
const user = yield call(jwt.decode, JwtToken);
console.log(payload);
if (user) {
const requestBody = {token: JwtToken}
yield call(logoutUserRequest, requestBody);
@@ -115,7 +113,6 @@ function* logout(payload) {
} catch (error) {
console.log(error); // eslint-disable-line
} finally {
console.log('ovde');
yield call(authScopeClearHelper);
yield call(removeHeaderToken);
yield put(resetLoginState());

+ 23
- 9
src/store/saga/offersSaga.js Näytä tiedosto

@@ -17,11 +17,21 @@ import {
setOffers,
setProfileOffers,
fetchOneOfferSuccess,
createOfferSuccess,
addOfferSuccess,
fetchMineOffersSuccess,
fetchProfileOffersSuccess,
removeOfferSuccess,
editOfferSuccess,
fetchOffersSuccess,
fetchOffersError,
fetchMoreOffersSuccess,
fetchMoreOffersError,
addOfferError,
fetchOneOfferError,
fetchMineOffersError,
fetchProfileOffersError,
removeOfferError,
editOfferError,
} from "../actions/offers/offersActions";
import { all, takeLatest, call, put, select } from "@redux-saga/core/effects";
import {
@@ -65,7 +75,9 @@ function* fetchOffers(payload) {
yield put(setTotalOffers(data.data.total));
yield put(setOffers(data.data.items.regularOffers));
yield put(setPinnedOffers(data.data.items.pinnedOffers));
yield put(fetchOffersSuccess());
} catch (e) {
yield put(fetchOffersError());
yield call(console.log, e);
}
}
@@ -96,35 +108,36 @@ function* fetchMoreOffers(payload) {
) {
yield put(setNoMoreOffersStatus(true));
}
yield put(fetchMoreOffersSuccess());
} catch (e) {
yield put(fetchMoreOffersError());
console.log(e);
}
}

function* createOffer(payload) {
try {
const data = yield call(attemptAddOffer, payload.payload.values.offerData);
console.log(data);
yield put(createOfferSuccess());
yield call(attemptAddOffer, payload.payload.values.offerData);
yield put(addOfferSuccess());
if (payload.payload.handleApiResponseSuccess) {
yield call(payload.payload.handleApiResponseSuccess);
}
} catch (e) {
yield put(addOfferError());
console.log(e);
}
}

function* fetchOneOffer(payload) {
try {
console.log(payload);
const data = yield call(attemptFetchOneOffer, payload.payload)
console.log(data.data);
yield put(fetchOneOfferSuccess(data.data));
} catch (e) {
console.log(e.response.status);
if (e.response.status === 400) {
yield call(history.push, NOT_FOUND_PAGE);
}
yield put(fetchOneOfferError());
}
}

@@ -136,6 +149,7 @@ function* fetchMineOffers() {
yield put(setMineOffers(data.data));
yield put(fetchMineOffersSuccess());
} catch (e) {
yield put(fetchMineOffersError());
console.log(e);
}
}
@@ -152,11 +166,11 @@ function* fetchProfileOffers(payload) {
if (e.response.status === 400) {
yield call(history.push, NOT_FOUND_PAGE);
}
yield put(fetchProfileOffersError());
}
}

function* removeOffer(payload) {
console.log(payload);
try {
const offerId = payload.payload.offerId;
yield call(attemptRemoveOffer, offerId);
@@ -165,13 +179,12 @@ function* removeOffer(payload) {
yield call(payload.payload.handleApiResponseSuccess);
}
} catch (e) {
yield put(removeOfferError());
console.log(e);
}
}

function* editOffer(payload) {
yield console.log(payload);

try {
const offerId = payload.payload.offerId;
const editedData = payload.payload.offerData;
@@ -181,6 +194,7 @@ function* editOffer(payload) {
yield call(payload.payload.handleApiResponseSuccess);
}
} catch (e) {
yield put(editOfferError());
console.log(e);
}
}

+ 8
- 8
src/store/saga/profileSaga.js Näytä tiedosto

@@ -9,7 +9,10 @@ import {
PROFILE_EDIT,
} from "../actions/profile/profileActionConstants";
import {
editMineProfileError,
editMineProfileSuccess,
fetchErrorProfile,
fetcHMineProfileError,
fetchMineProfileSuccess,
fetchProfileSuccess,
// editMineProfile,
@@ -20,12 +23,11 @@ import { selectUserId } from "../selectors/loginSelectors";

function* fetchProfile(payload) {
try {
console.log(payload);
const data = yield call(attemptFetchProfile, payload.payload);
console.log(data.data);
if (data) yield put(setProfile(data.data));
yield put(fetchProfileSuccess())
yield put(fetchProfileSuccess());
} catch (e) {
yield put(fetchErrorProfile());
console.log(e);
}
}
@@ -34,20 +36,17 @@ function* fetchMineProfile() {
try {
const userId = yield select(selectUserId);
const data = yield call(attemptFetchProfile, userId);
console.log(data);
if (data) yield put(setMineProfile(data.data));
yield put(fetchMineProfileSuccess())
yield put(fetchMineProfileSuccess());
} catch (e) {
yield put(fetcHMineProfileError());
console.log(e);
}
}

function* changeMineProfile(payload) {
try {
yield console.log(payload);

let image;

if (payload.payload.firmLogo.includes("data:image")) {
image = payload.payload.firmLogo
.replace("data:image/jpeg;base64,", "")
@@ -80,6 +79,7 @@ function* changeMineProfile(payload) {
}
console.log(data);
} catch (e) {
yield put(editMineProfileError());
console.log(e);
}
}

+ 1
- 3
src/store/saga/queryStringSaga.js Näytä tiedosto

@@ -7,8 +7,6 @@ import { setQueryStringRedux } from "../actions/queryString/queryStringActions";

function* setQueryString(payload) {
try {
console.log("trenutni queryString: ", payload.payload);
console.log(payload);
// const currentQS = yield select(selectQueryString);
// let newQueryString = payload.payload
// if (currentQS?.length > 0) {
@@ -18,7 +16,7 @@ function* setQueryString(payload) {
// payload.payload,
// );
// }
const newQueryString = convertQueryStringBackend(payload.payload)
const newQueryString = convertQueryStringBackend(payload.payload);
yield put(setQueryStringRedux(newQueryString));
} catch (e) {
console.log(e);

+ 7
- 0
src/store/saga/registerSaga.js Näytä tiedosto

@@ -1,6 +1,11 @@
import { all, takeLatest, call } from "@redux-saga/core/effects";
import { putRequest } from "../../request";
import { attemptRegister } from "../../request/registerRequest";
import { REGISTER_USER_FETCH } from "../actions/register/registerActionConstants";
import {
fetchRegisterUserError,
fetchRegisterUserSuccess,
} from "../actions/register/registerActions";

function* fetchRegisterUser({ payload }) {
try {
@@ -31,6 +36,7 @@ function* fetchRegisterUser({ payload }) {
if (payload.handleResponseSuccess) {
yield call(payload.handleResponseSuccess);
}
yield putRequest(fetchRegisterUserSuccess());
} catch (e) {
let type;
if (
@@ -50,6 +56,7 @@ function* fetchRegisterUser({ payload }) {
if (payload.handleResponseError) {
yield call(payload.handleResponseError, error);
}
yield putRequest(fetchRegisterUserError());
}
}


+ 37
- 25
src/store/saga/reviewSaga.js Näytä tiedosto

@@ -1,35 +1,47 @@
import { all, takeLatest, call, put } from "@redux-saga/core/effects";
import { attemptFetchReview, attemptGiveReview } from "../../request/reviewRequest";
import { REVIEW_GET, REVIEW_GIVE } from "../actions/review/reviewActionConstants";
import { setReviews } from "../actions/review/reviewActions";
import {
attemptFetchReview,
attemptGiveReview,
} from "../../request/reviewRequest";
import {
REVIEW_GET,
REVIEW_GIVE,
} from "../actions/review/reviewActionConstants";
import {
fetchReviewsError,
fetchReviewsSuccess,
giveReviewError,
giveReviewSuccess,
setReviews,
} from "../actions/review/reviewActions";

function* fetchReviews(payload) {
try {
yield call(console.log, payload);
const data = yield call(attemptFetchReview, payload.payload);
yield put(setReviews([...data.data].reverse()));
yield call(console.log, data);
}
catch(e) {
console.log(e);
}
try {
const data = yield call(attemptFetchReview, payload.payload);
yield put(setReviews([...data.data].reverse()));
yield put(fetchReviewsSuccess());
} catch (e) {
yield put(fetchReviewsError());
console.log(e);
}
}

function* giveReview(payload) {
try {
const data = yield call(attemptGiveReview, payload.payload.review)
console.log(data);
if (payload.payload.handleApiResponseSuccess) {
yield call(payload.payload.handleApiResponseSuccess);
}
} catch(e) {
console.log(e);
try {
yield call(attemptGiveReview, payload.payload.review);
if (payload.payload.handleApiResponseSuccess) {
yield call(payload.payload.handleApiResponseSuccess);
}
yield put(giveReviewSuccess());
} catch (e) {
yield put(giveReviewError());
console.log(e);
}
}

export default function* reviewSaga() {
yield all([
takeLatest(REVIEW_GET, fetchReviews),
takeLatest(REVIEW_GIVE, giveReview)
])
}
yield all([
takeLatest(REVIEW_GET, fetchReviews),
takeLatest(REVIEW_GIVE, giveReview),
]);
}

Loading…
Peruuta
Tallenna