fix: batch self enrollment

This commit is contained in:
Jannat Patel
2024-10-11 19:16:40 +05:30
parent 961d5ec77b
commit eb350c5a20
5 changed files with 49 additions and 12 deletions

View File

@@ -140,6 +140,7 @@ const removeAssessments = (selections, unselectAll) => {
}
const getRowRoute = (row) => {
console.log(row)
if (row.assessment_type == 'LMS Assignment') {
if (row.submission) {
return {

View File

@@ -75,6 +75,7 @@
variant="solid"
class="w-full mt-2"
v-else-if="batch.data.allow_self_enrollment && batch.data.seats_left"
@click="enrollInBatch()"
>
{{ __('Enroll Now') }}
</Button>
@@ -97,11 +98,13 @@
</template>
<script setup>
import { inject, computed } from 'vue'
import { Badge, Button } from 'frappe-ui'
import { Badge, Button, createResource } from 'frappe-ui'
import { BookOpen, Clock, Globe } from 'lucide-vue-next'
import { formatNumberIntoCurrency, formatTime } from '@/utils'
import { formatNumberIntoCurrency, formatTime, showToast } from '@/utils'
import DateRange from '@/components/Common/DateRange.vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const user = inject('$user')
const props = defineProps({
@@ -111,6 +114,36 @@ const props = defineProps({
},
})
const enroll = createResource({
url: 'lms.lms.utils.enroll_in_batch',
makeParams(values) {
return {
batch: props.batch.data.name,
}
},
})
const enrollInBatch = () => {
enroll.submit(
{},
{
onSuccess(data) {
showToast(
__('Success'),
__('You have been enrolled in this batch'),
'check'
)
router.push({
name: 'Batch',
params: {
batchName: props.batch.data.name,
},
})
},
}
)
}
const seats_left = computed(() => {
if (props.batch.data?.seat_count) {
return props.batch.data?.seat_count - props.batch.data?.students?.length

View File

@@ -85,7 +85,6 @@ const update = () => {
}
watch(props.data, (newData) => {
console.log(newData)
if (newData && !isDirty.value) {
isDirty.value = true
}