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

Ht 7 #58

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Ht 7 #58

wants to merge 11 commits into from

Conversation

vlapenkov
Copy link

2+3 пункты, кроме страницы success

@@ -6,7 +6,24 @@ const orderSelector = (state) => state.order;
const productsSelector = (state) => state.products.entities;
const reviewsSelector = (state) => state.reviews.entities;
const usersSelector = (state) => state.users.entities;
const routerSelector = (state) => state.router;
Copy link
Owner

Choose a reason for hiding this comment

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

в connected-react-router есть свои селекторы, которые можно так же использовать

loaded: false,
};

export default (state = initStatus, action) => {
Copy link
Owner

Choose a reason for hiding this comment

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

это все можно было поместить в редьюсер для ордера, который у нас уже есть

const { type, payload } = action;
switch (type) {
case CHANGE_CURRENCY:
if (currencies.some((cur) => cur.id === payload))
Copy link
Owner

Choose a reason for hiding this comment

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

если currencies изначально сделать объектом, а не массивом - будет намного проще

@@ -18,7 +22,9 @@ const Product = ({ product, amount, increment, decrement }) => {
<div>
<h4 className={styles.title}>{product.name}</h4>
<p className={styles.description}>{product.ingredients.join(', ')}</p>
<div className={styles.price}>{product.price} $</div>
<div className={styles.price}>
{product.price} {sign}
Copy link
Owner

Choose a reason for hiding this comment

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

тут цена в долларах, на сколько я понимаю и к ней просто дописывается знак текущей валюты


const initStatus = { ...arrToMap(currencies) }['dollar'];

export default (state = initStatus, action) => {
Copy link
Owner

Choose a reason for hiding this comment

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

это необходимо было сделать на контексте

@@ -11,3 +12,4 @@ export const LOAD_USERS = 'LOAD_USERS';
export const REQUEST = '_REQUEST';
export const SUCCESS = '_SUCCESS';
export const FAILURE = '_FAILURE';
export const CHANGE_CURRENCY = 'CHANGE_CURRENCY';
Copy link
Owner

Choose a reason for hiding this comment

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

я не нашел где используется это екшен

Copy link
Author

Choose a reason for hiding this comment

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

Да времени особенно не было селектор валют прикрутить, и некоторые другие детали,.т.к. работу никто не отменял. Сделал что успел. Можно просто store.dispatch(), так и проверял

<Button
onClick={() =>
createOrder(
orderProducts.map(({ product, amount }) => ({
Copy link
Owner

Choose a reason for hiding this comment

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

Это все должно быть в екшене. Сейчас компонент знает в каком виде нам нужно отправлять данные на апи

});

export const createOrder = (items) => async (dispatch, getState) => {
const state = getState();
Copy link
Owner

Choose a reason for hiding this comment

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

этот state не используется

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.

2 participants