PageSourceSearch

https://app.rhcloud.com.br/assets/MyMedicalLeavesPage-Fsd0voJ_.js

js rhcloud.com.br collected 2026-10-02 00:44:35 UTC 4,373 bytes, 1 lines download raw bytes

1import{bm as Q,bh as B,r as n,b1 as N,bo as R,j as s,ak as z,bD as D,e as i,P as H,a5 as I,a9 as b,C as K,t as O,v as G,x as V,L as C,bE as J,ag as L,bF as U,o as Y,bG as W,bH as X,aL as Z,bl as $,bI as ee,bJ as se,n as _,bK as ae,bL as te}from"./index-D1u-4Eoq.js";import{u as ne}from"./useFocusRequestFromQuery-p7N6kePk.js";import{N as ie,m as l}from"./NewMedicalLeaveDialog-7frpCqm0.js";import{P as re}from"./pencil-BbkDkFOR.js";import"./pagination-Dy8-spPX.js";import"./SearchableSelect-BeilyWSd.js";function me(){var h,y,f,j,v;const w=Q(),E=B(),{focusId:q}=ne(),[M,r]=n.useState(!1),[k,o]=n.useState(null),[u,x]=n.useState(null),T=((y=(h=N({queryKey:l.guide(),queryFn:ae}).data)==null?void 0:h.medical_leave_guide)==null?void 0:y.cid_required_for_health)!==!1,a=N({queryKey:l.mine(),queryFn:te}),p=n.useMemo(()=>{var e;return((e=a.data)==null?void 0:e.data)||[]},[a.data]),c=a.isLoading,m=((v=(j=(f=a.error)==null?void 0:f.response)==null?void 0:j.data)==null?void 0:v.message)||(a.error?"Falha ao carregar afastamentos.":null),d=()=>{E.invalidateQueries({queryKey:l.all})},A=R({mutationFn:se,onSuccess:()=>{_.success("Pedido excluído. O registro permanece no histórico."),d()},onError:e=>{var t,g;return _.error(((g=(t=e==null?void 0:e.response)==null?void 0:t.data)==null?void 0:g.message)||"Não foi possível excluir.")}}),F=()=>{o(null),r(!0)},P=e=>{o(e),r(!0)},S=async e=>{if(await w({title:"Excluir pedido",description:"O pedido será excluído, mas permanece no histórico com o status Excluído.",confirmText:"Excluir",variant:"destructive"})){x(e.id);try{await A.mutateAsync(e.id)}finally{x(null)}}};return s.jsxs("div",{className:"space-y-6 animate-fadeup",children:[s.jsx(z,{icon:D,title:"Meus afastamentos",description:"Abra um novo pedido e acompanhe o histórico.",actions:s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(i,{size:"sm",onClick:F,type:"button",children:[s.jsx(H,{className:"h-4 w-4 mr-1.5"}),"Novo pedido"]}),s.jsxs(i,{variant:"outline",size:"sm",onClick:d,disabled:c,type:"button",children:[s.jsx(I,{className:b("h-4 w-4 mr-1.5",c&&"animate-spin")}),"Atualizar"]})]})}),m&&s.jsx("p",{className:"text-sm text-destructive",children:m}),s.jsxs(K,{children:[s.jsx(O,{children:s.jsx(G,{className:"text-base",children:"Histórico"})}),s.jsx(V,{children:c?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(C,{className:"h-6 w-6 animate-spin text-primary"})}):p.length===0?s.jsxs("p",{className:"text-sm text-muted-foreground text-center py-6",children:["Nenhum pedido ainda. Clique em ",s.jsx("strong",{children:"Novo pedido"})," para registrar um afastamento."]}):s.jsx("ul",{className:"divide-y divide-border",children:p.map(e=>{const t=e.status==="cancelled";return s.jsxs("li",{"data-request-id":e.id,className:b("py-3 flex flex-wrap items-start justify-between gap-3 rounded-md px-1",t&&"opacity-70",$(e.id,q)),children:[s.jsxs("div",{className:"min-w-0 space-y-1.5",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(J,{type:e.leave_type}),s.jsxs("p",{className:"text-sm font-medium",children:[L(e.start_date)," — ",L(e.end_date),s.jsxs("span",{className:"text-muted-foreground font-normal ml-2",children:[e.days,"d"]})]})]}),U(e.leave_type)||e.cid_code?s.jsxs("p",{className:"text-xs font-medium text-rose-700 dark:text-rose-300",children:["CID ",e.cid_code||"não informado"]}):null,e.notes&&s.jsx("p",{className:"text-xs text-muted-foreground",children:e.notes}),e.rejection_reason&&e.status==="rejected"&&s.jsxs("p",{className:"text-xs text-destructive",children:["Motivo: ",e.rejection_reason]})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Y,{variant:X(e.status),className:"font-normal",children:W[e.status]||e.status}),e.can_edit&&s.jsx(i,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>P(e),"aria-label":"Editar pedido",children:s.jsx(re,{className:"h-4 w-4"})}),e.can_cancel&&s.jsx(i,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive",disabled:u===e.id,onClick:()=>S(e),"aria-label":"Excluir pedido",children:u===e.id?s.jsx(C,{className:"h-4 w-4 animate-spin"}):s.jsx(Z,{className:"h-4 w-4"})})]})]},e.id)})})})]}),s.jsx(ie,{open:M,onOpenChange:e=>{r(e),e||o(null)},onCreated:d,item:k,leaveTypeLabels:ee,cidRequiredForHealth:T})]})}
1export{me 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.