-
-
Notifications
You must be signed in to change notification settings - Fork 130
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 price override in react delivery form #4860
base: master
Are you sure you want to change the base?
Conversation
```javascript fetch('/api/task?groups=task,address,barcode') .then((response) => response.json()) .then((data) => console.log(data)); ```
…/coopcycle/coopcycle-web into feat/deliveryform-override-price
# Conflicts: # src/Entity/Store.php
20c3ec2
to
3d1d9b4
Compare
d8c6985
to
49efaba
Compare
@@ -107,6 +107,8 @@ const baseURL = location.protocol + '//' + location.host | |||
|
|||
export default function ({ storeId, deliveryId, order }) { | |||
|
|||
console.log(order) |
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.
remove?
// Could not figure out why, but sometimes Formik "re-renders" even if the values are the same. | ||
// so i store a ref to previous values to avoid re-calculating the price. | ||
const previousValues = useRef(initialValues); | ||
if (overridePrice && !values.variantName) { |
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.
@@ -107,6 +107,8 @@ const baseURL = location.protocol + '//' + location.host | |||
|
|||
export default function ({ storeId, deliveryId, order }) { | |||
|
|||
console.log(order) | |||
|
|||
// This variable is used to test the store role and restrictions. We need to have it passed as prop to make it work. | |||
const isAdmin = true |
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.
Better to call isDispatcher
</div> | ||
|
||
<div className='order-informations__complete-order'> | ||
<Button | ||
type="primary" | ||
style={{ height: '2.5em' }} | ||
htmlType="submit" disabled={isSubmitting || deliveryId && isAdmin === false}> | ||
htmlType="submit" | ||
disabled={isSubmitting || deliveryId && isAdmin === false}> |
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.
It should also be disabled when priceLoading
is true, as I understand #4854
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.
👍
Let's maybe put the test for the new form into a separate folder so it's easier to delete old ones later (I'd suggest keeping one test per file so that cypress re-runs only failed tests on retry)
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.
one test per file is easier to manage in cypress yes
@@ -26,7 +33,30 @@ public function __invoke(Delivery $data) | |||
throw new ValidationException($errors); | |||
} | |||
|
|||
$this->pricingManager->createOrder($data); | |||
$useArbitraryPrice = $this->authorizationCheckerInterface->isGranted('ROLE_ADMIN') && $data->hasArbitraryPrice(); |
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.
It should be ROLE_DISPATCHER
'throwException' => false | ||
]); | ||
|
||
} catch (NoRuleMatchedException $e) { |
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.
It's not needed, is it? PricingManager
does not throw an exception when 'throwException' => false
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.
not needed, it is because I switched between true and false
} | ||
|
||
$order = $data->getOrder(); | ||
$useArbitraryPrice = $this->authorizationCheckerInterface->isGranted('ROLE_ADMIN') && $data->hasArbitraryPrice(); |
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.
Same here, it should be ROLE_DISPATCHER
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.
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.
thanks for the catch i ll fix this
#4851
#4848
#4853
#4854
#4856