Getting a Record of Order Items

Upon clicking an order record, smoothly transition the user to a dedicated section or page displaying the order records associated with that order.

Request URL: https://api.eng-dev-1.trilloapps.com/ds/function/shared/GetOrderItems

Payload:

Preview:

Item Record Overview

  • Design the item record screen to provide a concise overview. Include key information, such as:

    • Name

    • Item Description

    • Code

    • Weight

    • Quantity

Back To Order Record Button

  • Maintain a clear and easily navigable path back to the order records screen, allowing users to switch between order and item records effortlessly.

Search Order Item By Name

  • Implement search options to help users quickly find specific item records based on item names.

Item Record Code Snippet

// Function to get item data based on order or from local storage
function getItemsData(comingId) {
   apiService.getItems(start, size, comingId)
       .then(response => {
           if (response.status == 'failed') {
               console.log(response.message);
               showToast(response.message, 'danger');
           } else {
               itemsDataList = response.data.items;
               totalPages = Math.ceil(response.data.totalData / itemsPerPage);
               // Populate the table and generate pagination links
               populateTable();
               generatePagination();
           }
       })
       .catch(error => {
           showToast(error.message, 'danger');
       });
}

Code Description

The getItemsData retrieves information about items based on a specific order ID (`orderId`) or from local storage. This function fetches relevant data about products associated with a particular order, enhancing order-specific details and local data retrieval capabilities.

API Request

Invokes the apiService.getItems(start, size, comingId) method, making an asynchronous request to the server to fetch item data. The comingId parameter is likely used to specify a context or filter for the items.

Handling API Response

  • Uses the then method to handle the response from the API request asynchronously.

  • Checks if the response status is 'failed', logs the error message to the console and displays a danger toast with the error message.

Update Global Data

  • If the response status is ‘not failed', updates the global itemsDataList with the item data received from the response.

  • Calculates the total number of pages (totalPages) based on the total data count and the number of items per page (itemsPerPage).

Populate Table and Pagination

  • Calls the populateTable function to update the table with the retrieved item data.

  • Calls the generatePagination function to create pagination links based on the total number of pages.

Error Handling

Uses the catch block to handle any errors that may occur during the API request and displays a danger toast with the error message.

Last updated