Repos that we’ll change
RBI Sanity Shared Schemas: https://github.com/rbilabs/rbi-sanity-shared-schemas - Connect your Github account
Whitelabel CMS: https://github.com/rbilabs/intl-whitelabel-cms - Connect your Github account
Task summary
RBI Sanity Shared Schemas/Whitelabel CMS:
Task 1: Add a new toggle to enable the “free items” on AddOnSection
Task 2: Extend the Option item to have new fields
Task 3: Create a new section (fieldset) for the free-addon modal
Tasks breakdown
RBI Sanity Shared Schemas
Order in UI
New toggle
New items selection section
New fieldset with the fields:
Modal image field
Modal title
Modal description
Modal text button
Task 1: Add a new toggle to enable the “free items” on AddOnSection
Motivation: this toggle will enable the new feature integration for “free/promotional items” on the cart
Label: Make options in this section as free add-ons
Description: By turning this on, guests will be able to add the options in the list of add-ons for free to their order. You can choose which items in the order are eligible to grant free add-ons and also how many add-on units will be free of charge per item.
Rules:
Toggle should only be visible by Intl market:
hidden: () => !ctx.isIntl
PATH FOR THE SOLUTION
Add the new toggle on
/src/schemas/menu/documents/add-on-section.tsx
DOD-LIKE
The initial value for this toggle: FALSE
This toggle should only be visible to Intl market
hidden: () => !ctx.isIntl
Task 2: Extend the Option item to have new fields
Motivation: we’ll need to configure the addon free configuration for each add-on (paid) selected on the main page of the section
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)
Hide the field Maximum amount
Motivation: we’ll use the sum of the menu items limit to configure on the Whitelabel UI the desired limits for each item (configured on the new object below)
Create the new object (addOnSectionMenuOptions
)
File name:
add-on-section-menu-options.ts
Folder:
./src/schemas/menu/objects
Put it on the build-shared-schemas:
./src/build-shared-schemas.ts
This file will have a structure similar to the
add-on-section-option.ts
Configure the
preview
on the object to show the item name and the free quantity info
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()
DOD-LIKE
Add the new fields on the UI
Create the new object for the menu item options
Follow the rules for each field
“Free addon item” should be filled if the free addon toggle is ON
“Menu items to offer the free item” should have at least one item if the free addon toggle is ON
Hide the maximum amount field
Task 3: Create a new section (fieldset) for the free-addon modal
Motivation: configure the add-ons free modal. The fieldset will help the organization, by grouping 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
We also will have the following fields inside this fieldset:
Image field
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
PATH FOR THE SOLUTION
For the fieldset, we have the Hero example on the Intl CMS repo and the doc from Sanity above
For the image, we can take a look at the item document from the CMS or other documents that have an image field and make the same
DOD-LIKE
All the fields should be children of the modal fieldset
The fieldset should not be collapsed when appears
Condition the new fieldset to be visible only if the new toggle is TRUE
0 Comments