-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
65 lines (61 loc) · 2.66 KB
/
index.html
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
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Tu licencia de navegación online</title>
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap" rel="stylesheet">
<script src='https://unpkg.com/vue/dist/vue.js'></script>
</head>
<body class="bg-gray-900">
<div id="app" class="p-16 flex justify-center align-center min-h-screen">
<div class="flex items-center w-full rounded-xl">
<div class="px-12 pt-8 pb-12 max-w-4xl w-full mx-auto bg-gray-100 bg-opacity-30 rounded-xl shadow-2xl">
<h1 class="w-full mx-auto text-2xl font-bold">TODO</h1>
<div class="mt-6">
<input v-model="currentTask" class="px-2 py-2 rounded-lg" type="text" name="task" />
<button @click="createTodo" class="ml-2 bg-blue-500 rounded-xl px-4 py-2">Add</button>
</div>
<div class="mt-6" v-for="task in tasks" :key="task">
<p>{{ task.data.title }}</p>
</div>
{{ currentTask }}
</div>
</div>
</div>
<script>
var app = new Vue({
el: '#app',
data: {
currentTask: '',
tasks: ['comprar pan', 'cortar pelo', 'pasear gato']
},
methods: {
async createTodo(data) {
return fetch('/.netlify/functions/todos-create', {
body: JSON.stringify({title: this.currentTask}),
method: 'POST'
}).then(response => {
this.currentTask = '';
return response.json();
});
}
},
computed: {
tasksData () {
return this.tasks.map(function(task) {
return task.data;
})
}
},
async mounted() {
const response = await fetch('/.netlify/functions/read-all-todos');
const tasks = await response.json();
this.tasks = tasks;
}
});
</script>
</body>
</html>