|
1 | 1 | <template>
|
2 | 2 | <div class="flex flex-col max-w-md gap-2 mx-auto">
|
3 | 3 | <div class="flex flex-col gap-2">
|
4 |
| - <template v-for="category in categories"> |
| 4 | + <!-- <template v-for="userProfile in userProfiles"> |
5 | 5 | <div class="flex justify-between p-2 rounded bg-base-100">
|
6 |
| - <span class="text-base-content">{{ category.name }} ({{ category.num_torrents }})</span> |
7 |
| - <button :data-cy="getDeleteButtonDataCy(category.name)" class="text-error-content hover:text-error" @click="deleteCategory(category.name)"> |
8 |
| - Delete |
9 |
| - </button> |
| 6 | + <span class="text-base-content">{{ userProfile.username }} ({{ userProfile.email }})</span> |
10 | 7 | </div>
|
11 |
| - </template> |
12 |
| - </div> |
13 |
| - <div class="flex gap-2"> |
14 |
| - <input v-model="newCategory" data-cy="add-category-input" class="w-full input input-bordered" type="text"> |
15 |
| - <button data-cy="add-category-button" class="btn btn-primary" :class="{ 'loading': addingCategory }" :disabled="addingCategory || !newCategory" @click="addCategory"> |
16 |
| - Add category |
17 |
| - </button> |
| 8 | + </template> --> |
| 9 | + <UserTable :user-profiles="userProfiles" /> |
18 | 10 | </div>
|
19 | 11 | </div>
|
20 | 12 | </template>
|
21 | 13 |
|
22 | 14 | <script setup lang="ts">
|
23 |
| -import { ref } from "vue"; |
24 |
| -import { notify } from "notiwind-ts"; |
25 |
| -import { getCategories, useCategories, useRestApi } from "#imports"; |
26 |
| -
|
27 |
| -const categories = useCategories(); |
28 |
| -const rest = useRestApi().value; |
| 15 | +import { getUserProfiles, useUserProfiles } from "#imports"; |
29 | 16 |
|
30 |
| -const newCategory = ref(""); |
31 |
| -const addingCategory = ref(false); |
| 17 | +const userProfiles = useUserProfiles(); |
32 | 18 |
|
33 | 19 | onBeforeMount(() => {
|
34 |
| - getCategories(); |
| 20 | + getUserProfiles(); |
35 | 21 | });
|
36 |
| -
|
37 |
| -function getDeleteButtonDataCy (name: string) { |
38 |
| - return "delete-category-" + name.toLowerCase().replace(/ /g, "-"); |
39 |
| -} |
40 |
| -
|
41 |
| -function addCategory () { |
42 |
| - if (newCategory.value) { |
43 |
| - addingCategory.value = true; |
44 |
| -
|
45 |
| - rest.category.addCategory(newCategory.value) |
46 |
| - .then(() => { |
47 |
| - getCategories(); |
48 |
| - }) |
49 |
| - .catch((err) => { |
50 |
| - notify({ |
51 |
| - group: "error", |
52 |
| - title: "Error", |
53 |
| - text: `Trying to add the category. ${err.message}.` |
54 |
| - }, 10000); |
55 |
| - }) |
56 |
| - .finally(() => { |
57 |
| - addingCategory.value = false; |
58 |
| - }); |
59 |
| - } |
60 |
| -} |
61 |
| -
|
62 |
| -function deleteCategory (category: string) { |
63 |
| - if (confirm(`Are you sure you want to delete ${category}?`)) { |
64 |
| - rest.category.deleteCategory(category) |
65 |
| - .then(() => { |
66 |
| - getCategories(); |
67 |
| - }) |
68 |
| - .catch((err) => { |
69 |
| - notify({ |
70 |
| - group: "error", |
71 |
| - title: "Error", |
72 |
| - text: `Trying to delete the category. ${err.message}.` |
73 |
| - }, 10000); |
74 |
| - }); |
75 |
| - } |
76 |
| -} |
77 | 22 | </script>
|
0 commit comments