feat: implement advanced funnel management with multiple funnels and team assignments
All checks were successful
Build and Deploy / build-and-push (push) Successful in 2m32s

- Updated DB schema to support multiple funnels (funnels table) and their stages (funnel_stages table).

- Added funnel_id to teams table to link teams to specific funnels.

- Redesigned /admin/funnels page ('Meus Funis') to allow creating multiple funnels, managing their stages, and assigning them to teams.

- Updated Dashboard, UserDetail, and AttendanceDetail to dynamically load the correct funnel based on the selected team or user's assigned team.
This commit is contained in:
Cauê Faleiros
2026-03-13 14:19:52 -03:00
parent 7ab54053db
commit ea8441d4be
7 changed files with 432 additions and 128 deletions

View File

@@ -96,7 +96,7 @@ export const getFunnels = async (tenantId: string): Promise<any[]> => {
}
};
export const createFunnel = async (data: any): Promise<any> => {
export const createFunnel = async (data: { name: string, tenantId: string }): Promise<any> => {
const response = await fetch(`${API_URL}/funnels`, {
method: 'POST',
headers: getHeaders(),
@@ -109,7 +109,7 @@ export const createFunnel = async (data: any): Promise<any> => {
return await response.json();
};
export const updateFunnel = async (id: string, data: any): Promise<boolean> => {
export const updateFunnel = async (id: string, data: { name?: string, teamIds?: string[] }): Promise<boolean> => {
try {
const response = await fetch(`${API_URL}/funnels/${id}`, {
method: 'PUT',
@@ -136,6 +136,46 @@ export const deleteFunnel = async (id: string): Promise<boolean> => {
}
};
export const createFunnelStage = async (funnelId: string, data: any): Promise<any> => {
const response = await fetch(`${API_URL}/funnels/${funnelId}/stages`, {
method: 'POST',
headers: getHeaders(),
body: JSON.stringify(data)
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.error || 'Erro ao criar etapa');
}
return await response.json();
};
export const updateFunnelStage = async (id: string, data: any): Promise<boolean> => {
try {
const response = await fetch(`${API_URL}/funnel_stages/${id}`, {
method: 'PUT',
headers: getHeaders(),
body: JSON.stringify(data)
});
return response.ok;
} catch (error) {
console.error("API Error (updateFunnelStage):", error);
return false;
}
};
export const deleteFunnelStage = async (id: string): Promise<boolean> => {
try {
const response = await fetch(`${API_URL}/funnel_stages/${id}`, {
method: 'DELETE',
headers: getHeaders()
});
return response.ok;
} catch (error) {
console.error("API Error (deleteFunnelStage):", error);
return false;
}
};
export const searchGlobal = async (query: string): Promise<{ members: User[], teams: any[], attendances: any[], organizations?: any[] }> => {
try {
const response = await fetch(`${API_URL}/search?q=${encodeURIComponent(query)}`, {