Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement