the problem statement is i have to make a search function in which i can search lower can upper case element both even if i type lower case either upper case

i tried upper case search and lower case but its not working at all please suggest me as soon as possible

search(searchValue) {
    if (searchValue != null && searchValue != "") {
      var searchItem = searchValue;
      var allOppData = this.stagesWiseOpportunitiesData;

      var filtered = _.mapValues(allOppData, statuses =>
        _.filter(statuses, statusT =>
          _.some(statusT, T => _.includes(T, searchItem))
        )
      );
      this.stagesWiseOpportunitiesData = filtered;
      let stages = this.opportunitiesStateReason;
      stages.forEach(element => {
        let num = this.stagesWiseOpportunitiesData[element.orderData].reduce(
          function(sum, value) {
            return sum + value.expected_revenue;
          },
          0
        );
        element.totalExpectedRevenue = num.toFixed(2);
      });
    } else {
      this.stagesWiseOpportunitiesData = this.stagesWiseOpportunitiesDataCopy;
      let stages = this.opportunitiesStateReason;
      stages.forEach(element => {
        let num = this.stagesWiseOpportunitiesData[element.orderData].reduce(
          function(sum, value) {
            return sum + value.expected_revenue;
          },
          0
        );
        element.totalExpectedRevenue = num.toFixed(2);
      });
    }
  }
}

1 Answers

0
Syed Mohamed Aladeen On

Try like this. you have missed to return the for the search function.

NOTE: you have only returned for a function inside search function

function search(searchValue) {
    if (searchValue != null && searchValue != "") {
        var searchItem = searchValue;
        var allOppData = this.stagesWiseOpportunitiesData;

        var filtered = _.mapValues(allOppData, statuses =>
            _.filter(statuses, statusT =>
                _.some(statusT, T => _.includes(T, searchItem))
            )
        );
        this.stagesWiseOpportunitiesData = filtered;
        let stages = this.opportunitiesStateReason;
        return stages.forEach(element => {
            let num = this.stagesWiseOpportunitiesData[element.orderData].reduce(
                function(sum, value) {
                    return sum + value.expected_revenue;
                },
                0
            );
            element.totalExpectedRevenue = num.toFixed(2);
        });
    } else {
        this.stagesWiseOpportunitiesData = this.stagesWiseOpportunitiesDataCopy;
        let stages = this.opportunitiesStateReason;
        return stages.forEach(element => {
            let num = this.stagesWiseOpportunitiesData[element.orderData].reduce(
                function(sum, value) {
                    return sum + value.expected_revenue;
                },
                0
            );
            element.totalExpectedRevenue = num.toFixed(2);
        });
    }
}

console.log(search("Test"))