Skip to content

feat: Displays region modal if no addresses and location is mandatory - #2750

Merged
hellofanny merged 15 commits into
feat/delivery-promisefrom
feat/mandatory-modal-location
Apr 9, 2025
Merged

hellofanny merged 15 commits into
feat/delivery-promisefrom
feat/mandatory-modal-location

Conversation

@hellofanny

@hellofanny hellofanny commented Mar 27, 2025 •

Copy link
Copy Markdown
Contributor

What's the purpose of this pull request?

This PR implements the scenario where no address is available and the location is set as mandatory on discovery.config

image

note: The region modal and the flow implemented in this PR differ from the previous prototype. But I've already aligned with @renatamottam (design team) and she will update the figma file. (The main difference is that we won't be using the Set Location button, we agreed to use the Apply from the input field)

image

We also made a fix in the current flow of the default RegionModal.

  • It won't automatically close if the added postalCode is invalid and not applied.

Adds buttonActionText field in hCMS (the default is Apply)

hCMS RegionModal
image image

TODO: when merging the feature branch, remind to run cms-sync in the default account.

How it works?

  1. when accessing the website, If there is no address and location is set as mandatory, regardless of the page they are accessing, the region modal should appear "forcing" the user to add a valid postal code.
  2. while the region modal is displayed the user won't see the modal's close button and won't be able to use the escape key to close it.
  3. when a valid postal code is entered, the region modal will close automatically.
image image

How to test it?

  1. Run locally or test via this preview

in the discovery.config file, sets mandatory as true:

deliveryPromise: {
   enabled: true,
   mandatory: true,
 },
  1. Logged in / postalCode available scenario
    If there is a postalCode already set, you shouldn't see a region modal appearing when accessing the website.
    When clicking to edit the postalCode button (in this example 07008), you should able to see the RegionModal with the close button and be able to close it using the esc key.
image
  1. postalCode not defined
    When accessing the website, RegionModal should appear "forcing" the user to add a valid postal code. There won't be a close button and you won't be able to close it using the esc key.
image

Starters Deploy Preview

https://github.com/vtex-sites/starter.store/pull/741

@codesandbox-ci

codesandbox-ci Bot commented Mar 28, 2025 •

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@hellofanny hellofanny changed the title feat: Displays region modal If no addresses and location is mandatory feat: Displays region modal if no addresses and location is mandatory Mar 28, 2025
@lariciamota
lariciamota force-pushed the feat/delivery-promise branch from 3825b3c to 9742ded Compare March 28, 2025 15:27
@hellofanny
hellofanny marked this pull request as ready for review March 28, 2025 17:35
@hellofanny
hellofanny requested a review from a team as a code owner March 28, 2025 17:35
@hellofanny hellofanny self-assigned this Mar 28, 2025
Comment thread packages/core/src/Layout.tsx Resolved

@lucasfp13 lucasfp13 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Testing all of described scenarios and trying to find other ones and the RegionModal behaved as it should, LGTM!

Just a reminder to check the CI, there is a type error happening 🎗️
Screenshot 2025-04-04 at 18 44 49

Comment thread packages/core/src/Layout.tsx Resolved
@lariciamota
lariciamota force-pushed the feat/delivery-promise branch from a28d534 to 8fbe4f1 Compare April 8, 2025 12:46
@hellofanny
hellofanny force-pushed the feat/mandatory-modal-location branch from c9b9f45 to 5901652 Compare April 8, 2025 15:53
@hellofanny

Copy link
Copy Markdown
Contributor Author

Testing all of described scenarios and trying to find other ones and the RegionModal behaved as it should, LGTM!

Just a reminder to check the CI, there is a type error happening 🎗️ Screenshot 2025-04-04 at 18 44 49

This CI is showing another type error happening, but this is not happen locally, I guess there is some outdated issue happening. :/
image

Comment on lines +42 to +46
inputField: {
label: inputFieldLabel,
errorMessage: inputFieldErrorMessage,
buttonActionText: inputButtonActionText,
} = {},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

question: Do we really need to define a default value here?

Suggested change
inputField: {
label: inputFieldLabel,
errorMessage: inputFieldErrorMessage,
buttonActionText: inputButtonActionText,
} = {},
inputField: {
label: inputFieldLabel,
errorMessage: inputFieldErrorMessage,
buttonActionText: inputButtonActionText,
},

@hellofanny
hellofanny merged commit 3f01e99 into feat/delivery-promise Apr 9, 2025
@hellofanny
hellofanny deleted the feat/mandatory-modal-location branch April 9, 2025 13:49
lariciamota pushed a commit that referenced this pull request Apr 11, 2025
…#2750)

This PR implements the scenario where no address is available and the
location is set as mandatory on `discovery.config`

<img width="400" alt="image"
src="https://github.com/user-attachments/assets/c37757e3-7d4f-4cbe-9ea6-9fabf781547e"
/>

**note**: The region modal and the flow implemented in this PR differ
from the previous prototype. But I've already aligned with @renatamottam
(design team) and she will update the figma file. (The main difference
is that we won't be using the `Set Location` button, we agreed to use
the `Apply` from the input field)

<img width="263" alt="image"
src="https://github.com/user-attachments/assets/827d0a3e-10c9-4628-99b3-3a86f0b6013e"
/>

We also made a fix in the current flow of the default `RegionModal`.
- It won't automatically close if the added postalCode is invalid and
not applied.

Adds `buttonActionText` field in hCMS (the default is `Apply`)
| hCMS | RegionModal|
|-|-|
|<img width="500" alt="image"
src="https://github.com/user-attachments/assets/64b8aa01-a5e7-48a0-95fe-4d742d8b2f8d"
/>|<img width="589" alt="image"
src="https://github.com/user-attachments/assets/cbe4c7e3-e6e9-4fad-bfbe-c4a8d10ed683"
/>|

TODO: when merging the feature branch, remind to run cms-sync in the
default account.

1. when accessing the website, If there is no address and location is
set as mandatory, regardless of the page they are accessing, the region
modal should appear "forcing" the user to add a valid postal code.
2. while the region modal is displayed the user won't see the modal's
close button and won't be able to use the escape key to close it.
3. when a valid postal code is entered, the region modal will close
automatically.
<img width="500" alt="image"
src="https://github.com/user-attachments/assets/662caa3b-3fad-4c45-9f2e-c492dc4776d3"
/>

<img width="500" alt="image"
src="https://github.com/user-attachments/assets/eb6fcef6-f95c-4b92-aa72-0a5d56c42415"
/>

1. Run locally or test via this
[preview](https://starter-6czvt97g2-vtex.vercel.app)

in the `discovery.config` file, sets `mandatory` as true:

 ```
 deliveryPromise: {
    enabled: true,
    mandatory: true,
  },
```

2. **Logged in / postalCode available scenario**
If there is a postalCode already set, you shouldn't see a region modal appearing when accessing the website.
When clicking to edit the postalCode button (in this example `07008`), you should able to see the `RegionModal` with the close button and be able to close it using the esc key.

<img width="500" alt="image" src="https://github.com/user-attachments/assets/65be27fe-a76a-40cd-81cf-6d13f014fca9" />

3. **postalCode not defined**
When accessing the website, `RegionModal`  should appear "forcing" the user to add a valid postal code. There won't be a close button and you won't be able to close it using the esc key.

<img width="500" alt="image" src="https://github.com/user-attachments/assets/99f4021a-9166-4c25-87bc-a27c27da5af3" />

https://github.com/vtex-sites/starter.store/pull/741
lariciamota pushed a commit that referenced this pull request Apr 22, 2025
…#2750)

This PR implements the scenario where no address is available and the
location is set as mandatory on `discovery.config`

<img width="400" alt="image"
src="https://github.com/user-attachments/assets/c37757e3-7d4f-4cbe-9ea6-9fabf781547e"
/>

**note**: The region modal and the flow implemented in this PR differ
from the previous prototype. But I've already aligned with @renatamottam
(design team) and she will update the figma file. (The main difference
is that we won't be using the `Set Location` button, we agreed to use
the `Apply` from the input field)

<img width="263" alt="image"
src="https://github.com/user-attachments/assets/827d0a3e-10c9-4628-99b3-3a86f0b6013e"
/>

We also made a fix in the current flow of the default `RegionModal`.
- It won't automatically close if the added postalCode is invalid and
not applied.

Adds `buttonActionText` field in hCMS (the default is `Apply`)
| hCMS | RegionModal|
|-|-|
|<img width="500" alt="image"
src="https://github.com/user-attachments/assets/64b8aa01-a5e7-48a0-95fe-4d742d8b2f8d"
/>|<img width="589" alt="image"
src="https://github.com/user-attachments/assets/cbe4c7e3-e6e9-4fad-bfbe-c4a8d10ed683"
/>|

TODO: when merging the feature branch, remind to run cms-sync in the
default account.

1. when accessing the website, If there is no address and location is
set as mandatory, regardless of the page they are accessing, the region
modal should appear "forcing" the user to add a valid postal code.
2. while the region modal is displayed the user won't see the modal's
close button and won't be able to use the escape key to close it.
3. when a valid postal code is entered, the region modal will close
automatically.
<img width="500" alt="image"
src="https://github.com/user-attachments/assets/662caa3b-3fad-4c45-9f2e-c492dc4776d3"
/>

<img width="500" alt="image"
src="https://github.com/user-attachments/assets/eb6fcef6-f95c-4b92-aa72-0a5d56c42415"
/>

1. Run locally or test via this
[preview](https://starter-6czvt97g2-vtex.vercel.app)

in the `discovery.config` file, sets `mandatory` as true:

 ```
 deliveryPromise: {
    enabled: true,
    mandatory: true,
  },
```

2. **Logged in / postalCode available scenario**
If there is a postalCode already set, you shouldn't see a region modal appearing when accessing the website.
When clicking to edit the postalCode button (in this example `07008`), you should able to see the `RegionModal` with the close button and be able to close it using the esc key.

<img width="500" alt="image" src="https://github.com/user-attachments/assets/65be27fe-a76a-40cd-81cf-6d13f014fca9" />

3. **postalCode not defined**
When accessing the website, `RegionModal`  should appear "forcing" the user to add a valid postal code. There won't be a close button and you won't be able to close it using the esc key.

<img width="500" alt="image" src="https://github.com/user-attachments/assets/99f4021a-9166-4c25-87bc-a27c27da5af3" />

https://github.com/vtex-sites/starter.store/pull/741
lariciamota pushed a commit that referenced this pull request May 8, 2025
…#2750)

This PR implements the scenario where no address is available and the
location is set as mandatory on `discovery.config`

<img width="400" alt="image"
src="https://github.com/user-attachments/assets/c37757e3-7d4f-4cbe-9ea6-9fabf781547e"
/>

**note**: The region modal and the flow implemented in this PR differ
from the previous prototype. But I've already aligned with @renatamottam
(design team) and she will update the figma file. (The main difference
is that we won't be using the `Set Location` button, we agreed to use
the `Apply` from the input field)

<img width="263" alt="image"
src="https://github.com/user-attachments/assets/827d0a3e-10c9-4628-99b3-3a86f0b6013e"
/>

We also made a fix in the current flow of the default `RegionModal`.
- It won't automatically close if the added postalCode is invalid and
not applied.

Adds `buttonActionText` field in hCMS (the default is `Apply`)
| hCMS | RegionModal|
|-|-|
|<img width="500" alt="image"
src="https://github.com/user-attachments/assets/64b8aa01-a5e7-48a0-95fe-4d742d8b2f8d"
/>|<img width="589" alt="image"
src="https://github.com/user-attachments/assets/cbe4c7e3-e6e9-4fad-bfbe-c4a8d10ed683"
/>|

TODO: when merging the feature branch, remind to run cms-sync in the
default account.

1. when accessing the website, If there is no address and location is
set as mandatory, regardless of the page they are accessing, the region
modal should appear "forcing" the user to add a valid postal code.
2. while the region modal is displayed the user won't see the modal's
close button and won't be able to use the escape key to close it.
3. when a valid postal code is entered, the region modal will close
automatically.
<img width="500" alt="image"
src="https://github.com/user-attachments/assets/662caa3b-3fad-4c45-9f2e-c492dc4776d3"
/>

<img width="500" alt="image"
src="https://github.com/user-attachments/assets/eb6fcef6-f95c-4b92-aa72-0a5d56c42415"
/>

1. Run locally or test via this
[preview](https://starter-6czvt97g2-vtex.vercel.app)

in the `discovery.config` file, sets `mandatory` as true:

 ```
 deliveryPromise: {
    enabled: true,
    mandatory: true,
  },
```

2. **Logged in / postalCode available scenario**
If there is a postalCode already set, you shouldn't see a region modal appearing when accessing the website.
When clicking to edit the postalCode button (in this example `07008`), you should able to see the `RegionModal` with the close button and be able to close it using the esc key.

<img width="500" alt="image" src="https://github.com/user-attachments/assets/65be27fe-a76a-40cd-81cf-6d13f014fca9" />

3. **postalCode not defined**
When accessing the website, `RegionModal`  should appear "forcing" the user to add a valid postal code. There won't be a close button and you won't be able to close it using the esc key.

<img width="500" alt="image" src="https://github.com/user-attachments/assets/99f4021a-9166-4c25-87bc-a27c27da5af3" />

https://github.com/vtex-sites/starter.store/pull/741
lariciamota pushed a commit that referenced this pull request May 12, 2025
…#2750)

This PR implements the scenario where no address is available and the
location is set as mandatory on `discovery.config`

<img width="400" alt="image"
src="https://github.com/user-attachments/assets/c37757e3-7d4f-4cbe-9ea6-9fabf781547e"
/>

**note**: The region modal and the flow implemented in this PR differ
from the previous prototype. But I've already aligned with @renatamottam
(design team) and she will update the figma file. (The main difference
is that we won't be using the `Set Location` button, we agreed to use
the `Apply` from the input field)

<img width="263" alt="image"
src="https://github.com/user-attachments/assets/827d0a3e-10c9-4628-99b3-3a86f0b6013e"
/>

We also made a fix in the current flow of the default `RegionModal`.
- It won't automatically close if the added postalCode is invalid and
not applied.

Adds `buttonActionText` field in hCMS (the default is `Apply`)
| hCMS | RegionModal|
|-|-|
|<img width="500" alt="image"
src="https://github.com/user-attachments/assets/64b8aa01-a5e7-48a0-95fe-4d742d8b2f8d"
/>|<img width="589" alt="image"
src="https://github.com/user-attachments/assets/cbe4c7e3-e6e9-4fad-bfbe-c4a8d10ed683"
/>|

TODO: when merging the feature branch, remind to run cms-sync in the
default account.

1. when accessing the website, If there is no address and location is
set as mandatory, regardless of the page they are accessing, the region
modal should appear "forcing" the user to add a valid postal code.
2. while the region modal is displayed the user won't see the modal's
close button and won't be able to use the escape key to close it.
3. when a valid postal code is entered, the region modal will close
automatically.
<img width="500" alt="image"
src="https://github.com/user-attachments/assets/662caa3b-3fad-4c45-9f2e-c492dc4776d3"
/>

<img width="500" alt="image"
src="https://github.com/user-attachments/assets/eb6fcef6-f95c-4b92-aa72-0a5d56c42415"
/>

1. Run locally or test via this
[preview](https://starter-6czvt97g2-vtex.vercel.app)

in the `discovery.config` file, sets `mandatory` as true:

 ```
 deliveryPromise: {
    enabled: true,
    mandatory: true,
  },
```

2. **Logged in / postalCode available scenario**
If there is a postalCode already set, you shouldn't see a region modal appearing when accessing the website.
When clicking to edit the postalCode button (in this example `07008`), you should able to see the `RegionModal` with the close button and be able to close it using the esc key.

<img width="500" alt="image" src="https://github.com/user-attachments/assets/65be27fe-a76a-40cd-81cf-6d13f014fca9" />

3. **postalCode not defined**
When accessing the website, `RegionModal`  should appear "forcing" the user to add a valid postal code. There won't be a close button and you won't be able to close it using the esc key.

<img width="500" alt="image" src="https://github.com/user-attachments/assets/99f4021a-9166-4c25-87bc-a27c27da5af3" />

https://github.com/vtex-sites/starter.store/pull/741
lariciamota added a commit that referenced this pull request May 13, 2025
## What's the purpose of this pull request?

Feature branch for the Delivery Promise feature - phase 1 (navigation
based on shopper location).

- #2708 
- #2728
- #2739 
- #2745 
- #2749
- #2750
- #2768
- #2772 
- #2775
- #2809
- #2817 
- #2824 
- #2835

## How it works?


## How to test it?


### Starters Deploy Preview


## References
- [Jira epic](https://vtex-dev.atlassian.net/browse/SFS-1696)


## Checklist

- [ ] For documentation changes, ping `@Mariana-Caetano` to review and
update (Or submit a doc request)
- [ ] TODO: Request Doc for PopOver
- [ ] TODO: Remind to run cms sync in the default account when the
feature branch is merged since new section was added. (And add the new
section in the admin!)

---------

Co-authored-by: Lucas Feijó <[email protected]>
Co-authored-by: Fanny Chien <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants