rename organizationId -> organizationSlug
This commit is contained in:
@@ -6,35 +6,6 @@ import { hashPassword, stripTrailingSlash } from '@openpanel/common';
|
||||
import { db } from '@openpanel/db';
|
||||
|
||||
export const clientRouter = createTRPCRouter({
|
||||
list: protectedProcedure
|
||||
.input(
|
||||
z.object({
|
||||
organizationId: z.string(),
|
||||
})
|
||||
)
|
||||
.query(async ({ input: { organizationId } }) => {
|
||||
return db.client.findMany({
|
||||
where: {
|
||||
organizationSlug: organizationId,
|
||||
},
|
||||
include: {
|
||||
project: true,
|
||||
},
|
||||
});
|
||||
}),
|
||||
get: protectedProcedure
|
||||
.input(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
})
|
||||
)
|
||||
.query(({ input }) => {
|
||||
return db.client.findUniqueOrThrow({
|
||||
where: {
|
||||
id: input.id,
|
||||
},
|
||||
});
|
||||
}),
|
||||
update: protectedProcedure
|
||||
.input(
|
||||
z.object({
|
||||
@@ -59,7 +30,7 @@ export const clientRouter = createTRPCRouter({
|
||||
z.object({
|
||||
name: z.string(),
|
||||
projectId: z.string(),
|
||||
organizationId: z.string(),
|
||||
organizationSlug: z.string(),
|
||||
cors: z.string().nullable(),
|
||||
})
|
||||
)
|
||||
@@ -67,7 +38,7 @@ export const clientRouter = createTRPCRouter({
|
||||
const secret = randomUUID();
|
||||
const client = await db.client.create({
|
||||
data: {
|
||||
organizationSlug: input.organizationId,
|
||||
organizationSlug: input.organizationSlug,
|
||||
projectId: input.projectId,
|
||||
name: input.name,
|
||||
secret: input.cors ? null : await hashPassword(secret),
|
||||
|
||||
@@ -8,12 +8,12 @@ export const projectRouter = createTRPCRouter({
|
||||
list: protectedProcedure
|
||||
.input(
|
||||
z.object({
|
||||
organizationId: z.string().nullable(),
|
||||
organizationSlug: z.string().nullable(),
|
||||
})
|
||||
)
|
||||
.query(async ({ input: { organizationId } }) => {
|
||||
if (organizationId === null) return [];
|
||||
return getProjectsByOrganizationSlug(organizationId);
|
||||
.query(async ({ input: { organizationSlug } }) => {
|
||||
if (organizationSlug === null) return [];
|
||||
return getProjectsByOrganizationSlug(organizationSlug);
|
||||
}),
|
||||
|
||||
update: protectedProcedure
|
||||
@@ -37,15 +37,15 @@ export const projectRouter = createTRPCRouter({
|
||||
.input(
|
||||
z.object({
|
||||
name: z.string().min(1),
|
||||
organizationId: z.string(),
|
||||
organizationSlug: z.string(),
|
||||
})
|
||||
)
|
||||
.mutation(async ({ input }) => {
|
||||
.mutation(async ({ input: { name, organizationSlug } }) => {
|
||||
return db.project.create({
|
||||
data: {
|
||||
id: await getId('project', input.name),
|
||||
organizationSlug: input.organizationId,
|
||||
name: input.name,
|
||||
id: await getId('project', name),
|
||||
organizationSlug: organizationSlug,
|
||||
name: name,
|
||||
},
|
||||
});
|
||||
}),
|
||||
|
||||
@@ -16,7 +16,7 @@ export const shareRouter = createTRPCRouter({
|
||||
},
|
||||
create: {
|
||||
id: uid.rnd(),
|
||||
organizationSlug: input.organizationId,
|
||||
organizationSlug: input.organizationSlug,
|
||||
projectId: input.projectId,
|
||||
public: input.public,
|
||||
password: input.password || null,
|
||||
|
||||
Reference in New Issue
Block a user