text: 'use strict';var UserPage={template:'\n        <div style="margin: 30px 0">\n            <editor-modal v-on:add-new-habit="addNewHabit"></editor-modal>\n\n            <router-view :active-habits="activeHabits" :ended-habits="endedHabits" :mark-complete="markComplete" :remove-habit="removeHabit" :loading="loading"></router-view>\n\n            <div class="fixed-action-btn">\n                <a class="btn-floating btn-large purple waves-effect waves-light" href="#editorModal">\n                    <i class="large material-icons">add</i>\n                </a>\n            </div>\n        </div>\n    ',mounted:function mounted(){this.fetchAllHabits()},methods:{fetchAllHabits:function fetchAllHabits(){var a=this;$.ajax({type:'GET',url:'/habits/all',success:function success(b){if(b.success){var c=[],d=[];b.bitBreaks.forEach(function(e){e.ended?d.push(new BitBreaks(e)):c.push(new BitBreaks(e))}),a.activeHabits=c,a.endedHabits=d,a.loading=!1}else messageUtility.showMessages(b.message),store.commit('removeUser'),router.push({path:'/'})},error:function error(b){messageUtility.handleError(b)}})},addNewHabit:function addNewHabit(a){this.activeHabits.push(new BitBreaks(a))},removeHabit:function removeHabit(a){var b=this;$.ajax({type:'DELETE',url:'/habits/delete/'+a.hash,contentType:'application/json',success:function success(c){c.success?(b.activeHabits=b.activeHabits.filter(function(d){return d.hash!==a.hash}),b.endedHabits=b.endedHabits.filter(function(d){return d.hash!==a.hash}),b.potentiallyRemovableHabit=null):messageUtility.showMessages(c.message)},error:function error(c){messageUtility.handleError(c)}})},markComplete:function markComplete(a){var b=this,c=a.hash,d=new Date,e=d.getTimezoneOffset();$.ajax({type:'PATCH',contentType:'application/json',url:'/habits/endhabit/'+c+'?timezone='+e,success:function success(f){f.success?(b.activeHabits=b.activeHabits.filter(function(g){return g.hash!==c}),b.endedHabits.push(new BitBreaks(f.bitBreak))):messageUtility.showMessages(f.message)},error:function error(f){messageUtility.handleError(f)}})}},data:function data(){return{activeHabits:[],endedHabits:[],loading:!0}}};