[Whitelabel] Handle with quantity limit on the extras modal

Repos that we’ll change

Whitelabel: https://github.com/rbilabs/intl-whitelabel-app

Figma: https://www.figma.com/file/sfH3mHXoEUfHbm5qMul0Vn/branch/VNb1dzeeYVV0IphMPJo0lt/Popeyes?type=design&node-id=3189-125398&t=b8GDYgoS6YtWAr0K-0


Task summary

 

Whitelabel:

  • Task 1: Adjust the extras modal quantity limit for the free item

  • Task 1: Show paid item if select all the free items


Tasks breakdown

Task 1: Adjust the extras modal quantity limit for the free item

Rules:

  • The quantity limit should respect the following rule:

    • sum the free quantity limits from Sanity (looking into each menu item because we can have all the items at the same time depending on the case)

    • Respect the maximum limit that is configured on Sanity (the default is 9). Well always need to respect this limit:

      • Even if the sum is equal 10 and the limit is 9 the maximum will be 9

    • If the maximum was reached the “+” button will be disabled

 

PATH FOR THE SOLUTION

  • As the modal is already using the data from Sanity we’ll just need to develop this new logic for the limit

    • Create a new method to handle this

    • If we choose the creation of a new hook/context (task 7) perhaps we can catch this info from there and just use it on the modal when our flag is ON

 

DOD-LIKE

  • Respect all points from the Rules section

  • Implement new unit tests

 

Task 2: Show paid item if select all the free items

The behavior will be something like this:

OBS: In this example let’s imagine that the free maximum will be 4 items and when I reached this value the “+” button will be disabled (task 1) and we’ll show the paid item above.

 

Rules:

  •  Show the paid item only if the maximum free quantity is reached

  • Adjust the list of items to show always the free items first and then the paid item (if shown)

 

PATH FOR THE SOLUTION

  • Look if the section has the free toggle ON

  • Create a new method that will sort/rearrange the order of the items (mounting a new array or something like that)

 

DOD-LIKE

  • Respect all points from the Rules section

  • Implement new unit tests