<script setup>
	import { formatSeconds } from '../libs/time.js'
	import { onMounted, ref, defineExpose } from 'vue'

	const practiceStatus = ref({})

	const loadData = async () => {
		const response = await fetch(import.meta.env.VITE_PRACTICE_TRACKER_API_URL+'status')
		practiceStatus.value = await response.json()
	}

	onMounted(loadData)
	defineExpose({loadData})
</script>
<template>
	<h2 @click="loadData">Practice Status</h2>
	<h3>Time Left to Practice Today</h3>
	{{formatSeconds(practiceStatus.seconds_left_to_practice_today)}}
	<h3>Extra Time to Accumulate</h3>
	{{formatSeconds(practiceStatus.seconds_left_to_get_ahead)}}
	<h3>Time Practiced Today</h3>
	{{formatSeconds(practiceStatus.seconds_practiced)}}
</template>
