Skip to content

Commit

Permalink
Discount catalog with promotion api (#4476)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
poulch committed Dec 18, 2023
1 parent b8303e6 commit fa38078
Show file tree
Hide file tree
Showing 104 changed files with 4,910 additions and 817 deletions.
5 changes: 5 additions & 0 deletions .changeset/eleven-dolls-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Use new promotion API to create and update discounts
2 changes: 1 addition & 1 deletion .changeset/empty-falcons-boil.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
"saleor-dashboard": minor
"saleor-dashboard": patch
---

Introduce intial component for catalog discounts
45 changes: 45 additions & 0 deletions locale/defaultMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,9 @@
"context": "references attribute type",
"string": "References"
},
"5dOOAB": {
"string": "Successfully created discount"
},
"5elC9k": {
"context": "taxes section name",
"string": "Taxes"
Expand Down Expand Up @@ -1327,6 +1330,9 @@
"context": "attribute value deleted",
"string": "Value deleted"
},
"7Hdiw2": {
"string": "Rule name is required"
},
"7J1ZKs": {
"context": "button",
"string": "Back to apps list"
Expand Down Expand Up @@ -1614,6 +1620,9 @@
"context": "cancel button",
"string": "Cancel order"
},
"9d24PR": {
"string": "Create rule"
},
"9eC0MZ": {
"context": "collection",
"string": "Hidden"
Expand Down Expand Up @@ -1677,6 +1686,9 @@
"context": "product discount removed title",
"string": "{productName} discount was removed by"
},
"A7W4KO": {
"string": "Catalog rule"
},
"A9QSur": {
"context": "area units type",
"string": "Area"
Expand Down Expand Up @@ -1815,6 +1827,9 @@
"context": "pint unit",
"string": "pint"
},
"B0fwAj": {
"string": "and {itemsLength} more"
},
"B2LE7A": {
"context": "menu item loading",
"string": "working..."
Expand Down Expand Up @@ -1989,6 +2004,9 @@
"context": "card header title",
"string": "Country list"
},
"CFlmRP": {
"string": "Rule reword value is required"
},
"CG+awx": {
"context": "dialog content",
"string": "Which address would you like to use as shipping address for selected customer:"
Expand Down Expand Up @@ -3175,6 +3193,9 @@
"context": "delete attribute value",
"string": "Are you sure you want to delete \"{name}\" value?"
},
"JyaQcP": {
"string": "Rule reword value must be less than 100"
},
"K+vjtE": {
"string": "Search Variants"
},
Expand Down Expand Up @@ -3491,6 +3512,9 @@
"context": "customers section name",
"string": "Customers"
},
"MdFdbd": {
"string": "Delete rule"
},
"MewrtN": {
"context": "section header",
"string": "Fulfillment"
Expand Down Expand Up @@ -3624,6 +3648,9 @@
"context": "order line discount updated title",
"string": "{productName} discount was updated by"
},
"NgRa6m": {
"string": "Discount of {value} on the purchase of {items} through the {channel}"
},
"NhQboB": {
"context": "dialog header",
"string": "Saleor couldn’t cancel order"
Expand Down Expand Up @@ -5114,6 +5141,9 @@
"context": "section header",
"string": "All Media"
},
"XVuPMw": {
"string": "Are you sure you want to delete this rule?"
},
"XWGZLL": {
"context": "transaction reference subtitle",
"string": "Transaction reference"
Expand Down Expand Up @@ -6174,6 +6204,9 @@
"context": "table head",
"string": "Category Name"
},
"fXdkiI": {
"string": "is"
},
"fbH51z": {
"context": "Amount error message",
"string": "Amount cannot be bigger than max refund"
Expand All @@ -6182,6 +6215,9 @@
"context": "order history message",
"string": "Products were deleted from an order"
},
"fg8dzN": {
"string": "Add condition"
},
"fgHLXc": {
"context": "attribute value",
"string": "Value"
Expand Down Expand Up @@ -8350,6 +8386,9 @@
"v1pNHW": {
"string": "Attribute Class"
},
"v1vJ77": {
"string": "Edit rule"
},
"v2+u4c": {
"context": "card subtitle",
"string": "Assign and sort warehouses that will be used in this channel (warehouses can be assigned in multiple channels)."
Expand Down Expand Up @@ -8526,6 +8565,9 @@
"w6kcxY": {
"string": "What happens if I approve?"
},
"w7jT4W": {
"string": "No channels selected"
},
"w9xgN9": {
"context": "see error log label in notification",
"string": "See error log"
Expand Down Expand Up @@ -8966,6 +9008,9 @@
"context": "attribute type",
"string": "Content Attribute"
},
"zehNKT": {
"string": "Rule has error, open rule to see details"
},
"zf48rQ": {
"context": "sum of captured amount of all transactions",
"string": "Total captured"
Expand Down
28 changes: 22 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@graphiql/plugin-explorer": "^0.1.12",
"@graphiql/react": "^0.15.0",
"@graphiql/toolkit": "^0.8.0",
"@hookform/resolvers": "^3.3.2",
"@material-ui/core": "^4.12.4",
"@material-ui/icons": "^4.11.3",
"@material-ui/lab": "^4.0.0-alpha.61",
Expand Down Expand Up @@ -100,7 +101,8 @@
"tslib": "^2.4.1",
"url-join": "^4.0.1",
"use-react-router": "^1.0.7",
"uuid": "^9.0.1"
"uuid": "^9.0.1",
"zod": "^3.22.4"
},
"devDependencies": {
"@babel/cli": "^7.5.5",
Expand Down
Loading

0 comments on commit fa38078

Please sign in to comment.