Repos that we’ll change
...
We’ll have two new fields: “Free addon item” and “Menu items to offer the free item” on the add-on-section-option.ts
:
“Free addon Item”
Label: (to be defined)
Description: (to be defined)
Rules:
Type
reference
to typeitem
(as the “Option” that we already have on the screen)Should be hidden if:
!ctx.isIntl
AND!ctxTest.document.enableAddonAsFreeItem
Required/invalid if:
context?.document?.enableAddonAsFreeItem && !value
(validation prop with custom rule)
...
“Menu items to offer the free item”
Label: (to be defined)
Description: (to be defined)
Rules:
Type
array
to typeaddOnSectionMenuOptions
(suggestion of name… we’ll create the new object that will be used here)Should be hidden if:
!ctx.isIntl
AND!ctxTest.document.enableAddonAsFreeItem
Required/invalid if:
context?.document?.enableAddonAsFreeItem && !value
(validation prop with custom rule)
...
For this object we’ll have:
“Free quantity”
Label: (to be defined)
Description: (to be defined)
Rules:
validation: (Rule: any) => Rule.min(1)
initialValue: 1
Type: number
“Menu item”
Label: (to be defined)
Description: (to be defined)
Rules:
Type
reference
to typeitem
(as the “Option” that we already have on the screen)validation: (Rule: any) => Rule.required()
...
Motivation: configure the add-ons free modal. The fieldset will help with the organization to group the fields
Label: (to be defined)
Description: (to be defined)
Rules:
The fieldset should not be collapsed when appears (DOC)
All fields should be children of the fieldset
The fieldset should only be visible if the toggle for add-on free items is ON
...
Modal toggle (to show/hide on the Whitelabel App):
Label: (to be defined)
Description: (to be defined)
Modal title field
Label: (to be defined)
Description: (to be defined)
Modal description field
Label: (to be defined)
Description: (to be defined)
Modal primary button field
Label: (to be defined)
Description: (to be defined)
Rules:
If the toggle is ON
The title and primary button should be filled in and are required. This is needed to prevent the user from publishing the document and to not show an empty modal on the Whitelabel App
Description and image fields are optional
...
Suggested props/interface for the new component
Code Block language typescript interface IAddOnsFreeModal { cartEntries: ICartEntry[]; // this is necessary to know if we'll show the modal based in whats in the cart entries addOnSections: IAddOnSection[]; // another option is to receive the addon free from the parent directly addToCartaddItemToCart: (items: IBaseItem) => void; }
I think that the modal should be responsible for our internal state to know if will be shown or not and if we click on the addToCart we’ll run the
handleAddToCart
from the parent component
...