Commit 23c8a4c3c3c34057be0a44fa8f9c6c6a6e04b628

Authored by themeteorchef
1 parent 3540345c50
Exists in master

remove dependency on getInputValue() from form modules

imports/modules/login.js
... ... @@ -3,13 +3,12 @@ import 'jquery-validation';
3 3 import { browserHistory } from 'react-router';
4 4 import { Meteor } from 'meteor/meteor';
5 5 import { Bert } from 'meteor/themeteorchef:bert';
6   -import { getInputValue } from './get-input-value';
7 6  
8 7 let component;
9 8  
10 9 const login = () => {
11   - const email = getInputValue(component.refs.emailAddress);
12   - const password = getInputValue(component.refs.password);
  10 + const email = document.querySelector('[name="emailAddress"]').value;
  11 + const password = document.querySelector('[name="password"]').value;
13 12  
14 13 Meteor.loginWithPassword(email, password, (error) => {
15 14 if (error) {
... ... @@ -51,7 +50,7 @@ const validate = () => {
51 50 });
52 51 };
53 52  
54   -export const handleLogin = (options) => {
  53 +export default function handleLogin(options) {
55 54 component = options.component;
56 55 validate();
57   -};
  56 +}
... ...
imports/modules/recover-password.js
... ... @@ -2,13 +2,12 @@ import $ from 'jquery';
2 2 import 'jquery-validation';
3 3 import { Accounts } from 'meteor/accounts-base';
4 4 import { Bert } from 'meteor/themeteorchef:bert';
5   -import { getInputValue } from './get-input-value';
6 5  
7 6 let component;
8 7  
9 8 const handleRecovery = () => {
10 9 Accounts.forgotPassword({
11   - email: getInputValue(component.refs.emailAddress),
  10 + email: document.querySelector('[name="emailAddress"]').value,
12 11 }, (error) => {
13 12 if (error) {
14 13 Bert.alert(error.reason, 'warning');
... ... @@ -36,7 +35,7 @@ const validate = () => {
36 35 });
37 36 };
38 37  
39   -export const handleRecoverPassword = (options) => {
  38 +export default function handleRecoverPassword(options) {
40 39 component = options.component;
41 40 validate();
42   -};
  41 +}
... ...
imports/modules/reset-password.js
... ... @@ -3,13 +3,12 @@ import 'jquery-validation';
3 3 import { browserHistory } from 'react-router';
4 4 import { Accounts } from 'meteor/accounts-base';
5 5 import { Bert } from 'meteor/themeteorchef:bert';
6   -import { getInputValue } from './get-input-value';
7 6  
8 7 let component;
9 8 let token;
10 9  
11 10 const handleReset = () => {
12   - const password = getInputValue(component.refs.newPassword);
  11 + const password = document.querySelector('[name="newPassword"]').value;
13 12 Accounts.resetPassword(token, password, (error) => {
14 13 if (error) {
15 14 Bert.alert(error.reason, 'danger');
... ... @@ -47,8 +46,8 @@ const validate = () => {
47 46 });
48 47 };
49 48  
50   -export const handleResetPassword = (options) => {
  49 +export default function handleResetPassword(options) {
51 50 component = options.component;
52 51 token = options.token;
53 52 validate();
54   -};
  53 +}
... ...
imports/modules/signup.js
... ... @@ -3,22 +3,21 @@ import 'jquery-validation';
3 3 import { browserHistory } from 'react-router';
4 4 import { Accounts } from 'meteor/accounts-base';
5 5 import { Bert } from 'meteor/themeteorchef:bert';
6   -import { getInputValue } from './get-input-value';
7 6  
8 7 let component;
9 8  
10 9 const getUserData = () => ({
11   - email: getInputValue(component.refs.emailAddress),
12   - password: getInputValue(component.refs.password),
  10 + email: document.querySelector('[name="emailAddress"]').value,
  11 + password: document.querySelector('[name="password"]').value,
13 12 profile: {
14 13 name: {
15   - first: getInputValue(component.refs.firstName),
16   - last: getInputValue(component.refs.lastName),
  14 + first: document.querySelector('[name="firstName"]').value,
  15 + last: document.querySelector('[name="lastName"]').value,
17 16 },
18 17 },
19 18 });
20 19  
21   -const signUp = () => {
  20 +const signup = () => {
22 21 const user = getUserData();
23 22  
24 23 Accounts.createUser(user, (error) => {
... ... @@ -65,11 +64,11 @@ const validate = () => {
65 64 minlength: 'Use at least six characters, please.',
66 65 },
67 66 },
68   - submitHandler() { signUp(); },
  67 + submitHandler() { signup(); },
69 68 });
70 69 };
71 70  
72   -export const handleSignup = (options) => {
  71 +export default function handleSignup(options) {
73 72 component = options.component;
74 73 validate();
75   -};
  74 +}
... ...