daily pastebin goal
23%
SHARE
TWEET

Untitled

a guest Mar 25th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function onSaveCustomerDetailsPress() {
  2.     const name = nameInput.getText();
  3.     const lastName = lastNameInput.getText();
  4.    
  5.     if (!isInputValid(name, lastName)) {
  6.         showAlert('Please fill all fields');
  7.         return;
  8.     }
  9.     saveCustomerDetails(name, lastName)
  10. }
  11.  
  12. function isInputValid(name, lastName) {
  13.     if (name.length === 0) {
  14.         return false;
  15.     }
  16.     if (name.length === 0) {
  17.         return false;
  18.     }
  19.     return true;
  20. }
  21.  
  22. async function saveCustomerDetails(name, lastName) {
  23.     try {
  24.         await RequestDispatcher.dispatch(new UpdateCustomerRequest(name, lastName));
  25.     } catch(error) {
  26.         showAlert('An error occurred, please try again');
  27.     }
  28. }
  29.  
  30. function showAlert(message) {
  31.     const alert = new Alert.create(message);
  32.     alert.show();
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top