56 lines
1.7 KiB
Vue
Raw Normal View History

2018-11-03 14:48:42 +05:30
<template>
2018-11-03 18:03:01 +05:30
<button v-if="isLoggedIn" class='btn btn-primary btn-lg' @click="$router.push(getUrl())">{{ buttonName }}</button>
2018-11-03 16:14:34 +05:30
<a v-else class='btn btn-primary btn-lg' href="/login#signup">{{ buttonName }}</a>
2018-11-03 14:48:42 +05:30
</template>
<script>
export default {
name: "AcademyTopSectionButton",
data() {
return {
buttonName: '',
2018-11-03 18:03:01 +05:30
isLoggedIn: this.$root.$data.checkLogin(),
nextContent: '',
nextContentType: '',
nextCourse: '',
link: '',
2018-11-03 14:48:42 +05:30
}
},
mounted() {
2018-11-03 18:03:01 +05:30
if(this.isLoggedIn && this.$route.name == 'program'){
frappe.call({
method: "erpnext.www.academy.get_continue_data",
args: {
program_name: this.$route.params.code
}
}).then( r => {
this.nextContent = r.message.content,
this.nextContentType = r.message.content_type,
this.nextCourse = r.message.course
})
}
if(this.isLoggedIn){
2018-11-03 16:14:34 +05:30
if(this.$route.name == 'home'){
this.buttonName = 'Explore Courses'
}
else if(this.$route.name == 'program'){
this.buttonName = 'Start Course'
}
}
else{
this.buttonName = 'Sign Up'
}
},
methods: {
getUrl() {
if(this.$route.name == 'home'){
return ''
}
else if(this.$route.name == 'program'){
2018-11-03 18:03:01 +05:30
this.link = this.$route.params.code + '/' + this.nextCourse + '/' + this.nextContentType + '/' + this.nextContent
return this.link
2018-11-03 14:48:42 +05:30
}
}
}
};
</script>