Vue.component('patientSubscriptions', {

    props: [
        'routes',
    ],

    data: function() {
        return {
            subscriptions: [],
            loading: false,
            add: false,
            showAll: false,
        };
    },

    mounted: function() {
        this.init();
    },

    computed: {
        canLoadAll() {
            return this.subscriptions.length > 1 && !this.showAll;
        },
        activeSubscription() {
            if (!this.subscriptions.length) {
                return null;
            }
            for (let i = 0; i < this.subscriptions.length; i++) {
                if (this.subscriptions[i].status === 'active') {
                    return this.subscriptions[i];
                }
            }
            return null;
        },
    },

    methods: {
        init() {
            this.load();
        },
        addTreatment() {
            this.add = true;
        },
        cancel() {
            this.add = false;
        },
        load() {
            /*
            this.loading = true;
            let vm = this;

            this.$http.post(this.routes['admin-reviews-load'], [])
                .then((response) => {

                    const data = response.data;

                    vm.reviews = data.reviews;
                    vm.loading = false;
                });

             */
        },
        loadAll() {
            this.showAll = true;
        }
    },
});
