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 default values for discount widgets, apply them on dropdown change #2207

Merged
merged 8 commits into from
Jun 21, 2017

Conversation

bagratinho
Copy link
Contributor

No description provided.

@bagratinho
Copy link
Contributor Author

bagratinho commented Jun 20, 2017

Original task is a bit changed, in discussion with @alexanderfc. Instead of preserving modified values for each possible discount field, its just need to reset it to default everytime a user changes offer or qualifier type.

@anru
Copy link
Contributor

anru commented Jun 20, 2017

👀

const setType = (type: any) => {
const defaultDiscountParams = _.find(props.descriptions, (item) => {
if (item.type == type) return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?! I think it can be just return item.type == type or even:

const defaultDiscountParams = _.find(props.descriptions, { type });

if (item.type == type) return true;
});
const key = _.get(defaultDiscountParams, 'content[0].[1].name');
const value = _.get(defaultDiscountParams, 'content[0].[1].value', {});
props.onChange({
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we have to check if type and key are defined. Otherwise we can receive an onChange with {null: {null: smth}} payload.

Copy link
Contributor

Choose a reason for hiding this comment

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

it's totally weird behavior -- using content[0][1] for business logic which aims to be a template. I'll prepare commit soon which fixes it

@anru anru force-pushed the bug/promotions-validation branch from 439f0ea to 34c7599 Compare June 20, 2017 17:55
discountChilds.push(<DiscountAttrs
blockId={'promo-qualifier-block-' + index}
dropdownId={'promo-qualifier-dd-' + index}
const discountChildren = discounts.reduce ((acc, disc, index) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Extra space after reduce, and probably we should use _.reduce?

Copy link
Contributor

Choose a reason for hiding this comment

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

there will be array for sure, so we can use native reduce method then

Copy link
Contributor

Choose a reason for hiding this comment

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

@anru
Copy link
Contributor

anru commented Jun 20, 2017

instead of accessing to concrete item description in content array, I added explicit default property

@bagratinho
Copy link
Contributor Author

Thx Andrey, @alexanderfc while I was testing @anru changes, I saw that promotion object fails to save in several offer types case. E.G. Discounted Shipping, Set Price shiping. Its same on stage.
Could you please review that and create an issue? I would rather say its backend issue, but not sure.

@anru
Copy link
Contributor

anru commented Jun 21, 2017

looks good, except excess value: 0 declarations in qualifiers.js

@bagratinho
Copy link
Contributor Author

fixed

@anru anru merged commit 6c26e0e into master Jun 21, 2017
@anru anru deleted the bug/promotions-validation branch June 21, 2017 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants