From fd3f6de51a082dcd72c2ef557747e031ef7b9c4a Mon Sep 17 00:00:00 2001
From: Zephyrrus <krisztian1997@gmail.com>
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" />
 					</b-field>
 
-					<p class="control has-addons is-pulled-right">
-						<router-link
-							to="/login"
-							class="is-text">
-							Already have an account?
-						</router-link>
-						<button
-							class="button is-primary big ml1"
-							:disabled="isLoading"
-							@click="register">
-							Register
-						</button>
-					</p>
+					<div class="level">
+						<!-- Left side -->
+						<div class="level-left">
+							<div class="level-item">
+								<router-link
+									to="/login"
+									class="is-text">
+									Already have an account?
+								</router-link>
+							</div>
+						</div>
+						<!-- Right side -->
+						<div class="level-right">
+							<p class="level-item">
+								<b-button
+									size="is-medium"
+									type="is-lolisafe"
+									:disabled="isLoading"
+									@click="register">
+									Register
+								</b-button>
+							</p>
+						</div>
+					</div>
 				</div>
 			</div>
 		</div>
@@ -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

