PageSourceSearch

https://artefatospro.com.br/assets/unidades-entrega-BCGjFzeh.js

js artefatospro.com.br collected 2026-09-24 14:34:54 UTC 37,188 bytes, 2 lines download raw bytes

1import{r as j,j as e}from"./vendor-react-O1HtssjF.js";import{a as je,u as B,b as C}from"./vendor-query-C57Ujfuk.js";import{d as fe,e as y,s as ye,P as Ue,B as P,p as G,M as ce,c as X,t as Ke}from"./index-DE-2a8lD.js";import{O as Qe}from"./OutrasFilas-DZqVOn2P.js";import{M as Ge}from"./ModuleGuide-CzQY2VA8.js";import{F as Je,a as me}from"./FilterBar-ChyvzrUr.js";import{Q as be}from"./QueryErrorState-yJLjEIb2.js";import{E as Ve}from"./EmptyState-yGty-Krw.js";import{S as Z}from"./Select--eowR-J1.js";import{u as Ne,a as ke,P as Ce}from"./Paginacao-DRgzifQ-.js";import{g as Q}from"./error-messages-izhQU6MT.js";import{m as He}from"./acesso-na-tela-CDSWhdlZ.js";import{b as Ye}from"./badge-cls-C_azANnJ.js";import{P as ee,a1 as ae,a2 as Xe,a3 as Ze,j as Ie,R as Te,a4 as ea,e as Se,T as aa,a5 as se,G as we}from"./vendor-icons-2dxAfxR_.js";import"./vendor-radix-Cn4zZLa9.js";import"./vendor-datefns-RsZNnTnu.js";import"./vendor-openai-PX4_LG7y.js";import"./acesso-projeto-BvV9qzfo.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new a.Error().stack;
1n&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[n]="501a066b-b285-40a0-9c5a-339c8deb459f",a._sentryDebugIdIdentifier="sentry-dbid-501a066b-b285-40a0-9c5a-339c8deb459f")}catch{}})();const sa=["Time","Squad","Frente","Célula","Unidade"],pe={configured:{label:"Configurado",cls:"v2-ok",dot:"var(--v2-color-success-500)"},approved:{label:"Aprovado",cls:"v2-ok",dot:"var(--v2-color-success-500)"},partial:{label:"Parcial",cls:"v2-warn",dot:"var(--v2-color-warning-500)"},suggested:{label:"Sugerido",cls:"v2-brand",dot:"var(--v2-color-primary-500)"},pending:{label:"Pendente",cls:"v2-warn",dot:"var(--v2-color-warning-500)"},stale:{label:"Desatualizado",cls:"v2-warn",dot:"var(--v2-color-warning-500)"},none:{label:"Não configurado",cls:"",dot:"var(--v2-text-subtle)"},missing:{label:"Ausente",cls:"",dot:"var(--v2-text-subtle)"},error:{label:"Com erro",cls:"v2-danger",dot:"var(--v2-color-danger-500)"}},ue={provider:{label:"Descoberta em integração",Icon:Te},manual:{label:"Cadastro manual",Icon:Ie},meeting:{label:"Sugerida em reunião",Icon:Ze},migration:{label:"Migração",Icon:Xe}},ve=[{value:"azure_area",label:"Azure Area",desc:"Itens cuja Area corresponde à regra",tracker:"Azure DevOps"},{value:"azure_team",label:"Azure Team",desc:"Itens do Team e sua configuração de Area",tracker:"Azure DevOps"},{value:"jira_board",label:"Jira Board",desc:"Issues que pertencem ao Board (via filtro)",tracker:"Jira"},{value:"jira_component",label:"Jira Component",desc:"Issues com o Component escolhido",tracker:"Jira"},{value:"linear_team",label:"Linear Team",desc:"Issues do Team do Linear",tracker:"Linear"},{value:"all_project",label:"Todos os itens do projeto",desc:"Cobre 100% (requer confirmação)",tracker:null},{value:"none",label:"Sem backlog por enquanto",desc:"Só identidade; sem métricas de tarefas",tracker:null}],ge=[{value:"azure_team",label:"Iterações do Azure Team",desc:"Usa as sprints do Team selecionado"},{value:"jira_board",label:"Sprints do Jira Board",desc:"Usa as sprints do Board"},{value:"none",label:"Sem sprint/cadência",desc:"Métricas gerais, mas não de sprint atual"}];function he(a){return String((a==null?void 0:a.message)??"").includes("unit_shared_with_other_projects")}function oa(a){if(!a)return"-";const n=new Date(a).getTime();if(Number.isNaN(n))return"-";const d=Math.round((Date.now()-n)/6e4);if(d<1)return"agora";if(d<60)return`há ${d} min`;const p=Math.round(d/60);if(p<24)return`há ${p} h`;const i=Math.round(p/24);return`há ${i} dia${i!==1?"s":""}`}const ta=(a,n)=>a!=null&&n!=null&&n>0?Math.round(a/n*100):null;function wa(){const a=je(),{toast:n}=fe(),[d,p]=j.useState("unidades"),[i,x]=j.useState({organizationId:null,projectId:null,provider:"",coverage:""}),[v,r]=j.useState(null),[I,g]=j.useState(!1),{data:c=[]}=B({queryKey:["/api/organizations"]}),{data:m=[]}=B({queryKey:["/api/projects"]}),l=j.useMemo(()=>m.filter(s=>!i.organizationId||s.organizationId===i.organizationId),[m,i.organizationId]);j.useEffect(()=>{i.projectId&&!l.find(s=>s.id===i.projectId)&&x(s=>({...s,projectId:null}))},[l,i.projectId]);const u=i.projectId??"",f=He(m,u),S=m.find(s=>s.id===u),A=s=>{var h;return((h=c.find(z=>z.id===s))==null?void 0:h.name)??"Sem organização"},w=u?`?projectId=${u}`:"",o=["/api/delivery-units",u],{data:k,isLoading:N,isError:F,error:T,refetch:D}=B({queryKey:o,queryFn:async()=>(await y("GET",`/api/delivery-units${w}`)).json()}),E=(k==null?void 0:k.deliveryUnits)??[],[L,J]=j.useState(!1),V=["/api/delivery-units/suggestions",u,L],{data:t,isLoading:q,isFetching:_,refetch:Ee}=B({queryKey:V,queryFn:async()=>(await y("GET",`/api/delivery-units/suggestions${w}${w.includes("?")?"&":"?"}${L?"incluirIgnoradas=1":""}`)).json()}),H=(t==null?void 0:t.suggestions)??[],ze=(t==null?void 0:t.ignoradas)??0,oe=!!(i.organizationId||i.provider||i.coverage),R=j.useMemo(()=>E.filter(s=>!(i.provider&&s.provider!==i.provider||i.coverage&&s.status.key!==i.coverage)),[E,i.provider,i.coverage]),Y=j.useMemo(()=>{if(!i.provider)return H;const h={azure:"Azure DevOps",jira:"Jira",linear:"Linear"}[i.provider];return h?H.filter(z=>z.tracker===h):[]},[H,i.provider]),Pe=d==="sugestoes"?Y.length:R.length,Ae=s=>d==="sugestoes"?`${s} sugest${s===1?"ão":"ões"}`:`${s} time${s===1?"":"s"}`,Fe=d!=="sugestoes",$e=Ne(180),te=ke(R,$e),qe=R.filter(s=>s.status.key==="completa").length,Re=R.filter(s=>s.status.key==="parcial").length,Be=R.filter(s=>s.status.cls==="danger").length,De=E.filter(s=>s.overlapCount>0),O=()=>{a.invalidateQueries({queryKey:["/api/delivery-units"]}),a.invalidateQueries({queryKey:["/api/delivery-units/suggestions"]})},W=s=>n({title:"Não foi possível salvar",description:Q(s),variant:"destructive"}),re=s=>({projectId:s.projectId,backlogType:s.backlogType,backlogRule:s.backlogRule}),Le=C({mutationFn:async s=>(await y("POST","/api/delivery-units/suggestions/dismiss",re(s))).json(),onSuccess:()=>{a.invalidateQueries({queryKey:["/api/delivery-units/suggestions"]}),n({title:"Sugestão ignorada",description:"Use “mostrar ignoradas” para trazer de volta."})},onError:s=>n({title:"Não foi possível ignorar",description:Q(s),variant:"destructive"})}),Oe=C({mutationFn:async s=>(await y("DELETE","/api/delivery-units/suggestions/dismiss",re(s))).json(),onSuccess:()=>{a.invalidateQueries({queryKey:["/api/delivery-units/suggestions"]}
1),n({title:"Sugestão de volta na fila"})},onError:s=>n({title:"Não foi possível restaurar",description:Q(s),variant:"destructive"})}),M=C({mutationFn:async s=>(await y("POST","/api/delivery-units",s)).json(),onSuccess:()=>{O(),g(!1),n({title:"Time criado"})},onError:W}),ne=C({mutationFn:async({id:s,body:h})=>(await y("PATCH",`/api/delivery-units/${s}`,h)).json(),onSuccess:()=>{O(),r(null),n({title:"Time atualizado"})},onError:W}),ie=ye(),We=C({mutationFn:async s=>(await y("DELETE",`/api/delivery-units/${s}`)).json(),onSuccess:()=>{O(),n({title:"Time excluído"})},onError:s=>{he(s)||W(s)}}),_e=C({mutationFn:async({id:s,projectId:h})=>(await y("POST",`/api/delivery-units/${s}/projects`,{projectId:h})).json(),onSuccess:s=>{O(),n({title:s!=null&&s.jaVinculado?"O time já atendia este projeto":"Time passou a atender o projeto"})},onError:W}),le=C({mutationFn:async({id:s,projectId:h})=>(await y("DELETE",`/api/delivery-units/${s}/projects/${h}`)).json(),onSuccess:s=>{O(),n({title:s!=null&&s.unidadeRemovida?"Time excluído":"Time desvinculado do projeto"})},onError:W});async function Me(s){var U;const h=s.totalProjetos<=1;if(await ie({title:"Excluir time",message:h?`Excluir o time "${s.name}"? Esta ação é permanente e não pode ser desfeita.`:`O time "${s.name}" atende ${s.totalProjetos} projetos. Excluir tira ele de todos.`,confirmLabel:"Excluir",destructive:!0}))try{await We.mutateAsync(s.id)}catch(b){const $=u||((U=s.projetos[0])==null?void 0:U.id);if(!he(b)||!$)return;await ie({title:"Este time não é só seu",message:`"${s.name}" também atende projetos em que você não pode editar, então não dá para excluir. Dá para tirar ele deste projeto: o time continua existindo para os outros.`,confirmLabel:"Tirar deste projeto"})&&le.mutate({id:s.id,projectId:$})}}return e.jsxs(Ue,{children:[e.jsxs("div",{className:"v2-page-head",children:[e.jsxs("div",{className:"v2-page-head-title",children:[e.jsx("h1",{children:"Times"}),e.jsxs("div",{className:"v2-sub",children:["O conceito canônico de ",e.jsx("strong",{children:"time, squad ou frente"}),": reconhecível por você e independente de como o Azure ou o Jira nomeiam. Um time existe mesmo sem backlog, e agora tem ",e.jsx("strong",{children:"quem"})," (roster de pessoas) além do que entrega."]}),e.jsx(Qe,{atual:"times"})]}),e.jsx("div",{className:"v2-page-head-actions",children:e.jsx(P,{leftIcon:e.jsx(ee,{className:"h-4 w-4"}),onClick:()=>g(!0),disabled:!!f,title:f,children:"Novo time"})})]}),e.jsxs("div",{className:"v2-tab-pill",style:{display:"inline-flex",marginBottom:14},children:[e.jsx("button",{className:d==="unidades"?"v2-active":"",onClick:()=>p("unidades"),children:"Times"}),e.jsx("button",{className:d==="sugestoes"?"v2-active":"",onClick:()=>p("sugestoes"),children:"Sugestões"}),e.jsx("button",{className:d==="sobreposicoes"?"v2-active":"",onClick:()=>p("sobreposicoes"),children:"Sobreposições"})]}),e.jsxs("div",{className:"v2-kpis",children:[e.jsxs("div",{className:"v2-kpi v2-tint-g",children:[e.jsx("div",{className:"v2-kpi-label",children:"Configuradas"}),e.jsx("div",{className:"v2-kpi-value",children:qe}),e.jsx("div",{className:"v2-kpi-foot",children:"identidade + backlog + cadência"})]}),e.jsxs("div",{className:"v2-kpi v2-tint-a",children:[e.jsx("div",{className:"v2-kpi-label",children:"Parciais"}),e.jsx("div",{className:"v2-kpi-value",children:Re}),e.jsx("div",{className:"v2-kpi-foot",children:"faltando backlog ou cadência"})]}),e.jsxs("div",{className:"v2-kpi",children:[e.jsx("div",{className:"v2-kpi-label",children:"Sugestões"}),e.jsx("div",{className:"v2-kpi-value",children:q?"…":Y.length}),e.jsx("div",{className:"v2-kpi-foot",children:"descobertas do scope nativo"})]}),e.jsxs("div",{className:"v2-kpi v2-tint-r",children:[e.jsx("div",{className:"v2-kpi-label",children:"Com erro"}),e.jsx("div",{className:"v2-kpi-value",children:Be}),e.jsx("div",{className:"v2-kpi-foot",children:"fonte removida ou inacessível"})]})]}),e.jsx(Je,{value:i,onChange:x,organizations:c,projects:l.map(s=>({id:s.id,name:G(s)})),resultCount:Pe,labels:{results:Ae},hasActiveFilters:oe,onClear:()=>x(s=>({organizationId:null,projectId:s.projectId,provider:"",coverage:""})),slots:e.jsxs(e.Fragment,{children:[e.jsx(me,{label:"Provedor",children:e.jsxs(Z,{"aria-label":"Provedor",value:i.provider??"",onChange:s=>x({...i,provider:s.target.value}),children:[e.jsx("option",{value:"",children:"Todos os provedores"}),e.jsx("option",{value:"azure",children:"Azure DevOps"}),e.jsx("option",{value:"jira",children:"Jira"}),e.jsx("option",{value:"linear",children:"Linear"}),e.jsx("option",{value:"manual",children:"Manual"})]})}),Fe&&e.jsx(me,{label:"Situação",children:e.jsxs(Z,{"aria-label":"Situação",value:i.coverage??"",onChange:s=>x({...i,coverage:s.target.value}),children:[e.jsx("option",{value:"",children:"Qualquer situação"}),e.jsx("option",{value:"completa",children:"Completa"}),e.jsx("option",{value:"parcial",children:"Parcial"}),e.jsx("option",{value:"desatualizado",children:"Desatualizado"}),e.jsx("option",{value:"com_erro",children:"Com erro"})]})})]})}),e.jsx("div",{style:{marginTop:14}}),d==="unidades"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[te.itens.map(s=>{const h=s.projetos[0],z=h?m.find(b=>b.id===h.id):void 0,U=new Set(s.projetos.map(b=>{var $;return(($=m.find(de=>de.id===b.id))==null?void 0:$.organizationId)??null}).filter(b=>b!==null));return e.jsx(ra,{u:s,orgLabel:U.size>1?"Várias organizações":A(z==null?void 0:z.organizationId),projetosDisponiveis:l.filter(b=>!s.projetos.some($=>$.id===b.id)),onVincularProjeto:b=>_e.mutate({id:s.id,projectId:b}),onDesvincular:b=>le.mutate({id:s.id,projectId:b}),onEdit:()=>r(s),onArchive:()=>Me(s)},s.id)}),R.length===0&&(F?e.jsx("div",{className:"v2-card",children:e.jsx(be,{error:T,recurso:"os times",onRetry:()=>D()})}):e.jsx("div",{className:"v2-card",children:e.jsx(Ve,{icon:e.jsx(ae,{className:"h-6 w-6"}),hasActiveFilters:oe,title:N?"Carregando…":"Nenhum time cadastrado ainda",description:N?void 0:'Use "Novo time" acima para criar o primeiro.',f
1ilteredTitle:N?"Carregando…":"Nenhum time com esses filtros",filteredDescription:N?void 0:"Tente afrouxar os filtros acima."})})),e.jsx(Ce,{estado:te,rotulo:"times"})]}),d==="sugestoes"&&e.jsx(ia,{suggestions:Y,loading:q||_,onDiscover:()=>Ee(),onIgnorar:s=>Le.mutate(s),onRestaurar:s=>Oe.mutate(s),mostrarIgnoradas:L,setMostrarIgnoradas:J,totalIgnoradas:ze,onApprove:s=>M.mutate({projectId:s.projectId,name:s.name,term:"Time",origin:"provider",aliases:[],backlogType:s.backlogType,backlogRule:s.backlogRule,tracker:s.tracker,cadenceType:"none",covIdentity:"configured",covBacklog:"configured",covCadence:"none",covEvidence:"none",items:s.items}),approving:M.isPending}),d==="sobreposicoes"&&e.jsx(la,{overlaps:De}),e.jsx(Ge,{moduleKey:"unidades-entrega",title:"Como funciona Times",howItWorks:e.jsxs(e.Fragment,{children:[e.jsxs("p",{style:{margin:"0 0 8px"},children:["Uma ",e.jsx("b",{children:"Unidade de Entrega"}),' é o conceito de "time" reconhecível por você, separado dos objetos do provedor (Azure Team, Jira Board, Area, Component). Ela tem quatro dimensões independentes: ',e.jsx("b",{children:"Identidade"})," (nome, aliases), ",e.jsx("b",{children:"Backlog"})," (quais itens pertencem), ",e.jsx("b",{children:"Cadência"})," (qual sprint) e ",e.jsx("b",{children:"Evidência"})," (de onde veio a definição). Nenhuma é inferida da outra automaticamente."]}),e.jsxs("p",{style:{margin:"0 0 8px"},children:["Uma unidade pode existir ",e.jsx("b",{children:"sem backlog"}),": o assistente sabe que ela existe, mas não inventa número de itens nem velocidade."]}),e.jsxs("p",{style:{margin:0},children:["A ",e.jsx("b",{children:"sobreposição"})," (um item em mais de uma unidade) é permitida: no portfólio o item é contado uma única vez (deduplicação)."]})]}),terms:[{term:"Unidade de Entrega",pt:"A entidade canônica de time/squad/frente, estável mesmo que o nome no provedor mude",origin:"manual"},{term:"Escopo nativo",pt:"Objeto descoberto numa integração: Azure Team/Area, Jira Board/Component",origin:"synced"},{term:"Vínculo (backlog)",pt:"A regra que liga a unidade a dados: por Area, Board, Component ou todos os itens",origin:"manual"},{term:"Situação",pt:"Quanto de cada dimensão (identidade/backlog/cadência) está configurado",origin:"calculated"},{term:"Sobreposição",pt:"Mesmo item pertencendo a mais de uma unidade; deduplicado no portfólio",origin:"calculated"}]}),e.jsx(ce,{open:I,onClose:()=>g(!1),title:"Novo time",children:e.jsx(xe,{projectName:S?G(S):"",projectId:u,projects:l,submitting:M.isPending,onCancel:()=>g(!1),onSubmit:s=>M.mutate(s)})}),e.jsx(ce,{open:!!v,onClose:()=>r(null),title:`Editar · ${(v==null?void 0:v.name)??""}`,children:v&&e.jsxs(e.Fragment,{children:[e.jsx(da,{unitId:v.id}),e.jsx(xe,{initial:v,submitting:ne.isPending,onCancel:()=>r(null),onSubmit:s=>ne.mutate({id:v.id,body:s})})]})})]})}function ra({u:a,orgLabel:n,projetosDisponiveis:d,onVincularProjeto:p,onDesvincular:i,onEdit:x,onArchive:v}){const r=ue[a.origin]??ue.manual,I=r.Icon,g=ta(a.items,a.projectItems);return e.jsxs("div",{className:"v2-card",style:{padding:0,overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:14,padding:"16px 18px"}
1,children:[e.jsx("div",{style:{width:42,height:42,borderRadius:10,background:"var(--v2-color-primary-50)",color:"var(--v2-color-primary-700)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(ae,{className:"h-5 w-5"})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:16,fontWeight:600,color:"var(--v2-text-strong)"},children:a.name}),e.jsx("span",{className:"v2-badge v2-badge-sm",children:a.term}),e.jsx("span",{className:`v2-badge v2-badge-sm ${Ye(a.status.cls)}`,children:a.status.label}),a.overlapCount>0&&e.jsx("span",{className:"v2-badge v2-badge-sm v2-warn",title:`Compartilha ${X(a.overlapCount,"item","itens")} com ${a.overlapWith??"outra unidade"}`,children:X(a.overlapCount,"sobreposto","sobrepostos")})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:5,fontSize:12.5,color:"var(--v2-text-muted)"},children:[e.jsx(ea,{className:"h-3 w-3"}),e.jsxs("span",{children:[n," ›"," ",e.jsx("strong",{style:{color:"var(--v2-text)"},children:a.projetos.map(c=>c.name).join(", ")||"sem projeto"}),a.totalProjetos>a.projetos.length&&e.jsxs("span",{title:"Este time também atende projetos que você não pode ver",children:[" ","+",a.totalProjetos-a.projetos.length]})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:6,flexWrap:"wrap"},children:[a.projetos.length>1&&a.projetos.map(c=>e.jsxs("button",{className:"v2-badge v2-badge-sm",style:{cursor:"pointer"},title:`Tirar o time de ${c.name}. Ele continua nos outros.`,onClick:()=>i(c.id),children:[c.name," ×"]},c.id)),d.length>0&&e.jsxs("select",{className:"v2-select v2-select-sm",value:"","aria-label":`Fazer ${a.name} atender mais um projeto`,onChange:c=>c.target.value&&p(c.target.value),style:{maxWidth:220},children:[e.jsx("option",{value:"",children:"Atender mais um projeto…"}),d.map(c=>e.jsx("option",{value:c.id,children:G(c)},c.id))]})]}),a.aliases.length>0&&e.jsxs("div",{style:{display:"flex",gap:5,marginTop:8,flexWrap:"wrap",alignItems:"center"},children:[e.jsx("span",{style:{fontSize:"var(--v2-text-xs)",color:"var(--v2-text-subtle)"},children:"também chamado:"}),a.aliases.map(c=>e.jsx("span",{className:"v2-badge v2-badge-sm",children:c},c))]})]}),e.jsxs("div",{style:{display:"flex",gap:4,flexShrink:0},children:[e.jsx("button",{className:"v2-icon-btn",title:"Editar",onClick:x,"aria-label":"Editar",children:e.jsx(Ie,{className:"h-3.5 w-3.5",style:{color:"var(--v2-text-subtle)"}})}),e.jsx("button",{className:"v2-icon-btn",title:"Excluir",onClick:v,"aria-label":"Excluir",children:e.jsx(Se,{className:"h-3.5 w-3.5",style:{color:"var(--v2-text-subtle)"}})})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:1,background:"var(--v2-border)",borderTop:"1px solid var(--v2-border)"},children:[e.jsx(K,{dim:"Identidade",state:a.covIdentity,detail:X(a.totalProjetos||a.projetos.length,"projeto","projetos")}),e.jsx(K,{dim:"Backlog",state:a.covBacklog,detail:a.backlogRule||"não configurado"}),e.jsx(K,{dim:"Cadência",state:a.covCadence,detail:a.covCadence==="error"?"fonte removida":a.cadenceRule||"sem sprint"}),e.jsx(K,{dim:"Evidências",state:a.covEvidence,detail:`${a.evidences} fonte${a.evidences!==1?"s":""}`})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:16,padding:"10px 18px",background:"var(--v2-surface-muted, var(--v2-surface))",fontSize:12,color:"var(--v2-text-muted)",flexWrap:"wrap"},children:a.covBacklog==="error"?e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"var(--v2-color-danger-700)"},children:[e.jsx(aa,{className:"h-3 w-3"})," Fonte de backlog removida no provedor: reconfigure o vínculo."]}):a.noData?e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"var(--v2-color-warning-700)"},children:[e.jsx(se,{className:"h-3 w-3"})," Time conhecido, mas sem backlog configurado, sem métricas de tarefas."]}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{children:[e.jsx("strong",{style:{color:"var(--v2-text)",fontFamily:"var(--v2-font-mono)"},children:a.items??0})," ",Ke(a.items??0,"item","itens")]}),g!=null&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--v2-text-subtle)"},children:"·"}),e.jsxs("span",{children:[g,"% do projeto"]})]}),e.jsx("span",{style:{color:"var(--v2-text-subtle)"},children:"·"}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5},children:[e.jsx(I,{className:"h-3 w-3"})," ",r.label]}),e.jsx("span",{style:{flex:1}}),e.jsxs("span",{style:{fontSize:"var(--v2-text-xs)",color:"var(--v2-text-subtle)"},children:["atualizado ",oa(a.updatedAt)]})]})})]})}function K({dim:a,state:n,detail:d}
1){const p=pe[n]??pe.none;return e.jsxs("div",{style:{background:"var(--v2-surface)",padding:"11px 14px"},children:[e.jsx("div",{style:{fontSize:"var(--v2-text-xs)",color:"var(--v2-text-subtle)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:4},children:a}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:3},children:[e.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:p.dot,flexShrink:0}}),e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--v2-text)"},children:p.label})]}),e.jsx("div",{style:{fontSize:"var(--v2-text-xs)",color:"var(--v2-text-subtle)",lineHeight:1.35,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:d,children:d})]})}const na={team:"Team descoberto na integração",board:"Board descoberto na integração",area:"Area Path dos itens sincronizados"};function ia({suggestions:a,loading:n,onDiscover:d,onApprove:p,approving:i,onIgnorar:x,onRestaurar:v,mostrarIgnoradas:r,setMostrarIgnoradas:I,totalIgnoradas:g}){const c=Ne(76),m=ke(a,c);return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginBottom:12,flexWrap:"wrap"},children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--v2-text-muted)",lineHeight:1.5},children:["Sugestões derivadas do ",e.jsx("strong",{children:"scope nativo já sincronizado"})," (Azure Team, Jira Board, Area Path). Nada entra em métricas sem a sua aprovação."]}),g>0&&e.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:12.5,cursor:"pointer"},title:"Sugestões que você recusou. Dá para trazer qualquer uma de volta.",children:[e.jsx("input",{type:"checkbox",checked:r,onChange:l=>I(l.target.checked)}),"mostrar ignoradas (",g,")"]}),e.jsx(P,{variant:"secondary",size:"sm",leftIcon:e.jsx(Te,{className:"h-3.5 w-3.5"}),onClick:d,disabled:n,children:n?"Descobrindo…":"Descobrir sugestões"})]}),a.length===0?e.jsx("div",{className:"v2-card",children:e.jsxs("div",{className:"v2-empty",style:{padding:32},children:[e.jsx("div",{className:"v2-empty-icon",children:e.jsx(we,{className:"h-6 w-6"})}),e.jsx("h4",{className:"v2-empty-title",children:n?"Descobrindo…":"Nenhuma sugestão pendente"}),e.jsx("p",{className:"v2-empty-desc",children:"A descoberta olha os Teams/Boards e Area Paths dos itens já sincronizados. Sem integração sincronizada neste escopo (ou com tudo já aprovado como unidade), não há o que sugerir: cadastre manualmente se precisar."})]})}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[m.itens.map(l=>e.jsxs("div",{className:"v2-card v2-card-tight",style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[e.jsx("div",{style:{width:36,height:36,borderRadius:9,background:"var(--v2-color-primary-50)",color:"var(--v2-color-primary-700)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(ae,{className:"h-4 w-4"})}),e.jsxs("div",{style:{flex:1,minWidth:220},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontWeight:600,color:"var(--v2-text-strong)"},children:l.name}),e.jsx("span",{className:"v2-badge v2-badge-sm v2-brand",children:"Sugerida"}),l.tracker&&e.jsx("span",{className:"v2-badge v2-badge-sm",children:l.tracker})]}),e.jsxs("div",{style:{fontSize:12,color:"var(--v2-text-muted)",marginTop:3},children:[l.projectName?e.jsxs(e.Fragment,{children:[e.jsx("strong",{style:{color:"var(--v2-text)"},children:l.projectName})," ·"," "]}):null,na[l.source]," · regra:"," ",e.jsx("span",{style:{fontFamily:"var(--v2-font-mono)"},children:l.backlogRule}),l.items!=null&&e.jsxs(e.Fragment,{children:[" ","· ",e.jsx("strong",{children:l.items})," ",l.items===1?"item":"itens"]})]})]}),e.jsx("div",{style:{display:"flex",gap:8,alignItems:"center"},children:l.ignorada?e.jsx(P,{size:"sm",variant:"secondary",onClick:()=>v(l),title:"Devolve esta sugestão para a fila",children:"Trazer de volta"}):e.jsxs(e.Fragment,{children:[e.jsx(P,{size:"sm",variant:"ghost",onClick:()=>x(l),title:"Some da fila. Dá para trazer de volta depois.",children:"Ignorar"}),e.jsx(P,{size:"sm",leftIcon:e.jsx(ee,{className:"h-3.5 w-3.5"}),onClick:()=>p(l),disabled:i,title:"Cria a unidade já vinculada a este backlog",children:"Criar unidade"})]})})]},`${l.projectId}|${l.backlogType}|${l.backlogRule}`)),e.jsx(Ce,{estado:m,rotulo:"sugestões"})]})]})}function la({overlaps:a}){return e.jsxs("div",{children:[e.jsxs("div",{className:"v2-callout",style:{display:"flex",gap:10,alignItems:"flex-start",marginBottom:16},children:[e.jsx(se,{className:"h-4 w-4",style:{flexShrink:0,marginTop:1,color:"var(--v2-color-primary-700)"}}),e.jsxs("div",{style:{lineHeight:1.55,fontSize:13,color:"var(--v2-text-muted)"},children:["Sobreposição é ",e.jsx("strong",{children:"permitida"}),": um item de plataforma pode ser compartilhado. Relatórios por unidade contam o item em cada uma; no ",e.jsx("strong",{children:"portfólio, ele é contado uma única vez"})," (deduplicação), evitando dupla contagem."]})]}),a.length===0?e.jsx("div",{className:"v2-card",children:e.jsxs("div",{className:"v2-empty",children:[e.jsx("div",{className:"v2-empty-icon",children:e.jsx(we,{className:"h-6 w-6"})}),e.jsx("h4",{className:"v2-empty-title",children:"Nenhuma sobreposição"}),e.jsx("p",{className:"v2-empty-desc",children:"Nenhum item pertence a mais de um time no momento."})]})}):e.jsx("div",{className:"v2-t-wrap",children:e.jsxs("table",{className:"v2-clean",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Time"}),e.jsx("th",{children:"Compartilha com"}),e.jsx("th",{style:{textAlign:"right"},children:"Itens sobrepostos"}),e.jsx("th",{children:"Impacto"})]})}),e.jsx("tbody",{children:a.map(n=>e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:n.name}),e.jsx("td",{style:{color:"var(--v2-text-muted)"},children:n.overlapWith??"-"}),e.jsx("td",{style:{textAlign:"right",fontFamily:"var(--v2-font-mono)",color:"var(--v2-color-warning-700)",fontWeight:600},children:n.overlapCount}),e.jsx("td",{style:{color:"var(--v2-text-subtle)",fontSize:12.5},children:"Contados 1× no portfólio"})]},n.id))})]})})]})}function xe({initial:a,projectName:n,projectId:d,projects:p,onSubmit:i,onCancel:x,submitting:v}){const[r,I]=j.useState({name:(a==null?void 0:a.name)??"",term:(a==null?void 0:a.term)??"Time",aliases:((a==null?void 0:a.aliases)??[]).join(", "),backlogType:(a==null?void 0:a.backlogType)??"none",backlogRule:(a==null?void 0:a.backlogRule)??"",cadenceType:(a==null?void 0:a.cadenceType)??"none",items:(a==null?void 0:a.items)!=null?String(a.items):"",projectItems:(a==null?void 0:a.projectItems)!=null?String(a.projectItems):"",projectId:d??""}),[g,c]=j.useState(""),m=(o,k)=>I(N=>({...N,[o]:k})),l=!a&&!d,u=ve.find(o=>o.value===r.backlogType),f=r.backlogType!=="none",S=r.cadenceType!=="none",A=r.backlogType.startsWith("azure")||r.backlogType.startsWith("jira")||r.backlogType.startsWith("linear"),w=()=>{var F;if(r.name.trim().length<2){c("Dê um nome à unidade (mínimo 2 caracteres)");return}if(l&&!r.projectId){c("Escolha o projeto desta unidade");return}const o=r.aliases.split(",").map(T=>
1T.trim()).filter(Boolean),k=r.items===""?null:Number(r.items),N=r.projectItems===""?null:Number(r.projectItems);i({...a?{}:{projectId:r.projectId},name:r.name.trim(),term:r.term,origin:(a==null?void 0:a.origin)??"manual",aliases:o,backlogType:r.backlogType,backlogRule:f&&(r.backlogRule.trim()||(u==null?void 0:u.label))||null,tracker:(u==null?void 0:u.tracker)??null,cadenceType:r.cadenceType,cadenceRule:S?((F=ge.find(T=>T.value===r.cadenceType))==null?void 0:F.label)??null:null,covIdentity:"configured",covBacklog:f?"configured":"none",covCadence:S?"configured":"none",covEvidence:(a==null?void 0:a.covEvidence)??"none",items:f?k:null,projectItems:N})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"v2-col v2-gap-4",children:[n&&e.jsxs("div",{style:{fontSize:12.5,color:"var(--v2-text-muted)"},children:["Projeto: ",e.jsx("b",{children:n})]}),a&&e.jsx("div",{style:{fontSize:12.5,color:"var(--v2-text-muted)"},children:a.projetos.length>0?e.jsxs(e.Fragment,{children:["Atende"," ",e.jsx("b",{children:a.projetos.map(o=>o.name).join(", ")}),". Para acrescentar ou tirar um projeto, use ",e.jsx("b",{children:"“Atender mais um projeto…”"})," no card do time."]}):e.jsxs(e.Fragment,{children:["Este time não atende nenhum projeto. Use"," ",e.jsx("b",{children:"“Atender mais um projeto…”"})," no card do time."]})}),l&&e.jsxs("div",{className:"v2-field",children:[e.jsx("label",{className:"v2-field-label",children:"Projeto *"}),e.jsxs("select",{className:"v2-select","aria-label":"Projeto da unidade",value:r.projectId,onChange:o=>m("projectId",o.target.value),children:[e.jsx("option",{value:"",children:"Escolha um projeto"}),(p??[]).map(o=>e.jsx("option",{value:o.id,children:G(o)},o.id))]}),(p??[]).length===0&&e.jsxs("span",{className:"v2-field-help",children:["Você ainda não tem projeto. Crie um em ",e.jsx("b",{children:"Projetos"})," para poder cadastrar aqui."]})]}),e.jsxs("div",{className:"v2-field",children:[e.jsx("label",{className:"v2-field-label",children:"Nome do time *"}),e.jsx("input",{className:`v2-input ${g?"v2-field-error":""}
1`,value:r.name,autoFocus:!0,onChange:o=>{m("name",o.target.value),c("")},placeholder:"Ex: Engenharia Lakehouse"}),g&&e.jsx("span",{className:"v2-field-error",children:g})]}),e.jsxs("div",{className:"v2-grid-2",children:[e.jsxs("div",{className:"v2-field",children:[e.jsx("label",{className:"v2-field-label",children:"Como chamar"}),e.jsx("select",{className:"v2-select",value:r.term,onChange:o=>m("term",o.target.value),children:sa.map(o=>e.jsx("option",{value:o,children:o},o))})]}),e.jsxs("div",{className:"v2-field",children:[e.jsx("label",{className:"v2-field-label",children:"Aliases (separados por vírgula)"}),e.jsx("input",{className:"v2-input",value:r.aliases,onChange:o=>m("aliases",o.target.value),placeholder:"Eng., Engenharia"})]})]}),e.jsxs("div",{className:"v2-field",children:[e.jsx("label",{className:"v2-field-label",children:"Backlog: quais itens representam este time"}),e.jsx("select",{className:"v2-select",value:r.backlogType,onChange:o=>m("backlogType",o.target.value),children:ve.map(o=>e.jsxs("option",{value:o.value,children:[o.label,": ",o.desc]},o.value))})]}),A&&e.jsxs("div",{className:"v2-field",children:[e.jsx("label",{className:"v2-field-label",children:"Valor da regra"}),e.jsx("input",{className:"v2-input",value:r.backlogRule,onChange:o=>m("backlogRule",o.target.value),placeholder:r.backlogType==="azure_area"?"Lakehouse\\Engenharia":"Produto"})]}),e.jsxs("div",{className:"v2-field",children:[e.jsx("label",{className:"v2-field-label",children:"Cadência: qual sprint/ciclo considerar"}),e.jsx("select",{className:"v2-select",value:r.cadenceType,onChange:o=>m("cadenceType",o.target.value),children:ge.map(o=>e.jsxs("option",{value:o.value,children:[o.label,": ",o.desc]},o.value))})]}),f&&e.jsxs("div",{className:"v2-grid-2",children:[e.jsxs("div",{className:"v2-field",children:[e.jsx("label",{className:"v2-field-label",children:"Itens associados (opcional)"}),e.jsx("input",{className:"v2-input",type:"number",min:0,value:r.items,onChange:o=>m("items",o.target.value),placeholder:"Ex: 86"})]}),e.jsxs("div",{className:"v2-field",children:[e.jsx("label",{className:"v2-field-label",children:"Total de itens do projeto (opcional)"}),e.jsx("input",{className:"v2-input",type:"number",min:0,value:r.projectItems,onChange:o=>m("projectItems",o.target.value),placeholder:"Ex: 564"})]})]}),!f&&e.jsxs("div",{style:{padding:"11px 14px",background:"var(--v2-color-warning-50)",border:"1px solid var(--v2-color-warning-100)",borderRadius:8,fontSize:12.5,color:"var(--v2-color-warning-700)",display:"flex",gap:8},children:[e.jsx(se,{className:"h-4 w-4",style:{flexShrink:0,marginTop:1}}),"Sem backlog, o time poderá ser encontrado no chat, mas ainda não terá métricas de tarefas ou sprint."]})]}),e.jsxs("div",{className:"v2-mt-6",style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(P,{variant:"ghost",onClick:x,children:"Cancelar"}),e.jsx(P,{onClick:w,disabled:v,children:a?"Salvar alterações":"Criar time"})]})]})}function da({unitId:a}){const{toast:n}=fe(),d=je(),p=ye(),i=[`/api/delivery-units/${a}/members`],{data:x,isLoading:v,isError:r,error:I,refetch:g}=B({queryKey:i,queryFn:async()=>(await y("GET",`/api/delivery-units/${a}/members`)).json()}),c=(x==null?void 0:x.members)??[],{data:m}=B({queryKey:["/api/sharing/people"],queryFn:async()=>(await y("GET","/api/sharing/people")).json()}),l=new Set(c.map(t=>t.personId)),u=((m==null?void 0:m.people)??[]).filter(t=>!l.has(t.id)),[f,S]=j.useState(""),[A,w]=j.useState(""),[o,k]=j.useState(""),[N,F]=j.useState(""),T=t=>n({title:"Erro no roster",description:Q(t),variant:"destructive"}),D=()=>d.invalidateQueries({queryKey:i}),E=C({mutationFn:async()=>{const t=f?{personId:f,roleInTeam:N.trim()||null}:{displayName:A.trim(),email:o.trim()||void 0,roleInTeam:N.trim()||null};return(await y("POST",`/api/delivery-units/${a}/members`,t)).json()},onSuccess:()=>{D(),d.invalidateQueries({queryKey:["/api/sharing/people"]}),S(""),w(""),k(""),F(""),n({title:"Pessoa adicionada ao time"})},onError:T}),L=C({mutationFn:async({memberId:t,roleInTeam:q})=>(await y("PATCH",`/api/delivery-units/${a}/members/${t}`,{roleInTeam:q})).json(),onSuccess:D,onError:T}),J=C({mutationFn:async t=>(await y("DELETE",`/api/delivery-units/${a}/members/${t}`)).json(),onSuccess:()=>{D(),n({title:"Pessoa removida do time"})},onError:T}),V=f?!0:A.trim().length>=2;return e.jsxs("div",{style:{marginBottom:18,paddingBottom:14,borderBottom:"1px solid var(--v2-border)"},children:[e.jsx("div",{className:"v2-eyebrow",style:{marginBottom:8},children:"Pessoas do time"}),v?e.jsx("p",{className:"v2-muted",style:{fontSize:12.5,margin:"4px 0 10px"},children:"Carregando roster…"}):r?e.jsx(be,{error:I,recurso:"o roster do time",onRetry:()=>g()}):c.length===0?e.jsx("p",{className:"v2-muted",style:{fontSize:12.5,margin:"4px 0 10px"},children:"Ninguém no time ainda. Adicione pessoas do diretório ou crie uma nova."}):e.jsx("div",{className:"v2-col v2-gap-1",style:{marginBottom:10},children:c.map(t=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("div",{style:{flex:"1 1 auto",minWidth:0},children:[e.jsx("span",{style:{fontWeight:500,fontSize:13},children:t.displayName}),t.email&&e.jsx("span",{className:"v2-muted",style:{fontSize:"var(--v2-text-xs)",marginLeft:6},children:t.email})]}),e.jsx("input",{className:"v2-input",style:{width:150,padding:"4px 8px",fontSize:12.5},placeholder:"Cargo no time",defaultValue:t.roleInTeam??"","aria-label":`Cargo de ${t.dis
1playName} no time`,onBlur:q=>{const _=q.target.value.trim()||null;_!==(t.roleInTeam??null)&&L.mutate({memberId:t.id,roleInTeam:_})}}),e.jsx("button",{className:"v2-icon-btn","aria-label":`Remover ${t.displayName} do time`,title:"Remover do time (a pessoa continua no diretório)",onClick:async()=>{await p({title:"Remover do time",message:`Remover ${t.displayName} deste time? A pessoa continua no diretório.`,confirmLabel:"Remover",destructive:!0})&&J.mutate(t.id)},children:e.jsx(Se,{className:"h-3.5 w-3.5",style:{color:"var(--v2-text-subtle)"}})})]},t.id))}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6,alignItems:"center"},children:[e.jsxs(Z,{value:f,onChange:t=>S(t.target.value),"aria-label":"Pessoa do diretório",style:{minWidth:170,fontSize:12.5},children:[e.jsx("option",{value:"",children:"+ Nova pessoa…"}),u.map(t=>e.jsx("option",{value:t.id,children:t.email&&t.displayName.toLowerCase()!==t.email.toLowerCase()?`${t.displayName} · ${t.email}`:t.displayName},t.id))]}),!f&&e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"v2-input",style:{width:140,padding:"5px 8px",fontSize:12.5},placeholder:"Nome *",value:A,onChange:t=>w(t.target.value),"aria-label":"Nome da nova pessoa"}),e.jsx("input",{className:"v2-input",style:{width:170,padding:"5px 8px",fontSize:12.5},placeholder:"E-mail (evita duplicar)",value:o,onChange:t=>k(t.target.value),"aria-label":"E-mail da nova pessoa"})]}),e.jsx("input",{className:"v2-input",style:{width:130,padding:"5px 8px",fontSize:12.5},placeholder:"Cargo no time",value:N,onChange:t=>F(t.target.value),"aria-label":"Cargo no time"}),e.jsx(P,{size:"sm",onClick:()=>E.mutate(),disabled:!V||E.isPending,loading:E.isPending,leftIcon:E.isPending?void 0:e.jsx(ee,{className:"h-3.5 w-3.5"}),children:"Adicionar"})]})]})}export{wa as default};
2//# sourceMappingURL=unidades-entrega-BCGjFzeh.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.