﻿<template>
    <tab :tabs="tabs" :header="header"></tab>
</template>

<script>
    Component(['@general/tab', '$data/courses'], function (tab, courses) {
        var params = this.$params;
        return {
            components: {
                tab
            },
            data: function () {
                var self = this;
                return {
                    tabs: [
                        {
                            title: 'محبوبترین',
                            component: '@general/slider',
                            params: function (callback) {
                                courses.top(8, params && params.community ? params.community : self.community, function (d) {
                                    callback({
                                        items: d,
                                        component: '@general/course-box',
                                        componentInput: 'course'
                                    });
                                });
                            }
                        },
                        {
                            title: 'جدیدترین',
                            component: '@general/slider',
                            params: function (callback) {
                                courses.latest(8, params && params.community ? params.community : self.community, function (d) {
                                    callback({
                                        items: d,
                                        component: '@general/course-box',
                                        componentInput: 'course'
                                    });
                                });
                            }
                        },
                        /*{
                            title: 'در حال تکمیل',
                            component: '@general/slider',
                            params: function (callback) {                                
                                courses.inProgress(8, params && params.community ? params.community : self.community, function (d) {
                                    callback({
                                        items: d,
                                        component: '@general/course-box',
                                        componentInput: 'course'
                                    });
                                });
                            }
                        },*/
                    ]
                }
            },
            props: {
                community: String,
                header: String
            }
        }
    });
</script>