feat(api,web): funil de vendas do representante
Kanban de oportunidades por etapa (lead, proposta, negociacao, ganho, perdido) com CRUD completo. - API: `FunilModule` com GET/POST/PATCH/DELETE em /funil, escopado por id_empresa + cod_vendedor. - Modelo `Oportunidade` + migration `sar.oportunidades`. Uma oportunidade referencia um cliente do ERP (id_cliente) ou e um prospect livre (nome_prospect / empresa_prospect). - Contrato Zod compartilhado em `funil.contract.ts`. - Web: `FunilPage` com colunas por etapa, entrada no menu do rep e rota /funil. Nota: a UI ainda nao expoe seletor de cliente, entao toda oportunidade criada pela tela nasce como prospect livre; `idCliente` e `idPedido` ja sao suportados no backend, mas ficam inalcancaveis pela interface. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
48
apps/api/src/app/funil/funil.controller.ts
Normal file
48
apps/api/src/app/funil/funil.controller.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
HttpCode,
|
||||
Param,
|
||||
ParseIntPipe,
|
||||
Patch,
|
||||
Post,
|
||||
} from '@nestjs/common';
|
||||
import { createZodDto } from 'nestjs-zod';
|
||||
import {
|
||||
CreateOportunidadeSchema,
|
||||
UpdateOportunidadeSchema,
|
||||
type FunilResponse,
|
||||
type Oportunidade,
|
||||
} from '@sar/api-interface';
|
||||
import { FunilService } from './funil.service';
|
||||
|
||||
class CreateDto extends createZodDto(CreateOportunidadeSchema) {}
|
||||
class UpdateDto extends createZodDto(UpdateOportunidadeSchema) {}
|
||||
|
||||
@Controller('funil')
|
||||
export class FunilController {
|
||||
constructor(private readonly funil: FunilService) {}
|
||||
|
||||
@Get()
|
||||
listar(): Promise<FunilResponse> {
|
||||
return this.funil.listar();
|
||||
}
|
||||
|
||||
@Post()
|
||||
criar(@Body() dto: CreateDto): Promise<Oportunidade> {
|
||||
return this.funil.criar(CreateOportunidadeSchema.parse(dto));
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
atualizar(@Param('id', ParseIntPipe) id: number, @Body() dto: UpdateDto): Promise<Oportunidade> {
|
||||
return this.funil.atualizar(id, UpdateOportunidadeSchema.parse(dto));
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@HttpCode(204)
|
||||
deletar(@Param('id', ParseIntPipe) id: number): Promise<void> {
|
||||
return this.funil.deletar(id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user