* feat: teams endpoints * refactor: organization teams reuse team types * refactor: move team specific functions out of organizations-teams.repository * supporting files * regenerate docs * feat: stripe service to generate team creation checkout * refactor: request payment when creating a team * fix: tests * fix env * driveby: event type name and email booking fields * finish merge main
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import { PrismaReadService } from "@/modules/prisma/prisma-read.service";
|
|
import { PrismaWriteService } from "@/modules/prisma/prisma-write.service";
|
|
import { TestingModule } from "@nestjs/testing";
|
|
import { Prisma, Team } from "@prisma/client";
|
|
|
|
export class TeamRepositoryFixture {
|
|
private prismaReadClient: PrismaReadService["prisma"];
|
|
private prismaWriteClient: PrismaWriteService["prisma"];
|
|
|
|
constructor(private readonly module: TestingModule) {
|
|
this.prismaReadClient = module.get(PrismaReadService).prisma;
|
|
this.prismaWriteClient = module.get(PrismaWriteService).prisma;
|
|
}
|
|
|
|
async get(teamId: Team["id"]) {
|
|
return this.prismaReadClient.team.findFirst({ where: { id: teamId } });
|
|
}
|
|
|
|
async create(data: Prisma.TeamCreateInput) {
|
|
return this.prismaWriteClient.team.create({ data });
|
|
}
|
|
|
|
async delete(teamId: Team["id"]) {
|
|
return this.prismaWriteClient.team.deleteMany({ where: { id: teamId } });
|
|
}
|
|
|
|
async getPlatformOrgTeams(organizationId: number, oAuthClientId: string) {
|
|
return this.prismaReadClient.team.findMany({
|
|
where: {
|
|
parentId: organizationId,
|
|
createdByOAuthClientId: oAuthClientId,
|
|
},
|
|
});
|
|
}
|
|
}
|