<template>
	<div id="NotesPage">
		<div class="ui segment">
			<search-bar />
		</div>

		<input-notes v-if="activeNoteId != null" :noteid="activeNoteId"></input-notes>
	</div>
</template>

<script>
	
	//ajax calls
	import axios from 'axios';
	// import { mapGetters } from 'vuex'

	export default {
	name: 'Notes',
		components:{
			'input-notes': require('./InputNotes.vue').default,
			'search-bar': require('./SearchBar.vue').default
		},
		data () {
			return {
				notes: null,
				activeNoteId: null
			}
		},
		beforeMount(){
			this.$bus.$on('close_active_note', () => {
				this.activeNoteId = null
			})

			this.$bus.$on('open_note', openNoteId => {
				this.activeNoteId = openNoteId
			})
		},
		mounted: function() {
			//this.getLatest()
		},
		methods: {
			openNote(id){
				this.activeNoteId = id
			}
		}
	}
</script>