web: edit report and edit dashboard
This commit is contained in:
@@ -10,12 +10,22 @@ import { z } from 'zod';
|
||||
export const dashboardRouter = createTRPCRouter({
|
||||
get: protectedProcedure
|
||||
.input(
|
||||
z.object({
|
||||
slug: z.string(),
|
||||
})
|
||||
z
|
||||
.object({
|
||||
slug: z.string(),
|
||||
})
|
||||
.or(z.object({ id: z.string() }))
|
||||
)
|
||||
.query(async ({ input: { slug } }) => {
|
||||
return getDashboardBySlug(slug);
|
||||
.query(async ({ input }) => {
|
||||
if ('id' in input) {
|
||||
return db.dashboard.findUnique({
|
||||
where: {
|
||||
id: input.id,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
return getDashboardBySlug(input.slug);
|
||||
}
|
||||
}),
|
||||
list: protectedProcedure
|
||||
.input(
|
||||
@@ -41,6 +51,9 @@ export const dashboardRouter = createTRPCRouter({
|
||||
where: {
|
||||
project_id: projectId,
|
||||
},
|
||||
orderBy: {
|
||||
createdAt: 'desc',
|
||||
},
|
||||
});
|
||||
}),
|
||||
create: protectedProcedure
|
||||
@@ -60,6 +73,23 @@ export const dashboardRouter = createTRPCRouter({
|
||||
},
|
||||
});
|
||||
}),
|
||||
update: protectedProcedure
|
||||
.input(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
})
|
||||
)
|
||||
.mutation(({ input }) => {
|
||||
return db.dashboard.update({
|
||||
where: {
|
||||
id: input.id,
|
||||
},
|
||||
data: {
|
||||
name: input.name,
|
||||
},
|
||||
});
|
||||
}),
|
||||
delete: protectedProcedure
|
||||
.input(
|
||||
z.object({
|
||||
|
||||
@@ -83,6 +83,9 @@ export const reportRouter = createTRPCRouter({
|
||||
project_id: project.id,
|
||||
dashboard_id: dashboard.id,
|
||||
},
|
||||
orderBy: {
|
||||
createdAt: 'desc',
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
@@ -138,4 +141,17 @@ export const reportRouter = createTRPCRouter({
|
||||
},
|
||||
});
|
||||
}),
|
||||
delete: protectedProcedure
|
||||
.input(
|
||||
z.object({
|
||||
reportId: z.string(),
|
||||
})
|
||||
)
|
||||
.mutation(({ input: { reportId } }) => {
|
||||
return db.report.delete({
|
||||
where: {
|
||||
id: reportId,
|
||||
},
|
||||
});
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user