diff --git a/web/src/components/NavBarIcons/UsersDialog.vue b/web/src/components/NavBarIcons/UsersDialog.vue index 2391950..315ccf9 100644 --- a/web/src/components/NavBarIcons/UsersDialog.vue +++ b/web/src/components/NavBarIcons/UsersDialog.vue @@ -13,13 +13,13 @@ @@ -39,17 +39,27 @@ import UsersDeleteAction from "./UsersDeleteActions.vue"; import UsersEditAction from "./UsersEditActions.vue"; import { Users } from "lucide-vue-next"; import { defineComponent, ref, computed, watch } from "vue"; +import { useQuery, useMutation, useQueryClient } from "@tanstack/vue-query"; +import { axiosInstance } from "@/client"; +import { User } from "@/types"; // Data Table values const headers = ref([ { title: "Name", value: "name" }, { title: "Email", value: "email" }, + { title: "isAdmin", value: "admin" }, { title: "Actions", value: "actions", sortable: false }, ]); -const items = ref([ - { name: "John Doe", email: "test@john.doe", action: "Here CRUD" }, -]); +const queryClient = useQueryClient(); + +const { data } = useQuery({ + queryKey: ["users"], + queryFn: async () => { + const res = await axiosInstance.get("/users"); + return res.data; + }, +}); // Dialog open state const users = ref(false); diff --git a/web/src/components/NavBarIcons/UsersEditActions.vue b/web/src/components/NavBarIcons/UsersEditActions.vue index a6ca8e9..377c114 100644 --- a/web/src/components/NavBarIcons/UsersEditActions.vue +++ b/web/src/components/NavBarIcons/UsersEditActions.vue @@ -29,6 +29,12 @@ :rules="editUserEmailRules" class="mb-3" > + @@ -61,7 +67,9 @@ import { ref } from "vue"; import { SubmitEventPromise } from "vuetify"; import { axiosInstance } from "@/client"; import { useMutation, useQueryClient } from "@tanstack/vue-query"; -import { CreateLicenseDto } from "@/types"; +import { CreateLicenseDto, User } from "@/types"; + +const { user } = defineProps<{ user: User }>(); const queryClient = useQueryClient(); @@ -104,8 +112,9 @@ const { mutate: userMutate } = useMutation({ }, }); -const editUserName = ref(""); -const editUserEmail = ref(""); +const editUserName = ref(user.name); +const editUserEmail = ref(user.email); +const editUserAdmin = ref(user.admin); const edit = ref(false); diff --git a/web/src/types.ts b/web/src/types.ts index 03d7f18..afb1735 100644 --- a/web/src/types.ts +++ b/web/src/types.ts @@ -25,10 +25,11 @@ export interface CreateLicenseDto { note?: string; } -export interface UserDto { +export interface User { id: string; name: string; email: string; + admin: boolean; } export type CreateGroupDto = Omit;