Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add product to favourites #16

Merged
merged 7 commits into from
Sep 4, 2023
Merged

Add product to favourites #16

merged 7 commits into from
Sep 4, 2023

Conversation

ihorhladkov
Copy link
Contributor

No description provided.

Copy link
Contributor

@MaxSchmide MaxSchmide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also remove unused code instead of pushing comments

}; // See if the product id is in the favoriteItems array

const handleClick = (currentProduct: IProduct) => {
if (hasProductId(currentProduct._id)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use one action, toggleFavorite, where u will check is product in fav by id

Copy link
Contributor

@perfectAcedia perfectAcedia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take a look at my last PR and implement a local storage feature as well.

Comment on lines 11 to 29

// eslint-disable-next-line no-console
// const [products, setProducts] = useState<IProduct[]>([]);
// #endregion

// #region rewrite to RTQ Query
useEffect(() => {
axios
.get('https://dreamteam.onrender.com/products', {
params: { page: 1, perPage: 8 },
})
.then((res) => {
setProducts(res.data.data);
})
.catch((e) => {
throw new Error(e);
});
}, []);
// useEffect(() => {
// axios
// .get('https://dreamteam.onrender.com/products', {
// params: { page: 1, perPage: 8 },
// })
// .then((res) => {
// setProducts(res.data.data);
// })
// .catch((e) => {
// throw new Error(e);
// });
// }, []);
// #endregion
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please delete comments

Comment on lines 1 to 10
import { useEffect } from 'react';
import { getInitialFavourites, useAppDispatch } from '../redux/';

export const useInitFavourites = () => {
const dispatch = useAppDispatch();

useEffect(() => {
dispatch(getInitialFavourites());
}, []);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GJ, but, please, rename file to your hook name

@MaxSchmide MaxSchmide self-requested a review September 4, 2023 20:58
Copy link
Contributor

@MaxSchmide MaxSchmide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@MaxSchmide MaxSchmide merged commit 9677868 into master Sep 4, 2023
1 check passed
@MaxSchmide MaxSchmide deleted the add-card-to-favourites branch September 5, 2023 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants