Improve provisionning new accounts (#757)

* Improve provisionning new accounts

* Fix lint
This commit is contained in:
Charles Bochet
2023-07-19 11:23:53 -07:00
committed by GitHub
parent 16aa507d50
commit 04c9748a96
12 changed files with 168 additions and 15 deletions

View File

@ -1,6 +1,9 @@
import { Injectable } from '@nestjs/common';
import { Company } from '@prisma/client';
import { PrismaService } from 'src/database/prisma.service';
import peopleSeed from 'src/core/person/seed-data/people.json';
@Injectable()
export class PersonService {
@ -36,4 +39,20 @@ export class PersonService {
// GroupBy
groupBy = this.prismaService.person.groupBy;
async createDefaultPeople({
workspaceId,
companies,
}: {
workspaceId: string;
companies: Company[];
}) {
const people = peopleSeed.map((person, i) => ({
...person,
companyId: companies[i].id || null,
workspaceId,
}));
return this.createMany({
data: people,
});
}
}