2017-05-13 02:54:12 +10:00
|
|
|
const UserFinder = {
|
|
|
|
data: () => ({
|
2017-06-04 06:42:54 +10:00
|
|
|
username: undefined,
|
2017-09-11 03:46:42 +10:00
|
|
|
hidden: true,
|
|
|
|
error: false,
|
|
|
|
loading: false
|
2017-05-13 02:54:12 +10:00
|
|
|
}),
|
|
|
|
methods: {
|
|
|
|
findUser (username) {
|
2017-09-11 03:46:42 +10:00
|
|
|
this.loading = true
|
2017-05-13 02:54:12 +10:00
|
|
|
this.$store.state.api.backendInteractor.externalProfile(username)
|
|
|
|
.then((user) => {
|
2017-09-11 03:46:42 +10:00
|
|
|
this.loading = false
|
|
|
|
this.hidden = true
|
2017-05-13 02:54:12 +10:00
|
|
|
if (!user.error) {
|
|
|
|
this.$store.commit('addNewUsers', [user])
|
|
|
|
this.$router.push({name: 'user-profile', params: {id: user.id}})
|
2017-09-11 03:46:42 +10:00
|
|
|
} else {
|
|
|
|
this.error = true
|
2017-05-13 02:54:12 +10:00
|
|
|
}
|
|
|
|
})
|
2017-06-04 06:42:54 +10:00
|
|
|
},
|
|
|
|
toggleHidden () {
|
|
|
|
this.hidden = !this.hidden
|
2017-09-11 03:46:42 +10:00
|
|
|
},
|
|
|
|
dismissError () {
|
|
|
|
this.error = false
|
2017-05-13 02:54:12 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default UserFinder
|