Skip to content

Commit 325cfd8

Browse files
committed
57
1 parent c8eb6f4 commit 325cfd8

File tree

4 files changed

+43
-8
lines changed

4 files changed

+43
-8
lines changed

src/pages/todos/_id.vue

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ export default {
7575
const originalTodo = ref(null);
7676
const loading = ref(true);
7777
const {
78-
toastMessage,
79-
toastAlertType,
80-
showToast,
81-
triggerToast
82-
} = useToast();
78+
toastMessage,
79+
toastAlertType,
80+
showToast,
81+
triggerToast
82+
} = useToast();
8383
8484
const todoId = route.params.id
8585
@@ -115,8 +115,6 @@ export default {
115115
116116
getTodo();
117117
118-
119-
120118
const onSave = async () => {
121119
try {
122120
const res = await axios.put(`

src/pages/todos/create/index.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<template>
2+
Create Page
3+
</template>
4+
5+
<script>
6+
export default {
7+
8+
}
9+
</script>
10+
11+
<style>
12+
13+
</style>

src/pages/todos/index.vue

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
<template>
22
<div>
3-
<h2>To-Do List</h2>
3+
<div class="d-flex justify-content-between mb-3">
4+
<h2>To-Do List</h2>
5+
<button
6+
class="btn btn-primary"
7+
@click="moveToCreatePage"
8+
>
9+
Create Todo
10+
</button>
11+
</div>
12+
413
<input
514
class="form-control"
615
type="text"
@@ -56,6 +65,7 @@ import TodoList from '@/components/TodoList.vue';
5665
import axios from 'axios';
5766
import Toast from '@/components/Toast.vue';
5867
import { useToast } from '@/composables/toast';
68+
import {useRouter} from 'vue-router';
5969
6070
export default {
6171
components: {
@@ -64,6 +74,7 @@ export default {
6474
Toast,
6575
},
6676
setup() {
77+
const router = useRouter();
6778
const todos = ref([]);
6879
const error = ref('');
6980
const numberOfTodos = ref(0);
@@ -146,6 +157,12 @@ export default {
146157
147158
};
148159
160+
const moveToCreatePage = () => {
161+
router.push({
162+
name: 'TodoCreate',
163+
})
164+
};
165+
149166
let timeout = null;
150167
const searchTodo = () => {
151168
clearTimeout(timeout);
@@ -173,6 +190,7 @@ export default {
173190
toastMessage,
174191
toastAlertType,
175192
showToast,
193+
moveToCreatePage,
176194
};
177195
}
178196
}

src/router/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { createRouter, createWebHistory } from 'vue-router';
22
import Home from '../pages/index.vue';
33
import Todos from '../pages/todos/index.vue';
44
import Todo from '../pages/todos/_id.vue';
5+
import TodoCreate from '../pages/todos/create/index.vue';
56

67
const router = createRouter({
78
history: createWebHistory(),
@@ -16,6 +17,11 @@ const router = createRouter({
1617
name: 'Todos',
1718
component: Todos
1819
},
20+
{
21+
path: '/todos/create',
22+
name: 'TodoCreate',
23+
component: TodoCreate
24+
},
1925
{
2026
path: '/todos/:id',
2127
name: 'Todo',

0 commit comments

Comments
 (0)