Advertisement
Guest User

Untitled

a guest
Mar 15th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. static contextTypes = {
  2. router: PropTypes.object
  3. }
  4. constructor(props,context){
  5. super(props,context);
  6. this.state = {
  7. fname:'',
  8. lname:'',
  9. emailaddress:'',
  10. password:'',
  11. mobile:'',
  12. user:'',
  13. login_pass:''
  14. }
  15. this.regi_data = this.regi_data.bind(this);
  16. this.login_data = this.login_data.bind(this);
  17. this.otpModalRef = React.createRef();
  18. }
  19.  
  20. regi_data(e){
  21. this.setState({[e.target.name] : e.target.value}
  22. );
  23. }
  24. login_data(e){
  25. this.setState({[e.target.name] : e.target.value})
  26. }
  27.  
  28. otpModalRef = ({onOpenModal}) => {
  29. this.showModal = onOpenModal;
  30. }
  31.  
  32. componentDidMount(){
  33.  
  34. }
  35.  
  36.  
  37. login = (e) => {
  38. e.preventDefault();
  39. axios.post('/api/signin', {
  40. user:this.state.user,
  41. password:this.state.login_pass,
  42. })
  43. .then(res => {
  44. console.log(res);
  45. this.context.router.history.push({
  46. pathname:'/',
  47. });
  48.  
  49. })
  50. .catch(function (error) {
  51. console.log(error.message);
  52. })
  53. }
  54.  
  55. register = (e,ref) => {
  56. e.preventDefault();
  57. axios.post('/api/user/add', {
  58. firstname: this.state.fname,
  59. lastname:this.state.lname,
  60. email:this.state.emailaddress,
  61. password:this.state.password,
  62. mobile:this.state.mobile
  63. },
  64. )
  65. .then(res => {
  66. console.log(res);
  67. this.showModal();
  68.  
  69. })
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement