From 720ffaf0083564c85a07d66a6d303f34706add41 Mon Sep 17 00:00:00 2001
From: Zephyrrus <krisztian1997@gmail.com>
Date: Thu, 2 Jul 2020 02:50:55 +0300
Subject: feat: start refactoring the code to actually use vuex

This includes creating multiple stores as needed for components and removing all complex states from components (since all those states should be stored in vuex)
---
 src/site/pages/register.vue | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

(limited to 'src/site/pages/register.vue')

diff --git a/src/site/pages/register.vue b/src/site/pages/register.vue
index c102abd..92eb35a 100644
--- a/src/site/pages/register.vue
+++ b/src/site/pages/register.vue
@@ -42,6 +42,8 @@
 </template>
 
 <script>
+import { mapState } from 'vuex';
+
 export default {
 	name: 'Register',
 	data() {
@@ -52,11 +54,7 @@ export default {
 			isLoading: false
 		};
 	},
-	computed: {
-		config() {
-			return this.$store.state.config;
-		}
-	},
+	computed: mapState(['config', 'auth']),
 	metaInfo() {
 		return { title: 'Register' };
 	},
@@ -72,7 +70,7 @@ export default {
 			}
 			if (this.password !== this.rePassword) {
 				this.$store.dispatch('alert', {
-					text: 'Passwords don\'t match',
+					text: "Passwords don't match",
 					error: true
 				});
 				return;
-- 
cgit v1.2.3


From ad852de51a0d2dd5d29c08838d5a430c58849e74 Mon Sep 17 00:00:00 2001
From: Zephyrrus <krisztian1997@gmail.com>
Date: Wed, 8 Jul 2020 04:00:12 +0300
Subject: chore: linter the entire project using the new rules

---
 src/site/pages/register.vue | 37 +++++++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 14 deletions(-)

(limited to 'src/site/pages/register.vue')

diff --git a/src/site/pages/register.vue b/src/site/pages/register.vue
index 92eb35a..1216dc1 100644
--- a/src/site/pages/register.vue
+++ b/src/site/pages/register.vue
@@ -10,18 +10,21 @@
 			<div class="columns">
 				<div class="column is-4 is-offset-4">
 					<b-field>
-						<b-input v-model="username"
+						<b-input
+							v-model="username"
 							type="text"
 							placeholder="Username" />
 					</b-field>
 					<b-field>
-						<b-input v-model="password"
+						<b-input
+							v-model="password"
 							type="password"
 							placeholder="Password"
 							password-reveal />
 					</b-field>
 					<b-field>
-						<b-input v-model="rePassword"
+						<b-input
+							v-model="rePassword"
 							type="password"
 							placeholder="Re-type Password"
 							password-reveal
@@ -29,11 +32,17 @@
 					</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"
+						<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>
+							@click="register">
+							Register
+						</button>
 					</p>
 				</div>
 			</div>
@@ -51,7 +60,7 @@ export default {
 			username: null,
 			password: null,
 			rePassword: null,
-			isLoading: false
+			isLoading: false,
 		};
 	},
 	computed: mapState(['config', 'auth']),
@@ -64,23 +73,23 @@ export default {
 			if (!this.username || !this.password || !this.rePassword) {
 				this.$store.dispatch('alert', {
 					text: 'Please fill all fields before attempting to register.',
-					error: true
+					error: true,
 				});
 				return;
 			}
 			if (this.password !== this.rePassword) {
 				this.$store.dispatch('alert', {
 					text: "Passwords don't match",
-					error: true
+					error: true,
 				});
 				return;
 			}
 			this.isLoading = true;
 
 			try {
-				const response = await this.$axios.$post(`auth/register`, {
+				const response = await this.$axios.$post('auth/register', {
 					username: this.username,
-					password: this.password
+					password: this.password,
 				});
 
 				this.$store.dispatch('alert', { text: response.message });
@@ -90,7 +99,7 @@ export default {
 			} finally {
 				this.isLoading = false;
 			}
-		}
-	}
+		},
+	},
 };
 </script>
-- 
cgit v1.2.3


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

