Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onSaveCustomerDetailsPress() {
- const name = nameInput.getText();
- const lastName = lastNameInput.getText();
- if (!isInputValid(name, lastName)) {
- showAlert('Please fill all fields');
- return;
- }
- saveCustomerDetails(name, lastName)
- }
- function isInputValid(name, lastName) {
- if (name.length === 0) {
- return false;
- }
- if (name.length === 0) {
- return false;
- }
- return true;
- }
- async function saveCustomerDetails(name, lastName) {
- try {
- await RequestDispatcher.dispatch(new UpdateCustomerRequest(name, lastName));
- } catch(error) {
- showAlert('An error occurred, please try again');
- }
- }
- function showAlert(message) {
- const alert = new Alert.create(message);
- alert.show();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement