Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 14 Next »

πŸ› οΈ Potential Solutions

🧐 Assumptions

  • We will turn the offer search editable, allowing the user to type the offer name.

  • It cannot take much time to show the offer searched.

  • We have to warn the user when the offer does not exist in the list.

  • It needs to search in the list for every offer that contains at least three characters of the name in any part of it (beginning, middle, ending) according to what was typed.

  • It should consider every character typed as lowercase to search in the list.

    • Space won’t count as a character.

  • It should always show Sanity offer in an increasing alphabetical order.

  • It should have a temporary feature flag to ensure everything is working fine, such as enable-search-assigned-offers.

βœ… Proposed Solution

Solution #1

The first solution is allowing the offer name to be editable using a different component (AutoComplete). When the Sanity offer is searched, it will look for the offer by comparing the name with what was typed.

To do this, you need to use a component that searches for the offer name based on each character typed.

Β src/components/customer-offers/forms/offer-form.tsx
const searchByOfferName = () => {
    if (!offerTemplate) {
      return customer.supportOffers.filter((offer) => offer);
    }

    return (
      customer?.supportOffers?.filter(
        (offer) =>
          offer?.name &&
          offerTemplate.length > 2 &&
          offer?.name?.toLowerCase().includes(offerTemplate),
      ) 
    );
  };
    
return {
  ...
  <form onSubmit={handleSubmit}>
    <DialogContent>
      <Grid container spacing={2}>
        <Grid item xs={12}>
          <FormControl
            variant="outlined"
            className={classes.formControl}
            error={hasSubmitted && !offerTemplate}
          >
            {searchByOfferName && (
              <Autocomplete
                ...
              )}

For more references:

βœ… Pros:

  • Quick implementation

(error) Disregarding Solution

Solution #1

This solution allows the offer name to be still editable using a TextBox. When the offer is searched, it will look for the Sanity offer by comparing the name with what was typed, in another component (Select) or a List that would render according to the list of offers available.

(error) Cons:

  • The creation of more dependencies between components

  • Use at least two components to do the same search instead of a specific one that does all the work

Solution #1.1

Use of regex to get any part of the text typed to compare to the list of offers to be assigned

(error) Cons:

  • The creation of a new constant to search offers names based on what was typed instead of using native properties.

πŸ§‘β€πŸš’ QA Plan

Test Scenario

Result

Screenshots

Show the entire offers list

  • When selecting the Search Ofer Input

  • Show a full list of Sanity offers names in a increasing alphabetical order.

Screenshot 2024-08-01 at 10.49.30.png

Show only offers with a specific character or words typed

  • After typing at least three characters in the Search Offer Input that exists in some offer name.

  • Show only Sanity offers with specific characters or words typed in an increasing alphabetical order.

Screenshot 2024-08-01 at 10.48.01.png

Show a warning error for absent offer in the list

  • After typing at least three characters that do not exist in any Sanity offer name in the Search Offer Input.

  • Shows warning message: No results for "whatever was typed".

Screenshot 2024-08-01 at 10.47.14.png
  • No labels

0 Comments

You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.