2018-11-03 14:48:42 +05:30
|
|
|
<template>
|
2019-02-26 16:48:49 +05:30
|
|
|
<button v-if="isLoggedIn" class='btn btn-primary btn-md' @click="primaryAction()">{{ buttonName }}</button>
|
|
|
|
<a v-else class='btn btn-primary btn-md' href="/login#signup">{{ buttonName }}</a>
|
2018-11-03 14:48:42 +05:30
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
export default {
|
2018-11-13 17:24:07 +05:30
|
|
|
name: "TopSectionButton",
|
2018-11-03 14:48:42 +05:30
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
buttonName: '',
|
2018-11-13 16:47:46 +05:30
|
|
|
isLoggedIn: lms.store.checkLogin(),
|
2018-11-03 18:03:01 +05:30
|
|
|
nextContent: '',
|
|
|
|
nextContentType: '',
|
|
|
|
nextCourse: '',
|
|
|
|
link: '',
|
2018-11-03 14:48:42 +05:30
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
2018-11-19 15:12:39 +05:30
|
|
|
this.computeButtons()
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
computeButtons(){
|
|
|
|
if(this.isLoggedIn){
|
2019-03-27 18:14:59 +05:30
|
|
|
this.buttonName = 'Explore Programs'
|
2018-11-07 22:12:55 +05:30
|
|
|
}
|
2018-11-19 15:12:39 +05:30
|
|
|
else{
|
|
|
|
this.buttonName = 'Sign Up'
|
2018-11-03 16:14:34 +05:30
|
|
|
}
|
2018-11-19 15:12:39 +05:30
|
|
|
},
|
2018-11-07 22:12:55 +05:30
|
|
|
primaryAction() {
|
2018-11-03 16:14:34 +05:30
|
|
|
if(this.$route.name == 'home'){
|
2019-03-27 18:14:59 +05:30
|
|
|
this.$router.push('List/Program');
|
2018-11-03 16:14:34 +05:30
|
|
|
}
|
2018-11-19 17:08:40 +05:30
|
|
|
else if(this.$route.name == 'program' && lms.store.enrolledPrograms.includes(this.$route.params.program_name)){
|
2018-11-12 12:50:54 +05:30
|
|
|
this.$router.push({ name: 'content', params: { program_name: this.$route.params.program_name, course: this.nextCourse, type: this.nextContentType, content: this.nextContent}})
|
2018-11-03 14:48:42 +05:30
|
|
|
}
|
2018-11-07 22:12:55 +05:30
|
|
|
else {
|
2018-11-20 17:36:57 +05:30
|
|
|
lms.call("enroll_in_program",
|
|
|
|
{
|
|
|
|
program_name: this.$route.params.program_name,
|
|
|
|
student_email_id: frappe.session.user
|
|
|
|
}
|
|
|
|
)
|
2018-11-13 16:47:46 +05:30
|
|
|
lms.store.updateEnrolledPrograms()
|
2018-11-07 22:12:55 +05:30
|
|
|
}
|
|
|
|
},
|
2018-11-03 14:48:42 +05:30
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|