2018-10-30 12:55:49 +00:00
|
|
|
<template>
|
|
|
|
<div class='card-deck mt-5'>
|
|
|
|
<div class="card">
|
2018-11-15 05:43:56 +00:00
|
|
|
<img v-if="program.hero_image" :src="program.hero_image" style='height: 150px; width: auto'>
|
2018-10-30 12:55:49 +00:00
|
|
|
<div class='card-body'>
|
|
|
|
<router-link :to="'/Program/' + program.name">
|
2018-11-01 11:49:21 +00:00
|
|
|
<h5 class='card-title'>{{ program.program_name }}</h5>
|
2018-10-30 12:55:49 +00:00
|
|
|
</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> -->
|
2018-11-09 12:55:19 +00:00
|
|
|
<a-button
|
|
|
|
v-if="enrolled"
|
|
|
|
type="primary"
|
|
|
|
size="sm"
|
|
|
|
:route="programPageRoute"
|
|
|
|
>
|
|
|
|
{{ buttonName }}
|
|
|
|
</a-button>
|
2018-11-15 05:43:56 +00:00
|
|
|
<a v-else-if="isLogin" class='btn btn-secondary btn-sm' @click="enroll()">{{ enrollButton }}</a>
|
2018-11-05 05:31:37 +00:00
|
|
|
<a v-else class='btn btn-secondary btn-sm' href="/login#signup">Sign Up</a>
|
2018-10-30 12:55:49 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
2018-11-09 12:55:19 +00:00
|
|
|
import AButton from './Button.vue';
|
2018-10-30 12:55:49 +00:00
|
|
|
export default {
|
2018-11-09 12:55:19 +00:00
|
|
|
props: ['program', 'enrolled'],
|
2018-11-13 11:54:07 +00:00
|
|
|
name: "ProgramCard",
|
2018-10-30 12:55:49 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2018-11-15 05:43:56 +00:00
|
|
|
isLogin: lms.store.isLogin,
|
|
|
|
enrollButton: 'Enroll Now',
|
|
|
|
programRoute: { name: 'program', params: { program_name: this.program.name }}
|
2018-10-30 12:55:49 +00:00
|
|
|
};
|
|
|
|
},
|
2018-11-09 12:55:19 +00:00
|
|
|
created() {
|
2018-10-30 12:55:49 +00:00
|
|
|
},
|
2018-11-03 12:33:24 +00:00
|
|
|
methods: {
|
|
|
|
enroll() {
|
2018-11-15 05:43:56 +00:00
|
|
|
this.enrollButton = 'Enrolling...'
|
2018-11-13 11:17:46 +00:00
|
|
|
lms.call('enroll_in_program', {
|
2018-11-09 12:55:19 +00:00
|
|
|
program_name: this.program.name,
|
2018-11-15 05:43:56 +00:00
|
|
|
}).then(data => {
|
|
|
|
console.log(data)
|
2018-11-23 11:46:33 +00:00
|
|
|
lms.store.updateEnrolledPrograms()
|
2018-11-15 05:43:56 +00:00
|
|
|
this.$router.push(this.programRoute)
|
|
|
|
})
|
2018-11-08 07:31:55 +00:00
|
|
|
}
|
2018-11-09 06:17:09 +00:00
|
|
|
},
|
2018-11-08 07:31:55 +00:00
|
|
|
computed: {
|
|
|
|
buttonName() {
|
2018-11-09 12:55:19 +00:00
|
|
|
if(this.enrolled){
|
2018-11-08 07:31:55 +00:00
|
|
|
return "Start Course"
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return "Enroll"
|
|
|
|
}
|
2018-11-09 12:55:19 +00:00
|
|
|
},
|
|
|
|
programPageRoute() {
|
2018-11-15 05:43:56 +00:00
|
|
|
return this.programRoute
|
2018-11-09 12:55:19 +00:00
|
|
|
},
|
|
|
|
isEnrolled() {
|
2018-11-19 11:38:40 +00:00
|
|
|
return lms.store.enrolledPrograms.includes(this.program.name)
|
2018-11-03 12:33:24 +00:00
|
|
|
}
|
2018-11-09 12:55:19 +00:00
|
|
|
},
|
|
|
|
components: {
|
|
|
|
AButton
|
2018-11-03 12:33:24 +00:00
|
|
|
}
|
2018-10-30 12:55:49 +00:00
|
|
|
};
|
2018-11-01 11:49:21 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="css" scoped>
|
|
|
|
a {
|
2018-11-15 05:43:56 +00:00
|
|
|
text-decoration: none;
|
|
|
|
}
|
|
|
|
a.btn-secondary {
|
|
|
|
color: white !important;
|
|
|
|
}
|
2018-11-01 11:49:21 +00:00
|
|
|
</style>
|