-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddTask.vue
76 lines (74 loc) · 1.66 KB
/
addTask.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<template>
<aside class="mx-auto flex justify-between mt-24 px-4">
<label for="add task" class="flex-1">
<input
type="text"
v-model="taskadded"
name="add task"
class="
todo-add-task-input
px-4
py-2
placeholder-blueGray-300
text-blueGray-600
bg-white
rounded
text-sm
border border-blueGray-300
outline-none
focus:outline-none focus:ring
w-full
"
placeholder="Enter Task"
/>
</label>
<button
type="button"
class="
todo-add-task
bg-transparent
hover:bg-green-500
text-green-700 text-sm
hover:text-white
px-3
py-2
border border-green-500
hover:border-transparent
rounded
"
@click="addTask"
>
Add Task
</button>
</aside>
</template>
<script>
import { defineComponent } from '@nuxtjs/composition-api'
export default defineComponent({
data() {
return{
taskadded: ""
}
},
emits: ['newTask'],
methods: {
addTask() {
if (this.taskadded == "" ){
this.$toast.error("Empty tasks can't be added")
}
else if (this.taskadded.length > 255 ){
this.$toast.error("Maximum length of task should be 255")
}
else{
const task = {
title: this.taskadded
}
this.$axios.post('todo/create/', task , {headers: { Authorization: 'Token ' + this.$store.getters.token}})
this.$toast.success("Task added successfully.")
this.$emit('newTask')
}
this.taskadded = ""
},
},
})
</script>