
myVueMixin.push({
    data() {
        return {
            presenceConfig: null,
        }
    },
    mounted() {
        this.loadPresenceConfig();
        this.$store.dispatch('config/loadPerson');
        this.$store.dispatch('config/loadPengumuman');
        this.$store.dispatch('config/loadJadwalPelajaran');
    },

    computed: {
        reqiuredPresence() {
            if (this.presenceConfig == null) return false;
            if (this.presenceConfig.libur) return false;
            if (this.presenceConfig.present == null) return true;
            if (this.presenceConfig.present.timeOut) return false;
            if (!this.presenceConfig.present.timeIn) return true;
            if (myMoment({ tz: this.$store.state.config.timezone }).format("DD/MM/Y HH:mm:ss") > this.presenceConfig.timeOut) return true;
            return false;
        }
    },
    methods: {
        loadPresenceConfig() {
            axios({
                method: 'GET',
                url: this.$store.state.config.base_url + '/daily-presence/map/config',
            }).then((response) => {

                if (!isObject(response.data)) return setTimeout(() => this.loadPresenceConfig(), 5000);
                this.presenceConfig = response.data;
            }, (error) => { });
        },
    }
})