Getting a Record of Customer Orders

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

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

Payload:

Preview:

Order Record Overview

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

    • Order No

    • Title

    • Description

    • Booking Date

    • Delivery Time

    • Status (Pending, Processing, Shipped, Delivered)

Back To Customer Record Button

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

Search Order By Title

  • Implement search options to help users quickly find specific order records based on their titles.

Order Record Code Snippet

// Function to get order data
function getOrdersData(comingId) {
   apiService.getOrders(start, size, comingId)
       .then(response => {
           if (response.status == 'failed') {
               console.log(response.message);
               showToast(response.message, 'danger');
           } else {
               // Update global orderDataList and calculate total pages
               orderDataList = response.data.orders;
               totalPages = Math.ceil(response.data.totalData / itemsPerPage);
               // Populate table and generate pagination
               populateTable();
               generatePagination();
           }
       })
       .catch(error => {
           showToast(error.message, 'danger');
       });
}

Code Description

The getOrdersData retrieves information about orders in a system. This function typically involves querying a database to fetch relevant data regarding customer orders, enabling effective order management and analysis.

API Request

  • Invokes the apiService.getOrders(start, size, comingId) method, making an asynchronous request to the server to fetch order data.

  • The start and size parameters likely control the pagination of the data, and comingId is a parameter passed to the API, possibly indicating a specific context or filter for the orders.

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', update the global orderDataList with the order 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 order 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