Skip to content

Instantly share code, notes, and snippets.

@astexplorer
Last active December 30, 2017 19:42
Show Gist options
  • Save astexplorer/de28761373f95a0615a4ef9bc4155822 to your computer and use it in GitHub Desktop.
Save astexplorer/de28761373f95a0615a4ef9bc4155822 to your computer and use it in GitHub Desktop.
{
"v": 2,
"parserID": "typescript",
"toolID": "jscodeshift",
"settings": {
"typescript": {}
},
"versions": {
"typescript": "2.6.1",
"jscodeshift": "0.3.32"
}
}
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { HomePage } from '../home/home';
import { FormGroup, FormControl, Validators } from '@angular/forms';
import { UserProvider } from '../../providers/user/user';
import 'rxjs/add/operator/finally';
import { LoginPage } from '../index';
@Component({
selector: 'page-signup',
templateUrl: 'signup.html'
})
export class SignupPage {
signupForm: FormGroup;
loading: boolean;
constructor(public navCtrl: NavController, private userProvider: UserProvider) {
this.signupForm = new FormGroup({
username: new FormControl('', [ Validators.required ]),
email: new FormControl('', [ Validators.required, Validators.email ]),
password: new FormControl('', [ Validators.required ])
});
}
signup() {
if (this.signupForm.valid) {
this.userProvider.signup(this.signupForm.value)
.finally(() => this.loading = false)
.subscribe(response => {
if (response["status"] === "success") {
this.gotoHome();
}
}, err => {
// console.log("err", err);
});
} else {
this.userProvider.presentToast('Please fill the form correctly');
}
}
gotoHome() {
this.navCtrl.setRoot(HomePage);
}
gotoLogin() {
this.navCtrl.setRoot(LoginPage);
}
}
// Press ctrl+space for code completion
export default function transformer(file, api) {
const j = api.jscodeshift;
return j(file.source)
.find(j.Identifier)
.forEach(path => {
j(path).replaceWith(
j.identifier(path.node.name.split('').reverse().join(''))
);
})
.toSource();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment