feat: update workspace slug

This commit is contained in:
Henry
2025-01-01 14:42:16 +00:00
parent d05655ac9e
commit b5dc9433db
6 changed files with 144 additions and 35 deletions

View File

@@ -119,7 +119,8 @@ export const workspaceRouter = createTRPCRouter({
.input(
z.object({
workspacePublicId: z.string().min(12),
name: z.string().min(3).max(24),
name: z.string().min(3).max(24).optional(),
slug: z.string().min(3).max(24).optional(),
}),
)
.output(z.custom<Awaited<ReturnType<typeof workspaceRepo.update>>>())
@@ -128,6 +129,7 @@ export const workspaceRouter = createTRPCRouter({
ctx.db,
input.workspacePublicId,
input.name,
input.slug,
);
return result;

View File

@@ -42,11 +42,12 @@ export const create = async (
export const update = async (
db: SupabaseClient<Database>,
workspacePublicId: string,
name: string,
name: string | undefined,
slug: string | undefined,
) => {
const { data } = await db
.from("workspace")
.update({ name })
.update({ name, slug })
.eq("publicId", workspacePublicId)
.is("deletedAt", null);
@@ -110,7 +111,8 @@ export const getAllByUserId = async (
role,
workspace (
publicId,
name
name,
slug
)
`,
)