"Utilizing Javascript filtering to narrow down results based on date ranges within a Vue

I'm currently using Vue within a Laravel application. Most of the functionality is working as expected, except for the last part. I've been struggling to come up with the right search terms for this scenario. Apologies if this question has already been asked before.

Below is the code snippet I am working with:

return [...this.tableData].filter((salesorders) => {
     if (this.selectOption == '6') {
         return salesorders.order_status.match(this.status);
    }

                if (this.selectOption == '1') {
                    return salesorders.number.includes(this.searchInput);
                }

                if (this.selectOption == '2' && this.choice == 'is') {
                   var ship_date = moment(String(this.first_date)).format('MM-DD-YYYY');
                    return salesorders.requested_ship_date.match(ship_date);
                }

                if (this.selectOption == '2' && this.choice == 'is not') {
                    var ship_date = moment(String(this.first_date)).format('MM-DD-YYYY');
                    return !salesorders.requested_ship_date.match(ship_date);
                }

                if (this.selectOption == '2' && this.choice == 'is between') {
                    var ship_date1 = moment(String(this.first_date)).format('MM-DD-YYYY');
                    var ship_date2 = moment(String(this.end_date)).format('MM-DD-YYYY');

                    return salesorders.requested_ship_date >= ship_date1 && salesorders.requested_ship_date >= ship_date2;
                }

            });

Answer №1

Finally, the solution became clear to me:

    if (salesorders.requested_ship_date >= ship_date1 && salesorders.requested_ship_date <= ship_date2) {
        return true;
    } else {
        return false;
    }

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Prevent zoom function on CapacitorJS application using Android Webview

I have developed a TV WebApp using Vue, optimized for FullHD resolution 1920x1080. Now I am looking to transition it to Android TV. The app works and looks fine on browsers and TizenTV: https://i.stack.imgur.com/njPaX.png When viewed in the AndroidTV sim ...

What is the process for uploading files from NextJS directly from the browser to either Cloud Storage or an FTP server?

Is there a way to upload files from the browser using NextJS directly to Cloud Storage or an FTP server? I'm looking to upload files directly from the browser to a storage server. Do you think I can utilize node-ftp in the API routes of Nextjs, like ...

The date-fns parse function will retrieve the value from the previous day

When attempting to parse a date using the date-fns library, I am encountering an issue where the resulting date is one day prior. How can this be resolved in order to obtain the correct result? start = '2021-08-16' const parseStart = parse(start, ...

Updating the content of a Telerik RadEditor using Javascript/jQuery

I am currently facing a challenge in manually cleaning the HTML of a Telerik RadEditor using Javascript. Despite my efforts, I am struggling to find the appropriate location to store the value in order for it to be saved during post back. Below is the Jav ...

When using PHP's `json_encode()`, don't forget to append a "1" at the

While utilizing json_encode in my project, I have encountered an issue that is perplexing. On one particular page where I make an ajax call, the resulting json seems to mysteriously add a 1 to the end of the string. The output of my return string appears ...

Accessing JSON Data Using JQUERY

Currently, I am experimenting with grabbing JSON data from websites using the $.getJSON() method. Here is the code snippet I have been working on: The website I am attempting to retrieve JSON data from can be found here. Interestingly, the code functions ...

Error code SQLSTATE[42000]: Invalid syntax or unauthorized access: 1064 encountered in the Laravel framework

In my master page header, there is a notification displaying the number of unread messages: <li class="nav-item dropdown"> <a href="{{url('chat-room')}}" target="_blank" role="button"> <span class="adminpro-icon admin ...

Utilize ng-show/ng-hide to dynamically display messages or content based on the results obtained

One of my functions builds and returns a JSON object like this: {"message":"No Grupos de MetaDetalles found","entities":[],"breadcrumbs":[],"parent_id":0} Now, I have an Angular view set up like this: <table id="example-datatables" class="table table ...

Send Vue form data to Axios without using v-model for submission

When I submit a form, I intercept the submit event and pass it to a Vue method. My dilemma is how to pass this event directly to an Axios call without creating multiple v-models or variables based on the event. <template> <form @submit.prevent ...

Chrome Driver Protractor Angular 2 encountering issue with unclickable element

My issue is with clicking the second level menu options to expand to the third level. I have tried using browser.driver.manage().window().setSize(1280, 1024) in the before all section. Here is my code snippet: it('Should trigger the expansion of the ...

Fetching deeply nested data from JSON within Angular Material tables - ANGULAR

Having trouble retrieving data from localhost, especially when it's in a different structure. Any suggestions on how to properly extract and display this data for the user? This is my attempted approach, but I'm encountering an error message: ER ...

Resetting the countdown timer is triggered when moving to a new page

In my current project, I am developing a basic battle game in which two players choose their characters and engage in combat. The battles are structured into turns, with each new turn initiating on a fresh page and featuring a timer that counts down from ...

"Using axios and async/await in VUE.JS to perform multiple asynchronous GET

Perhaps this is a somewhat basic inquiry, as I am still learning the ropes of vue.js and javascript. Please bear with me if my question is not well-articulated or if the solution is straightforward... I am facing an issue where I need to retrieve data from ...

Convert HTML templates into JavaScript on the client side using Angular framework along with Browserify, Babel, ES2015, and Gulp

Having trouble with my Browserify Angular configuration file, specifically when using require() to load HTML templates. I attempted to use stringify or browserify-ng-html2js in the transform() function, but it resulted in multiple transform calls in my gul ...

Stopping a jQuery function from executing multiple times while it is already active - is it possible?

Currently, I am utilizing the http://jsfiddle.net/CqAU2/ plugin for image rotation on my website. The issue I am facing is that when the user clicks on the image box multiple times, it continues rotating each time. I want the click action to only be regi ...

The cross-origin resource sharing (CORS) functionality is functioning properly on the

I've encountered an unusual problem with express cors. While my Cors configuration works perfectly on localhost, it fails to function in the production environment. Every time I encounter the same error. Failed to load : Response to preflight r ...

I encountered an issue in node.js where I was unable to delete a folder after renaming a zip

When attempting to rename an uploaded file using the code below: fs.rename('xxxxx','xxxxx',function(err) { }); I encountered an issue within the callback function. I attempted to remove a folder using the following code: fs.rename(& ...

Utilizing constants for DOM element objects across multiple methods in Vue.js

Is there a way to share DOM element objects between methods in Vue.js without duplicating code? I'm using @vue/cli and struggling to export them before the Vue.js code due to my limited experience with this framework. I have multiple nodes involved in ...

Issue with Jquery prevents clicking on hyperlinks

I have a table where table rows can be clicked. However, some cells cannot be clicked if they contain hyperlinks. This is because having both actions - one for clicking the table row and another for clicking the hyperlink - can cause confusion. Therefore, ...

Running a 2D JavaScript game script on a React page - A step-by-step guide!

I am facing a challenge with my website that features a game coded entirely in javascript. Despite my efforts to switch the site from an HTML layout to a more modern React design, I can't seem to get the game to display correctly. In the original HTM ...