1import{R as A,a0 as h,L as e,T as M,U as I,W as K,Y as H,bZ as Q,S as V,ag as y,a6 as G,b2 as w,a5 as g,c1 as F,aI as U,aJ as Y,aK as p,aL as x,aM as Z,aO as u,Z as j,O as i,aa as $,ab as J,ac as W,ad as X,a2 as m,a3 as O,ax as N,ay as _,az as C,aA as S,aB as b,by as ee,bu as se}from"./index_ec3ba43a.js";import{h as D,r as P,b as ae}from"./requiredDocuments_87ae3ac4.js";function re(c=!0){return A({queryKey:D.missingSummary(),enabled:c,staleTime:6e4,queryFn:async()=>{const{data:s,error:t}=await h.rpc("hr_central_missing_documents");if(t)throw t;return s??[]}})}function te(){const{data:c,isLoading:s}=re(),t=c??[];return e.jsxs(M,{children:[e.jsx(I,{className:"pb-3",children:e.jsxs(K,{className:"text-base",children:["Pendências por pessoa",!s&&e.jsxs("span",{className:"ml-2 text-sm font-normal text-muted-foreground",children:[t.length," pessoa(s)"]})]})}),e.jsxs(H,{className:"space-y-2",children:[s&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregando..."}),!s&&t.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Ninguém com documento faltando."}),t.map(a=>e.jsxs(Q,{to:`${V.HR_EMPLOYEES}/${a.employee_id}`,className:"flex flex-wrap items-center justify-between gap-2 rounded-md border p-3 hover:bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:a.full_name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:P(a.contract_regime)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[a.missing_count>0&&e.jsxs(y,{variant:"outline",children:[a.missing_count," faltando"]}),a.rejected_count>0&&e.jsxs(y,{variant:"destructive",children:[a.rejected_count," recusado(s)"]}),a.pending_review_count>0&&e.jsxs(y,{variant:"secondary",children:[a.pending_review_count," em conferência"]})]})]},a.employee_id))]})]})}function ce(c=!0){return A({queryKey:[...D.list(),c],staleTime:6e4,queryFn:async()=>{let s=h.from("hr_required_documents").select("*").order("sort_order",{ascending:!0}).order("label",{ascending:!0});c||(s=s.eq("is_active",!0));const{data:t,error:a}=await s;if(a)throw a;return t??[]}})}function z(){const c=G(),s=()=>c.invalidateQueries({queryKey:D.all}),t=w({mutationFn:async r=>{const o={regime:r.regime,label:r.label.trim(),category:r.category,kind:r.kind,is_active:r.is_active,sort_order:r.sort_order},{error:l}=r.id?await h.from("hr_required_documents").update(o).eq("id",r.id):await h.from("hr_required_documents").insert(o);if(l)throw l},onSuccess:()=>{s(),g.success("Lista de documentos atualizada")},onError:r=>g.error(F(r))}),a=w({mutationFn:async r=>{const{error:o}=await h.from("hr_required_documents").delete().eq("id",r);if(o)throw o},onSuccess:()=>{s(),g.success("Documento removido da lista")},onError:r=>g.error(F(r))});return{save:t,remove:a}}function ne({items:c,onEdit:s,onRemove:t}){return e.jsxs(U,{children:[e.jsx(Y,{children:e.jsxs(p,{children:[e.jsx(x,{children:"Documento"}),e.jsx(x,{children:"Regime"}),e.jsx(x,{children:"Tipo"}),e.jsx(x,{children:"Situação"}),e.jsx(x,{className:"text-right",children:"Ações"})]})}),e.jsxs(Z,{children:[c.map(a=>e.jsxs(p,{children:[e.jsx(u,{className:"font-medium",children:a.label}),e.jsx(u,{children:P(a.regime)}),e.jsx(u,{children:a.kind==="foto"?"Foto":"Documento"}),e.jsx(u,{children:e.jsx(y,{variant:a.is_active?"default":"outline",children:a.is_active?"Exigido":"Desativado"})}),e.jsxs(u,{className:"text-right space-x-2",children:[e.jsx(j,{size:"sm",variant:"outline",onClick:()=>s(a),children:"Editar"}),e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>t(a),children:"Remover"})]})]},a.id)),c.length===0&&e.jsx(p,{children:e.jsx(u,{colSpan:5,className:"text-sm text-muted-foreground",children:"Nenhum documento exigido cadastrado."})})]})]})}const oe=[{value:"identificacao",label:"Identificação"},{value:"contrato",label:"Contrato"},{value:"trabalhista",label:"Trabalhista"},{value:"saude",label:"Saúde"},{value:"financeiro",label:"Financeiro"},{value:"formacao",label:"Formação"}];function le({open:c,editing:s,onOpenChange:t}){const{save:a}=z(),[r,o]=i.useState(""),[l,v]=i.useState("clt"),[f,d]=i.useState("identificacao"),[E,q]=i.useState("documento"),[T,R]=i.useState(!0),[k,L]=i.useState(1);i.useEffect(()=>{c&&(o((s==null?void 0:s.label)??""),v((s==null?void 0:s.regime)??"todos"),d((s==null?void 0:s.category)??"identificacao"),q((s==null?void 0:s.kind)??"documento"),R((s==null?void 0:s.is_active)??!0),L((s==null?void 0:s.sort_order)??1))},[c,s]);const B=async()=>{r.trim()&&(await a.mutateAsync({id:s==null?void 0:s.id,label:r,regime:l==="todos"?null:l,category:f,kind:E,is_active:T,s
1ort_order:k}),t(!1))};return e.jsx($,{open:c,onOpenChange:t,children:e.jsxs(J,{children:[e.jsx(W,{children:e.jsx(X,{children:s?"Editar documento exigido":"Novo documento exigido"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Nome"}),e.jsx(O,{value:r,onChange:n=>o(n.target.value)})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Regime"}),e.jsxs(N,{value:l,onValueChange:n=>v(n),children:[e.jsx(_,{children:e.jsx(C,{})}),e.jsx(S,{children:ae.map(n=>e.jsx(b,{value:n.value,children:n.label},n.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Categoria"}),e.jsxs(N,{value:f,onValueChange:n=>d(n),children:[e.jsx(_,{children:e.jsx(C,{})}),e.jsx(S,{children:oe.map(n=>e.jsx(b,{value:n.value,children:n.label},n.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Tipo"}),e.jsxs(N,{value:E,onValueChange:n=>q(n),children:[e.jsx(_,{children:e.jsx(C,{})}),e.jsxs(S,{children:[e.jsx(b,{value:"documento",children:"Documento"}),e.jsx(b,{value:"foto",children:"Foto"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Ordem"}),e.jsx(O,{type:"number",value:k,onChange:n=>L(Number(n.target.value)||0)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ee,{checked:T,onCheckedChange:R}),e.jsx(m,{children:"Exigir este documento"})]})]}),e.jsxs(se,{children:[e.jsx(j,{variant:"outline",onClick:()=>t(!1),children:"Cancelar"}),e.jsx(j,{disabled:!r.trim()||a.isPending,onClick:()=>void B(),children:"Salvar"})]})]})})}function ue(){const{data:c,isLoading:s}=ce(),{remove:t}=z(),[a,r]=i.useState(!1),[o,l]=i.useState(null),v=()=>{l(null),r(!0)},f=d=>{l(d),r(!0)};return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Documentos de admissão"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Defina o que cada regime precisa entregar. A lista aparece no link de cadastro e na Central do Colaborador."})]}),e.jsx(j,{onClick:v,children:"Novo documento"})]}),e.jsxs(M,{children:[e.jsx(I,{className:"pb-3",children:e.jsx(K,{className:"text-base",children:"Lista exigida"})}),e.jsx(H,{children:s?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregando..."}):e.jsx(ne,{items:c??[],onEdit:f,onRemove:d=>void t.mutateAsync(d.id)})})]}),e.jsx(te,{}),e.jsx(le,{open:a,editing:o,onOpenChange:r})]})}export{ue as default};
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.