add delete function
This commit is contained in:
parent
f66c35a225
commit
2ef07fd37a
@ -95,6 +95,15 @@ const ResourceViewPage = () => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const { mutate: mutateDelete } = api.auditoryResource.delete.useMutation({
|
||||||
|
onSuccess: async () => {
|
||||||
|
await router.push(`/resources`);
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
console.error(error);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const ConditionalView = (data: AuditoryResource) => {
|
const ConditionalView = (data: AuditoryResource) => {
|
||||||
return (
|
return (
|
||||||
<div className="mx-auto flex max-w-2xl flex-col flex-col-reverse divide-x py-4 sm:flex-row">
|
<div className="mx-auto flex max-w-2xl flex-col flex-col-reverse divide-x py-4 sm:flex-row">
|
||||||
@ -138,8 +147,9 @@ const ResourceViewPage = () => {
|
|||||||
label="Delete"
|
label="Delete"
|
||||||
symbol={<TrashIcon className="w-4" />}
|
symbol={<TrashIcon className="w-4" />}
|
||||||
onConfirm={() => {
|
onConfirm={() => {
|
||||||
// todo
|
mutateDelete({
|
||||||
console.log("deleting");
|
id,
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
/>,
|
/>,
|
||||||
]}
|
]}
|
||||||
|
@ -89,6 +89,20 @@ export const auditoryResourceRouter = createTRPCRouter({
|
|||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
delete: protectedProcedure
|
||||||
|
.input(
|
||||||
|
z.object({
|
||||||
|
id: z.string(),
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.mutation(async ({ input, ctx }) => {
|
||||||
|
return await ctx.prisma.auditoryResource.delete({
|
||||||
|
where: {
|
||||||
|
id: input.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
|
||||||
update: protectedProcedure
|
update: protectedProcedure
|
||||||
.input(AuditoryResourceSchema.partial().extend({ id: z.string() }))
|
.input(AuditoryResourceSchema.partial().extend({ id: z.string() }))
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user