76 lines
2.2 KiB
Vue
Raw Normal View History

2018-10-30 18:25:49 +05:30
<template>
<div class='card-deck mt-5'>
<div class="card">
2018-11-01 17:19:21 +05:30
<img :src="program.hero_image" style='height: 150px; width: auto'>
2018-10-30 18:25:49 +05:30
<div class='card-body'>
<router-link :to="'/Program/' + program.name">
2018-11-01 17:19:21 +05:30
<h5 class='card-title'>{{ program.program_name }}</h5>
2018-10-30 18:25:49 +05:30
</router-link>
<div v-html="program.description"></div>
</div>
<div class='card-footer text-right'>
<!-- <a class='video-btn btn btn-secondary btn-sm' data-toggle="modal" data-src=" insert jinja stuff here " data-target="#myModal">Watch Intro</a>&nbsp;&nbsp; -->
2018-11-09 18:25:19 +05:30
<a-button
v-if="enrolled"
type="primary"
size="sm"
:route="programPageRoute"
>
{{ buttonName }}
</a-button>
<a v-else-if="isLogin" class='btn btn-secondary btn-sm' @click="enroll()">Enroll</a>
2018-11-05 11:01:37 +05:30
<a v-else class='btn btn-secondary btn-sm' href="/login#signup">Sign Up</a>
2018-10-30 18:25:49 +05:30
</div>
</div>
</div>
</template>
<script>
2018-11-09 18:25:19 +05:30
import AButton from './Button.vue';
2018-10-30 18:25:49 +05:30
export default {
2018-11-09 18:25:19 +05:30
props: ['program', 'enrolled'],
2018-11-13 17:24:07 +05:30
name: "ProgramCard",
2018-10-30 18:25:49 +05:30
data() {
return {
2018-11-13 16:47:46 +05:30
isLogin: lms.store.isLogin
2018-10-30 18:25:49 +05:30
};
},
2018-11-09 18:25:19 +05:30
created() {
2018-10-30 18:25:49 +05:30
},
2018-11-03 18:03:24 +05:30
methods: {
enroll() {
2018-11-13 16:47:46 +05:30
lms.call('enroll_in_program', {
2018-11-09 18:25:19 +05:30
program_name: this.program.name,
}).then(
2018-11-13 16:47:46 +05:30
lms.store.enrolledPrograms.add(this.program.name),
lms.store.updateEnrolledPrograms(),
2018-11-09 18:25:19 +05:30
this.router.push('Program/' + this.program.name)
)
2018-11-08 13:01:55 +05:30
}
2018-11-09 11:47:09 +05:30
},
2018-11-08 13:01:55 +05:30
computed: {
buttonName() {
2018-11-09 18:25:19 +05:30
if(this.enrolled){
2018-11-08 13:01:55 +05:30
return "Start Course"
}
else {
return "Enroll"
}
2018-11-09 18:25:19 +05:30
},
programPageRoute() {
return `Program/${this.program.name}`
},
isEnrolled() {
2018-11-13 16:47:46 +05:30
return lms.store.enrolledPrograms.has(this.program.name)
2018-11-03 18:03:24 +05:30
}
2018-11-09 18:25:19 +05:30
},
components: {
AButton
2018-11-03 18:03:24 +05:30
}
2018-10-30 18:25:49 +05:30
};
2018-11-01 17:19:21 +05:30
</script>
<style lang="css" scoped>
a {
text-decoration: none;
}
</style>