Skip to content

Commit 471172d

Browse files
committed
fix(ui): fix UserList status field chip
- fixes the typing of IUser, replacing outdated `confirmed` with `status` - fixes the UI accordingly - simplifies the status chip conditional logic
1 parent 109856d commit 471172d

File tree

2 files changed

+16
-24
lines changed

2 files changed

+16
-24
lines changed

ui/admin/src/components/User/UserList.vue

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
<td :namespaces-test="item.namespaces">
3030
{{ item.namespaces }}
3131
</td>
32-
<td v-if="item.confirmed" class="pl-0">
33-
<v-chip class="ma-2" color="success" variant="text" prepend-icon="mdi-checkbox-marked-circle">
34-
Confirmed
35-
</v-chip>
36-
</td>
37-
<td v-else class="pl-0">
38-
<v-chip class="ma-2" color="warning" variant="text" prepend-icon="mdi-alert-circle">
39-
Not confirmed
32+
<td class="pl-0">
33+
<v-chip
34+
class="ma-2"
35+
:color="statusChip[item.status].color"
36+
variant="text"
37+
:prepend-icon="statusChip[item.status].icon"
38+
>
39+
{{ statusChip[item.status].label }}
4040
</v-chip>
4141
</td>
4242

@@ -91,27 +91,14 @@
9191
import { computed, onMounted, ref, watch } from "vue";
9292
import { useRouter } from "vue-router";
9393
import useUsersStore from "@admin/store/modules/users";
94-
import { UserAdminResponse } from "@admin/api/client/api";
94+
import { IUser } from "@admin/interfaces/IUser";
9595
import useAuthStore from "@admin/store/modules/auth";
9696
import useSnackbar from "@/helpers/snackbar";
9797
import DataTable from "../DataTable.vue";
9898
import UserFormDialog from "./UserFormDialog.vue";
9999
import UserDelete from "./UserDelete.vue";
100100
import UserResetPassword from "./UserResetPassword.vue";
101101
102-
export interface IUser {
103-
id: string;
104-
auth_methods: Array<string>;
105-
namespaces: number;
106-
confirmed: boolean;
107-
created_at: string;
108-
last_login: string;
109-
name: string;
110-
email: string;
111-
username: string;
112-
password: string;
113-
}
114-
115102
const router = useRouter();
116103
const snackbar = useSnackbar();
117104
const userStore = useUsersStore();
@@ -123,6 +110,11 @@ const page = ref(1);
123110
const filter = ref("");
124111
const users = computed(() => userStore.getUsers as unknown as IUser[]);
125112
const totalUsers = computed(() => userStore.numberUsers);
113+
const statusChip: Record<IUser["status"], { color: string; icon: string; label: string }> = {
114+
confirmed: { color: "success", icon: "mdi-checkbox-marked-circle", label: "Confirmed" },
115+
invited: { color: "warning", icon: "mdi-email-alert", label: "Invited" },
116+
"not-confirmed": { color: "error", icon: "mdi-alert-circle", label: "Not Confirmed" },
117+
};
126118
127119
const header = [
128120
{
@@ -220,7 +212,7 @@ const refreshUsers = async () => {
220212
await userStore.refresh();
221213
};
222214
223-
const redirectToUser = async (user: UserAdminResponse) => {
215+
const redirectToUser = async (user: IUser) => {
224216
router.push({ name: "userDetails", params: { id: user.id } });
225217
};
226218

ui/admin/src/interfaces/IUser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export interface IUser {
22
id: string;
33
namespaces: number;
4-
confirmed: boolean;
4+
status: "confirmed" | "invited" | "not-confirmed";
55
created_at: string;
66
last_login: string;
77
name: string;

0 commit comments

Comments
 (0)