mirror of
https://github.com/eliasstepanik/core.git
synced 2026-01-11 17:38:27 +00:00
39 lines
735 B
TypeScript
39 lines
735 B
TypeScript
import { type Workspace } from "@core/database";
|
|
import { prisma } from "~/db.server";
|
|
|
|
interface CreateWorkspaceDto {
|
|
slug: string;
|
|
name: string;
|
|
integrations: string[];
|
|
userId: string;
|
|
}
|
|
|
|
export async function createWorkspace(
|
|
input: CreateWorkspaceDto,
|
|
): Promise<Workspace> {
|
|
const workspace = await prisma.workspace.create({
|
|
data: {
|
|
slug: input.slug,
|
|
name: input.name,
|
|
userId: input.userId,
|
|
},
|
|
});
|
|
|
|
await prisma.user.update({
|
|
where: { id: input.userId },
|
|
data: {
|
|
confirmedBasicDetails: true,
|
|
},
|
|
});
|
|
|
|
return workspace;
|
|
}
|
|
|
|
export async function getWorkspaceByUser(userId: string) {
|
|
return await prisma.workspace.findFirst({
|
|
where: {
|
|
userId,
|
|
},
|
|
});
|
|
}
|