Improve provisionning new accounts (#757)
* Improve provisionning new accounts * Fix lint
This commit is contained in:
@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
38
server/src/core/person/seed-data/people.json
Normal file
38
server/src/core/person/seed-data/people.json
Normal file
@ -0,0 +1,38 @@
|
||||
[
|
||||
{
|
||||
"firstName": "Soumyadeb",
|
||||
"lastName": "Mitra",
|
||||
"city": "San Francisco",
|
||||
"email": "soumyadeb@rudderstack.com",
|
||||
"phone": ""
|
||||
},
|
||||
{
|
||||
"firstName": "Sebastian",
|
||||
"lastName": "Rindom",
|
||||
"city": "Copenhagen",
|
||||
"email": "sebastian@medusajs.com",
|
||||
"phone": ""
|
||||
},
|
||||
{
|
||||
"firstName": "Sameer",
|
||||
"lastName": "Al-Sakran",
|
||||
"city": "San Francisco",
|
||||
"email": "sameer@metabase.com",
|
||||
"phone": ""
|
||||
},
|
||||
{
|
||||
"firstName": "Pierre",
|
||||
"lastName": "Burgy",
|
||||
"city": "Paris",
|
||||
"email": "pierre@strapi.com",
|
||||
"phone": ""
|
||||
},
|
||||
{
|
||||
"firstName": "James",
|
||||
"lastName": "Hawkins",
|
||||
"city": "San Francisco",
|
||||
"email": "james@posthog.com",
|
||||
"phone": ""
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user