feat: default pipeline provisioning at workspace creation (#728)
* feat: default pipeline and pipeline stage on workspace creation * Create seed data files, typo * Naming --------- Co-authored-by: Emilien <emilien.chauvet.enpc@gmail.com>
This commit is contained in:
33
server/src/core/pipeline/seed-data/pipeline-stages.json
Normal file
33
server/src/core/pipeline/seed-data/pipeline-stages.json
Normal file
@ -0,0 +1,33 @@
|
||||
[
|
||||
{
|
||||
"name": "New",
|
||||
"color": "#B76796",
|
||||
"index": 0,
|
||||
"type": "open"
|
||||
},
|
||||
{
|
||||
"name": "Screening",
|
||||
"color": "#CB912F",
|
||||
"index": 1,
|
||||
"type": "ongoing"
|
||||
},
|
||||
{
|
||||
"name": "Meeting",
|
||||
"color": "#9065B0",
|
||||
"index": 2,
|
||||
"type": "ongoing"
|
||||
},
|
||||
{
|
||||
"name": "Proposal",
|
||||
"color": "#337EA9",
|
||||
"index": 3,
|
||||
"type": "ongoing"
|
||||
},
|
||||
{
|
||||
"name": "Customer",
|
||||
"color": "#079039",
|
||||
"index": 4,
|
||||
"type": "won"
|
||||
}
|
||||
]
|
||||
|
||||
6
server/src/core/pipeline/seed-data/sales-pipeline.json
Normal file
6
server/src/core/pipeline/seed-data/sales-pipeline.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "Sales pipeline",
|
||||
"icon": "💰",
|
||||
"pipelineProgressableType": "Company"
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { PrismaService } from 'src/database/prisma.service';
|
||||
import seedPipelineStages from '../seed-data/pipeline-stages.json';
|
||||
|
||||
@Injectable()
|
||||
export class PipelineStageService {
|
||||
@ -35,4 +36,22 @@ export class PipelineStageService {
|
||||
|
||||
// GroupBy
|
||||
groupBy = this.prismaService.pipelineStage.groupBy;
|
||||
|
||||
// Customs
|
||||
async createDefaultPipelineStages({
|
||||
workspaceId,
|
||||
pipelineId,
|
||||
}: {
|
||||
workspaceId: string;
|
||||
pipelineId: string;
|
||||
}) {
|
||||
const pipelineStages = seedPipelineStages.map((pipelineStage) => ({
|
||||
...pipelineStage,
|
||||
workspaceId,
|
||||
pipelineId,
|
||||
}));
|
||||
return this.createMany({
|
||||
data: pipelineStages,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { PrismaService } from 'src/database/prisma.service';
|
||||
import seedSalesPipeline from '../seed-data/sales-pipeline.json';
|
||||
import { PipelineProgressableType } from '@prisma/client';
|
||||
|
||||
@Injectable()
|
||||
export class PipelineService {
|
||||
@ -35,4 +37,18 @@ export class PipelineService {
|
||||
|
||||
// GroupBy
|
||||
groupBy = this.prismaService.pipeline.groupBy;
|
||||
|
||||
// Customs
|
||||
async createDefaultPipeline({ workspaceId }: { workspaceId: string }) {
|
||||
const pipeline = {
|
||||
...seedSalesPipeline,
|
||||
pipelineProgressableType:
|
||||
seedSalesPipeline.pipelineProgressableType as PipelineProgressableType,
|
||||
workspaceId,
|
||||
};
|
||||
|
||||
return this.create({
|
||||
data: pipeline,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user