Skip to content

Commit 03ed6fc

Browse files
committed
refactor: [#658] styled palceholder user tab for the admin panel
1 parent dd6af08 commit 03ed6fc

File tree

1 file changed

+7
-62
lines changed

1 file changed

+7
-62
lines changed

pages/admin/settings/users.vue

Lines changed: 7 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,22 @@
11
<template>
22
<div class="flex flex-col max-w-md gap-2 mx-auto">
33
<div class="flex flex-col gap-2">
4-
<template v-for="category in categories">
4+
<!-- <template v-for="userProfile in userProfiles">
55
<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>
107
</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" />
1810
</div>
1911
</div>
2012
</template>
2113

2214
<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";
2916
30-
const newCategory = ref("");
31-
const addingCategory = ref(false);
17+
const userProfiles = useUserProfiles();
3218
3319
onBeforeMount(() => {
34-
getCategories();
20+
getUserProfiles();
3521
});
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-
}
7722
</script>

0 commit comments

Comments
 (0)