This commit is contained in:
Kseninia Mikhaylova 2024-04-25 15:17:27 +03:00
parent dc5c259336
commit dd0f3adc79
1 changed files with 8 additions and 5 deletions

View File

@ -17,13 +17,16 @@ const item = computed(() => {
return null return null
} }
}) })
const getData = async ()=>{ const getData = async () => {
const res = await fetch(`${baseUrl}/api/sheet`) const res = await fetch(`${baseUrl}/api/sheet`)
const result = await res.json() const result = await res.json()
if (result.status == "success") { if (result.status == "success") {
data.value = result.data data.value = result.data
} }
} }
const formatNumber = (n: string) => {
return Math.ceil(parseFloat(n.replace(',', '.')))
}
onMounted(async () => { onMounted(async () => {
await getData() await getData()
setInterval(async () => { setInterval(async () => {
@ -42,11 +45,11 @@ onMounted(async () => {
<div class="item-wrapper"> <div class="item-wrapper">
<div class="item" v-if="item"> <div class="item" v-if="item">
{{ item.name.slice(0, 2).join(' ') }}<br /> {{ item.name.slice(0, 2).join(' ') }}<br />
{{ item.hours }} / {{ Math.ceil(parseFloat(item.calendar)) }} {{ formatNumber(item.hours) }} / {{ formatNumber(item.calendar) }}
<strong :class="{ <strong :class="{
'high': parseInt(item.percent) >= 70, 'high': parseInt(item.percent) >= 70,
'medium': parseInt(item.percent) >= 35 && parseInt(item.percent) < 70, 'medium': parseInt(item.percent) >= 35 && parseInt(item.percent) < 70,
}">({{ item.percent }}%)</strong> }">({{ formatNumber(item.percent) }}%)</strong>
</div> </div>
</div> </div>
</template> </template>