From fd3f6de51a082dcd72c2ef557747e031ef7b9c4a Mon Sep 17 00:00:00 2001 From: Zephyrrus Date: Thu, 9 Jul 2020 02:24:40 +0300 Subject: refactor: refactor most of the admin pages to use the store instead of internal states --- src/site/pages/register.vue | 57 +++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 25 deletions(-) (limited to 'src/site/pages/register.vue') diff --git a/src/site/pages/register.vue b/src/site/pages/register.vue index 1216dc1..7cf4573 100644 --- a/src/site/pages/register.vue +++ b/src/site/pages/register.vue @@ -31,19 +31,30 @@ @keyup.enter.native="register" /> -

- - Already have an account? - - -

+
+ +
+
+ + Already have an account? + +
+
+ +
+

+ + Register + +

+
+
@@ -70,32 +81,28 @@ export default { methods: { async register() { if (this.isLoading) return; + if (!this.username || !this.password || !this.rePassword) { - this.$store.dispatch('alert', { - text: 'Please fill all fields before attempting to register.', - error: true, - }); + this.$notifier.error('Please fill all fields before attempting to register.'); return; } if (this.password !== this.rePassword) { - this.$store.dispatch('alert', { - text: "Passwords don't match", - error: true, - }); + this.$notifier.error('Passwords don\'t match'); return; } this.isLoading = true; try { - const response = await this.$axios.$post('auth/register', { + const response = await this.$store.dispatch('auth/register', { username: this.username, password: this.password, }); - this.$store.dispatch('alert', { text: response.message }); - return this.$router.push('/login'); + this.$notifier.success(response.message); + this.$router.push('/login'); + return; } catch (error) { - // + this.$notifier.error(error.message); } finally { this.isLoading = false; } -- cgit v1.2.3