web: correctly pass user to component
This commit is contained in:
parent
cdebdaccdb
commit
c0a84f9bc8
2 changed files with 28 additions and 2 deletions
|
@ -25,8 +25,8 @@
|
||||||
<v-btn
|
<v-btn
|
||||||
class="ms-auto"
|
class="ms-auto"
|
||||||
text="Confirm Delete"
|
text="Confirm Delete"
|
||||||
type="submit"
|
|
||||||
color="red darken-1"
|
color="red darken-1"
|
||||||
|
@click="deleteMutate()"
|
||||||
></v-btn>
|
></v-btn>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
@ -36,8 +36,34 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { useQuery, useMutation, useQueryClient } from "@tanstack/vue-query";
|
||||||
|
import { axiosInstance } from "@/client";
|
||||||
|
import { SubmitEventPromise } from "vuetify";
|
||||||
|
import { LicenseGroup, UpdateLicenseDto, License } from "@/types";
|
||||||
|
import { User } from "@/types";
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
|
|
||||||
|
const { user } = defineProps<{ user: User }>();
|
||||||
|
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
const gyros = user.id;
|
||||||
|
|
||||||
|
const { mutate: deleteMutate } = useMutation({
|
||||||
|
mutationFn: async () => {
|
||||||
|
console.log(gyros);
|
||||||
|
console.log(user.id);
|
||||||
|
await axiosInstance.delete(`/users/${gyros}`);
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
console.log(error);
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["users"] });
|
||||||
|
deleteDialog.value = false;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const deleteDialog = ref(false);
|
const deleteDialog = ref(false);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
>
|
>
|
||||||
<template v-slot:item.actions="{ item }">
|
<template v-slot:item.actions="{ item }">
|
||||||
<UsersEditAction :user="item" />
|
<UsersEditAction :user="item" />
|
||||||
<UsersDeleteAction />
|
<UsersDeleteAction :user="item" />
|
||||||
</template>
|
</template>
|
||||||
</v-data-table>
|
</v-data-table>
|
||||||
<v-divider class="border-opacity-50 mt-5" :thickness="2"></v-divider>
|
<v-divider class="border-opacity-50 mt-5" :thickness="2"></v-divider>
|
||||||
|
|
Loading…
Reference in a new issue