Allow user to be added to team with role.
This commit is contained in:
1 parent
d85b2be5f8
commit
502facd426
2 files changed
+34
-15
No files matched your search
@@ -1,12 +1,31 @@
|
||||
import { Prisma, TeamUser } from '@prisma/client';
|
||||
import { Prisma, TeamUser, UserRole } from '@prisma/client';
|
||||
import { uuid } from 'lib/crypto';
|
||||
import prisma from 'lib/prisma';
|
||||
|
||||
export async function createTeamUser(
|
||||
data: Prisma.TeamUserCreateInput | Prisma.TeamUserUncheckedCreateInput,
|
||||
): Promise<TeamUser> {
|
||||
return prisma.client.teamUser.create({
|
||||
data,
|
||||
});
|
||||
userId: string,
|
||||
teamId: string,
|
||||
roleId: string,
|
||||
): Promise<[TeamUser, UserRole]> {
|
||||
const { client } = prisma;
|
||||
|
||||
return client.$transaction([
|
||||
client.teamUser.create({
|
||||
data: {
|
||||
id: uuid(),
|
||||
userId,
|
||||
teamId,
|
||||
},
|
||||
}),
|
||||
client.userRole.create({
|
||||
data: {
|
||||
id: uuid(),
|
||||
userId,
|
||||
teamId,
|
||||
roleId,
|
||||
},
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
export async function getTeamUser(where: Prisma.TeamUserWhereInput): Promise<TeamUser> {
|
||||
|
||||
Reference in new issue
Block a user