Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions src/app/login/components/LoginBaseCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<b-form>
<b-row class="my-1">
<b-col sm="3"><label for="type-email">User Name</label></b-col>
<b-col sm="9"><b-form-input :value="email" id="type-email" type="text" disabled></b-form-input></b-col>
<b-col sm="9"><b-form-input :value="email" id="type-email" type="text" placeholder="Your email" disabled></b-form-input></b-col>
</b-row>
<b-row class="my-1">
<b-col sm="3"><label for="type-password">Password</label></b-col>
Expand Down Expand Up @@ -32,7 +32,8 @@
export default class LoginBaseCard extends Vue {
@State('login') private login!: LoginState;
@Action('fetchData', {namespace}) private fetchData: any;
@Getter('userEmail', {namespace}) private userEmail!: string;
@Getter('name', {namespace}) private name!: string;
@Getter('email', {namespace}) private email!: string;

private data() {
return {
Expand All @@ -44,15 +45,5 @@
private mounted() {
this.fetchData();
}

get email() {
const user = this.login && this.login.user;
return user && user.email;
}

get name() {
const user = this.login && this.login.user;
return user && user.name;
}
}
</script>
12 changes: 9 additions & 3 deletions src/app/login/vuex/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ import { LoginState } from './types';
import { RootState } from '../../types';

export const getters: GetterTree<LoginState, RootState> = {
userEmail(state): string {

email(state): string {
const { user } = state;
const name = (user && user.name) || '';
const email = (user && user.email) || '';
return `${name}<${email}>`;
return email;
},

name(state): string {
const { user } = state;
const name = (user && user.name) || '';
return name;
},
};
3 changes: 2 additions & 1 deletion src/app/sample/components/SampleComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
style="max-width: 100%;"
class="mb-2">
<p class="card-text">
{{sample.message}}
{{message}}
</p>
<b-button href="/user-login" variant="primary">Second Module</b-button>
</b-card>
Expand All @@ -22,6 +22,7 @@
export default class SampleComponent extends Vue {
@Action('sampleData', {namespace}) private sampleData: any;
@State('sample') private sample!: SampleState;
@Getter('message', {namespace}) private message!: string;

private mounted() {
this.sampleData();
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/sample.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { expect } from 'chai';
import { ComponentOptions } from 'vue/types/options';
import { shallowMount } from '@vue/test-utils';
import { SampleComponent } from '@/app/sample/components';
import Vue from 'vue';

describe('SampleComponent.vue', () => {

it('truthy test', () => {
expect(true).eq(true);
});
Expand Down