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

@@ -32,7 +32,7 @@ export const UserDetail: React.FC = () => {
setUser(u);
if (u && tenantId) {
const [data, funnels] = await Promise.all([
const [data, fetchedFunnels] = await Promise.all([
getAttendances(tenantId, {
...filters,
userId: id
@@ -40,7 +40,14 @@ export const UserDetail: React.FC = () => {
getFunnels(tenantId)
]);
setAttendances(data);
setFunnelDefs(funnels);
const targetTeamId = u.team_id || null;
let activeFunnel = fetchedFunnels[0];
if (targetTeamId) {
const matchedFunnel = fetchedFunnels.find(f => f.teamIds?.includes(targetTeamId));
if (matchedFunnel) activeFunnel = matchedFunnel;
}
setFunnelDefs(activeFunnel && activeFunnel.stages ? activeFunnel.stages.sort((a: any, b: any) => a.order_index - b.order_index) : []);
}
} catch (error) {
console.error("Error loading user details", error);