Tasks: able to get and print tasks

This commit is contained in:
2023-12-31 01:39:42 +01:00
parent cf20935e01
commit 4c9765b4a3
10 changed files with 103 additions and 24 deletions

View File

@ -27,6 +27,8 @@ export default {
return {
username: AppStore.data.user.username
}
}
},
methods: {},
async created() {}
}
</script>

View File

@ -29,7 +29,6 @@ const durationInSeconds = computed(() =>
Math.floor((props.task.timeEnd - props.task.timeStart) / 1000)
)
const normalizedDuration = computed(() => formatDuration(durationInSeconds.value))
console.log(props.task.title)
</script>
<template>
@ -40,7 +39,6 @@ console.log(props.task.title)
class="title"
placeholder="What are you working on?"
:value="props.task.title"
:size="props.task.title.length + 1"
/>
</span>
<span>

View File

@ -1,4 +1,5 @@
export default {
api_url: 'http://localhost:6060/api/v1',
data: {
user: {
_id: '1234',
@ -7,26 +8,28 @@ export default {
},
newTask: {},
fetchedTasks: [
{
_id: 1,
title: 'frontend',
project: 'TiM',
client: 'Filip Rojek',
timeStart: 1703960133061,
timeEnd: 1703960141414
},
{
_id: 2,
title: 'setting up',
project: 'l2tp vpn',
client: 'IS Media',
timeStart: 1703960133061,
timeEnd: 1703960141414
}
//{
// _id: 1,
// title: 'Loading',
// project: 'Loading',
// client: 'Loading',
// timeStart: 1703960133061,
// timeEnd: 1703960141414
//}
]
},
// Methods that you need, for e.g fetching data from server etc.
fetchData() {
// fetch logic
async fetchData() {
try {
const response = await fetch(this.api_url + '/task/get')
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`)
}
const data = await response.json()
this.data.fetchedTasks = data
console.log('Received data:', data)
} catch (error) {
console.error('Error fetching data:', error)
}
}
}

View File

@ -25,6 +25,10 @@ export default {
return {
tasks: AppStore.data.fetchedTasks
}
},
async mounted() {
await AppStore.fetchData()
this.tasks = AppStore.data.fetchedTasks
}
}
</script>