basicInfo.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. basicInfoObj = {
  2. display: function(){
  3. controller.clearScreen();
  4. controller.basicInfoStrand.style.display = "flex";
  5. if(!recipes){
  6. document.querySelector("#nameLabel").style.display = "block";
  7. }
  8. },
  9. submit: function(){
  10. event.preventDefault();
  11. let name = document.querySelector("#regName").value;
  12. let email = document.querySelector("#regEmail").value;
  13. let password = document.querySelector("#regPass").value;
  14. let confirmPassword = document.querySelector("#regConfirmPass").value;
  15. axios.post("/email", {email: email})
  16. .then((response)=>{
  17. if(typeof(response.data) === "string"){
  18. banner.createError(response.data);
  19. }else if(response.data){
  20. if(validator.merchant.password(password, confirmPassword)){
  21. controller.data.name = name;
  22. controller.data.email = email;
  23. controller.data.password = password;
  24. controller.data.confirmPassword = confirmPassword;
  25. addIngredientsObj.display();
  26. }
  27. }else{
  28. banner.createError("Email address already in use");
  29. }
  30. })
  31. .catch((err)=>{
  32. banner.createError("Error: unable to validate email address");
  33. });
  34. }
  35. }