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 price override in react delivery form #4860

Open
wants to merge 54 commits into
base: master
Choose a base branch
from

Conversation

CamilleNerriere
Copy link
Member

@CamilleNerriere CamilleNerriere commented Jan 24, 2025

  • Add override Price and restriction for admin
  • Create a widget to convert price with/without VAT
  • Fix issues with Calculate prices
  • Change range for timeslots in DateRangePicker (10 minutes)
  • Add autofill address if activated
  • Add multidropoff only if activated
  • UX : make all task header clicable to toggle

#4851
#4848
#4853
#4854
#4856

r0xsh and others added 30 commits January 21, 2025 16:12
```javascript
fetch('/api/task?groups=task,address,barcode')
  .then((response) => response.json())
  .then((data) => console.log(data));

```
@Atala Atala requested review from alexsegura and removed request for Atala January 30, 2025 15:36
src/Api/Resource/TaxRate.php Outdated Show resolved Hide resolved
src/Entity/Delivery.php Outdated Show resolved Hide resolved
src/Action/Delivery/Create.php Outdated Show resolved Hide resolved
features/deliveries.feature Outdated Show resolved Hide resolved
features/deliveries.feature Outdated Show resolved Hide resolved
@Atala Atala force-pushed the feat/deliveryform-override-price branch from 20c3ec2 to 3d1d9b4 Compare February 7, 2025 10:10
@Atala Atala force-pushed the feat/deliveryform-override-price branch from d8c6985 to 49efaba Compare February 7, 2025 12:17
@@ -107,6 +107,8 @@ const baseURL = location.protocol + '//' + location.host

export default function ({ storeId, deliveryId, order }) {

console.log(order)
Copy link
Contributor

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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The behaviour in the old form is to allow an empty product name (as a way to remove the custom name and generate a default name). I think it's good to keep that behaviour at least

Screenshot 2025-02-10 at 14 46 36

@@ -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
Copy link
Contributor

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}>
Copy link
Contributor

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

Copy link
Contributor

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)

Copy link
Member

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();
Copy link
Contributor

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) {
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 not needed, is it? PricingManager does not throw an exception when 'throwException' => false

Copy link
Member

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();
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Should it always be excl. VAT and then incl. VAT?

Screenshot 2025-02-10 at 15 38 46

Copy link
Contributor

Choose a reason for hiding this comment

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

I have an issue when I select Pre-fill automatically pickup address. It pre-fills the same address in both pickup and dropoff:

Screenshot 2025-02-10 at 15 43 42

The same happens when I open an existing delivery:

Screenshot 2025-02-10 at 15 45 25

Screenshot 2025-02-10 at 15 45 32

Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment