Skip to content

Commit

Permalink
feat: start on signup page
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya Radchenko committed Aug 27, 2018
1 parent 19220f2 commit b8e6f6d
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 17 deletions.
13 changes: 1 addition & 12 deletions app/application/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,5 @@ import SessionService from 'cg/services/session';
export default class Application extends Route.extend({
// anything which *must* be merged to prototype here
}) {
@service('session') sessionService!: SessionService;

beforeModel() {
super.beforeModel(...arguments);
let session = this.sessionService;

if (!session.isAuthenticated) {
return this.transitionTo('signin');
}

return;
}

}
4 changes: 2 additions & 2 deletions app/index/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export default class Index extends Route.extend({
@service('session') sessionService!: SessionService;

model() {
let churchId = this.sessionService.churchId;
// let churchId = this.sessionService.churchId;

return this.store.findRecord('church', churchId);
// return this.store.findRecord('church', churchId);
}
}
19 changes: 19 additions & 0 deletions app/models/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import DS from 'ember-data';
import { attr } from '@ember-decorators/data';

export default class User extends DS.Model.extend({

}) {
@attr('string')
email!: string;

@attr('string')
password!: string;
}

// DO NOT DELETE: this is how TypeScript knows how to look up your models.
declare module 'ember-data' {
interface ModelRegistry {
'user': User;
}
}
1 change: 1 addition & 0 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const Router = EmberRouter.extend({

Router.map(function() {
this.route('signin');
this.route('signup');
});

export default Router;
14 changes: 11 additions & 3 deletions app/signin/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@
<div class='self-center mt-8 w-full max-w-xs'>
<form class='bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4' {{action 'signin' on='submit'}}>
<div class='mb-4'>
<label class='block text-grey-darker text-sm font-bold mb-2' for='username'>
Username
<label
class='block text-grey-darker text-sm font-bold mb-2'
for='email'
>
Email
</label>
<input class='shadow appearance-none border rounded w-full py-2 px-3 text-grey-darker leading-tight' id='username' type="text" placeholder="Username">
<input
class='shadow appearance-none border rounded w-full py-2 px-3 text-grey-darker leading-tight'
id='email'
type='text'
placeholder='Email'
>
</div>
<div class="mb-6">
<label class='block text-grey-darker text-sm font-bold mb-2' for='password'>
Expand Down
32 changes: 32 additions & 0 deletions app/signup/controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import Controller from '@ember/controller';
import { action } from '@ember-decorators/object';
import { service } from '@ember-decorators/service';
import DS from 'ember-data';

export default class Signup extends Controller.extend({
// anything which *must* be merged to prototype here
}) {
@service('store')
storeService!: DS.Store;

email: string = '';

@action
async signup() {
let email = this.email;
let store = this.storeService;
let user = store.createRecord('user', {
email
});

await user.save();
debugger;
}
}

// DO NOT DELETE: this is how TypeScript knows how to look up your controllers.
declare module '@ember/controller' {
interface Registry {
'signup': Signup;
}
}
7 changes: 7 additions & 0 deletions app/signup/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Route from '@ember/routing/route';

export default class Signup extends Route.extend({
// anything which *must* be merged to prototype here
}) {
// normal class body definition here
}
31 changes: 31 additions & 0 deletions app/signup/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<FullLayout>
<div class='self-center mt-8 w-full max-w-xs'>
<form class='bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4' {{action 'signup' on='submit'}}>
<div class='mb-4'>
<label
class='block text-grey-darker text-sm font-bold mb-2'
for='email'
>
Email
</label>
<input
class='shadow appearance-none border rounded w-full py-2 px-3 text-grey-darker leading-tight'
id='email'
type='text'
placeholder='Email'
oninput={{action (mut this.email) value='target.value'}}
>
</div>

<div class='flex items-center justify-between'>
<button class='bg-blue hover:bg-blue-dark text-white font-bold py-2 px-4 rounded' type='submit'>
Sign Up
</button>

{{#link-to 'signin' class='inline-block align-baseline font-bold text-sm text-blue hover:text-blue-darker'}}
Already have an account? Sign In
{{/link-to}}
</div>
</form>
</div>
</FullLayout>
14 changes: 14 additions & 0 deletions tests/unit/models/user-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import { run } from '@ember/runloop';

module('Unit | Model | user', function(hooks) {
setupTest(hooks);

// Replace this with your real tests.
test('it exists', function(assert) {
let store = this.owner.lookup('service:store');
let model = run(() => store.createRecord('user', {}));
assert.ok(model);
});
});
12 changes: 12 additions & 0 deletions tests/unit/signup/controller-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

module('Unit | Controller | signup', function(hooks) {
setupTest(hooks);

// Replace this with your real tests.
test('it exists', function(assert) {
let controller = this.owner.lookup('controller:signup');
assert.ok(controller);
});
});
11 changes: 11 additions & 0 deletions tests/unit/signup/route-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

module('Unit | Route | signup', function(hooks) {
setupTest(hooks);

test('it exists', function(assert) {
let route = this.owner.lookup('route:signup');
assert.ok(route);
});
});

0 comments on commit b8e6f6d

Please sign in to comment.