-
Notifications
You must be signed in to change notification settings - Fork 13
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
base: master
Are you sure you want to change the base?
Ht 7 #58
Conversation
# Conflicts: # README.md
@@ -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; |
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я не нашел где используется это екшен
There was a problem hiding this comment.
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 }) => ({ |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
этот state не используется
2+3 пункты, кроме страницы success