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

Discount catalog with promotion api #4476

Merged
merged 121 commits into from
Dec 18, 2023
Merged

Discount catalog with promotion api #4476

merged 121 commits into from
Dec 18, 2023

Conversation

poulch
Copy link
Member

@poulch poulch commented Nov 21, 2023

closes #4232

To switch on/off feature flag, run this code in browser console

localStorage.setItem('FF_discounts_rules', '{"enabled":true,"payload":"default"}')

Screenshots

Pull Request Checklist

  1. This code contains UI changes
  2. All visible strings are translated with proper context including data-formatting
  3. Attributes data-test-id are added for new elements
  4. The changes are tested in Chrome/Firefox/Safari browsers and in light/dark mode
  5. Your code works with the latest stable version of the core
  6. I added changesets file (instructions in contribution guide

Test environment config

API_URI=https://automation-dashboard.staging.saleor.cloud/graphql/
APPS_MARKETPLACE_API_URI=https://apps.staging.saleor.io/api/v2/saleor-apps

Do you want to run more stable tests?

To run all tests, just select the stable checkbox. To speed up tests, increase the number of containers. Tests will be re-run only when the "run e2e" label is added.

  1. stable
  2. app
  3. attribute
  4. category
  5. collection
  6. customer
  7. giftCard
  8. homePage
  9. login
  10. menuNavigation
  11. navigation
  12. orders
  13. pages
  14. payments
  15. permissions
  16. plugins
  17. productType
  18. products
  19. sales
  20. shipping
  21. translations
  22. variants
  23. vouchers

CONTAINERS=2

@github-actions github-actions bot temporarily deployed to pr-4232-discount-catalog-api December 15, 2023 22:12 Destroyed
@github-actions github-actions bot temporarily deployed to storybook pr-4232-discount-catalog-api December 15, 2023 22:12 Destroyed
@github-actions github-actions bot temporarily deployed to storybook pr-4232-discount-catalog-api December 15, 2023 23:47 Destroyed
@github-actions github-actions bot temporarily deployed to pr-4232-discount-catalog-api December 15, 2023 23:47 Destroyed
@github-actions github-actions bot temporarily deployed to storybook pr-4232-discount-catalog-api December 17, 2023 13:33 Destroyed
@github-actions github-actions bot temporarily deployed to pr-4232-discount-catalog-api December 17, 2023 13:33 Destroyed
andrzejewsky
andrzejewsky previously approved these changes Dec 18, 2023
Droniu
Droniu previously approved these changes Dec 18, 2023
Copy link
Member

@Droniu Droniu left a comment

Choose a reason for hiding this comment

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

This PR is enormous, it's really difficult to review this because of the complicated structure. Please make sure to split it into smaller batches next time

condition.type ? typeToFetchMap[condition.type] : undefined
}
isConditionTypeSelected={isConditionTypeSelected}
key={condition.type || conditionIndex}
Copy link
Member

Choose a reason for hiding this comment

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

question if I understand this correctly it's possible to have multiple rule conditions of same types? If so this is gonna result in duplicated keys

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, you can't have multiple rule conditions with same type

src/discounts/views/DiscountDetails/DiscountDetails.tsx Outdated Show resolved Hide resolved
@poulch poulch dismissed stale reviews from Droniu and andrzejewsky via 340e5cf December 18, 2023 12:32
@github-actions github-actions bot temporarily deployed to storybook pr-4232-discount-catalog-api December 18, 2023 12:33 Destroyed
@github-actions github-actions bot temporarily deployed to pr-4232-discount-catalog-api December 18, 2023 12:33 Destroyed
@poulch poulch merged commit a6ee99d into main Dec 18, 2023
17 checks passed
@poulch poulch deleted the 4232-discount-catalog-api branch December 18, 2023 12:51
poulch added a commit that referenced this pull request Dec 19, 2023
* Generate flag

* Init new discounts create and details view

* Update params types

* Discount page components

* Add discount rules and metadata

* Add react-hook-form

* Update types

* Handle form using RHF

* Selecting channel and showing currency code

* Connect rules conditon to rhf

* Rename Inputs to CreateDiscoutFormData

* DiscountDetailsPage and handle submit and edit rule

* Bump macaw ui

* Improve structure and typing

* Add changeset

* Add stories

* Extract messages

* Fix CR comments

* createPromotin mutation and types

* Create promotion and display details

* Fix loading description text

* Fetch condition row

* Handle fetch more and fix fetch with query

* Send coditions during create

* Handle display condition in details

* Refactor create promotion handler

* Fix some types

* Introduct RuleDTO

* Add variant search

* Category type fix

* Fetch condition options labels names

* Add fetch condition option in discount detail

* Handle promotion details update

* Handle submit rules update/create using single button submit

* Fix some ts strict null

* Move condition fetch options to component

* Extract messages

* Add changeset

* Improve condition option fetch

* Fix input bg color on rule and showing when selected channels

* Handle disable state, fix description in rule

* Set percantage reward type when no currency

* Show rule name when rule not collapsed

* Bump macaw ui

* Fix discount switch to use value

* Error handling

* Introduce RuleSummary

* Improve fetch conditions options details

* Remove rules, show rules list summaries

* RuleModal, show rule on create page in modal

* Handle edit/add rule inside modal on details promotion page

* Two column rules grid

* Handle delete rule

* Show text when no channels selected

* Client side rule form validation

* Adjust size of reward

* Introduce rule edit button

* Fix showing ids instead of labels

* Always show reward, handle loading during rule deletion

* Fix ruleRewardValue number, move option fetch higher, fix fetch labels for selected options

* Single channel, fetch option labels when promotion change

* Fetch condition option only when channel

* Improve validation schema

* Name and channel in one row

* Fix rule index conditions, fix hasEndDate checkbox change handling

* Fix clearing conditions on channel change

* Improve rule summary conditions values disply

* Temp fix rule modal overflow

* Fix clear values when change condition type

* Fix tests

* Fix ts errors

* Update tests

* Fix theme colors vars

* Bump macaw version

* DiscountRules tests

* Improve rule summary colors and add button

* Test RuleModal

* Improve summary chips colors

* Fix scroll issue

* Fix multiple conditions

* Restore usePreviousValue

* Improve types

* Update changeset to patch

* Use sparate urls for discounts

* Refactor dto into view models

* Fix tests with empty rule during rule creation

* Form refactor

* Test DiscountRules, update props

* Update index type from string to number

* Validation schema for discount form

* Fix description in init form values

* Update mocks and fixures

* Add mocks to storybook

* Update test

* Update description type

* Add fromFormValues methods to Rule and Conditon

* Fix rule delete and update handlers

* CR fixes

* Fix zod import

* Remove any types

* Fix is translation
@poulch poulch restored the 4232-discount-catalog-api branch July 1, 2024 11:26
@poulch poulch deleted the 4232-discount-catalog-api branch July 1, 2024 11:32
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.

[Feature]: Catalog discounts
3 participants