Update a Record
Edit Button Interaction
Include an "Edit" button within the item details screen, giving users a clear and distinct call-to-action to initiate the editing process.
Editable Fields:
Clearly indicate which fields are editable. Typically, the Quantity field is editable.
Save Changes Button
Include a "Save" button to allow users to confirm their edits.
Upon clicking "Save" trigger an API(EditLineItem) request to update the item details on the server.
Request URL: https://api.eng-dev-1.trilloapps.com/ds/function/shared/EditLineItem
Payload:
Preview:
Update Record Code Snippet
Code Description
The saveItem is a function that typically handles the process of saving or updating information related to a specific item within a system or application. This function involves storing the item's details in a database, updating records, or performing necessary actions to persist the changes made to the item's information.
Construct Data Object
It constructs a data object containing the lineItemId (converted to a string) and the quantity retrieved from the 'itemQuantity1' input field.
Validate Quantity Input
Validates the quantity input:
Checks if the quantity is not empty.
Verifies if the quantity is a valid number.
Ensures that the quantity is not equal to zero.
If the quantity input is not valid, it displays a validation message and stops further execution.
API Request
If the quantity input is valid, it proceeds to call the apiService.editLineItem function, passing the data object.
Handling API Response
Upon receiving the response from the API call:
If the status is 'failed', it logs the error message and displays a danger toast.
If the status is successful, it updates the UI with the new item details:
Sets various elements such as 'itemName', 'description', 'itemCode', 'itemWeight', 'itemQuantity', and 'itemPic' based on the updated details.
Shows a success toast.
Closes the modal.
Error Handling
If there's an error during the API call, it displays an error toast.
Last updated