Browse Source

Moving user to Vuex, add app create button

Ecconia 7 years ago
parent
commit
775c20555f
3 changed files with 28 additions and 10 deletions
  1. 7 2
      src/App.vue
  2. 11 8
      src/store.js
  3. 10 0
      src/views/Applications.vue

+ 7 - 2
src/App.vue

@@ -31,15 +31,20 @@
 	export default {
 	export default {
 		data () {
 		data () {
 			return {
 			return {
-				user: null,
 				menu_entries: {
 				menu_entries: {
 					'Startpage': '/',
 					'Startpage': '/',
 					'Applications': '/applications',
 					'Applications': '/applications',
 					'Development Blog': '/devblog',
 					'Development Blog': '/devblog',
-				}
+				},
 			}
 			}
 		},
 		},
 
 
+		computed: {
+			user() {
+				return this.$store.state.user
+			},
+		},
+
 		components: {
 		components: {
 			MenuContainer
 			MenuContainer
 		},
 		},

+ 11 - 8
src/store.js

@@ -4,13 +4,16 @@ import Vuex from 'vuex'
 Vue.use(Vuex)
 Vue.use(Vuex)
 
 
 export default new Vuex.Store({
 export default new Vuex.Store({
-  state: {
+	strict: process.env.NODE_ENV !== 'production',
+	state: {
+		user: null,
+	},
+	mutations: {
+		setUser(state, user) {
+			state.user = user
+		}
+	},
+	actions: {
 
 
-  },
-  mutations: {
-
-  },
-  actions: {
-
-  }
+	}
 })
 })

+ 10 - 0
src/views/Applications.vue

@@ -3,6 +3,11 @@
 		<h1>Applications:</h1>
 		<h1>Applications:</h1>
 		<p>This area is basically the first big GOAL of the final product. Creating and Judging apps. The path to get here is quite long though, many other issues have to be solved first.</p>
 		<p>This area is basically the first big GOAL of the final product. Creating and Judging apps. The path to get here is quite long though, many other issues have to be solved first.</p>
 
 
+		<div v-if="getUser && getUser.rank === undefined">
+			<router-link to="/myapp" v-if="getUser.appstate === 0">Create application.</router-link>
+			<router-link to="/myapp" v-else-if="getUser.appstate === 1">Edit application.</router-link>
+		</div>
+
 		<div class="app-container">
 		<div class="app-container">
 			<router-link class="app-entry" :to="{ name: 'application', params: { id: app.id }}" v-for="app in apps" :key="app.id">
 			<router-link class="app-entry" :to="{ name: 'application', params: { id: app.id }}" v-for="app in apps" :key="app.id">
 				<p>Name: {{ app.playername }} </p>
 				<p>Name: {{ app.playername }} </p>
@@ -52,6 +57,11 @@
 		},
 		},
 		created () {
 		created () {
 		},
 		},
+		computed: {
+			getUser() {
+				return this.$store.state.user
+			},
+		},
 		methods: {
 		methods: {
 			readableTime(timestamp) {
 			readableTime(timestamp) {
 				let date = new Date(timestamp * 1000)
 				let date = new Date(timestamp * 1000)