1import{az as F,H as e,bI as ce,aO as G,aL as de,T as U,dM as ue,I as m,dN as me,dO as ve,dP as he,dQ as Ae,dR as Se,aw as _e,ax as ye,ay as Ce,D as s,bT as ge,bU as fe,bW as Ee,bV as Re,bX as xe,aC as be,aE as c,dS as je,dT as Ue,dU as Pe,dV as Te,dW as De}from"./index-8IokZXBO.js";import{S as Le}from"./index-DJKhKpPc.js";function Ie(p){const{openApprovalModal:u,openApprovalLeaveModal:h,approvalCaseRequests:n,approvalCaseLoading:o}=p,d=F();return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"tb-db-table-area","data-cols":"5",children:[e.jsx("div",{className:"tb-db-table-area-head",children:e.jsxs("ul",{children:[e.jsx("li",{children:"Type"}),e.jsx("li",{className:"grid-span-2",children:"Title"}),e.jsx("li",{children:"Status"}),e.jsx("li",{children:"Date Created"})]})}),e.jsx("div",{className:"tb-db-table-area-body tb-clickable-row",children:!o&&n.caseList.map((a,l)=>e.jsxs("ul",{onClick:()=>{if(a.type!=="manual_time"){if(a.type==="timesheet_manual_time"){const r=btoa(JSON.stringify(a));d(`/time-sheet?data=${r}`)}else if(a.type==="timesheet_import_manual_time"){const r=btoa(JSON.stringify(a));d(`/time-sheet-import?data=${r}`)}else if(a.type==="leave_request"){const r=btoa(JSON.stringify(a));d(`/leave-request?data=${r}`)}else if(a.type==="invoice_request"){const r=btoa(JSON.stringify(a));d(`/invoices?data=${r}`)}}},children:[e.jsx("li",{children:e.jsxs("div",{className:"tb-name-flex",children:[e.jsx("img",{height:30,width:30,src:a.type==="manual_time"?"/images/en/approvals-time-sheet-icon.svg":a.type==="leave_request"?"/images/en/leave-request-icon.svg":a.type==="timesheet_manual_time"?"/images/en/approvals-time-sheet-icon.svg":a.type==="timesheet_import_manual_time"?"/images/en/time-sheet-import-icon.svg":a.type==="invoice_request"?"/images/invoice-approval.svg":"/images/window-icon.svg",alt:a.type}),a.type==="manual_time"?"Manual Time":a.type==="leave_request"?"Leave Request":a.type==="timesheet_manual_time"?"Time Sheet":a.type==="timesheet_import_manual_time"?"Time Sheet Import":a.type==="invoice_request"?"Invoice Request":""]})}),e.jsx("li",{className:"grid-span-2 two-line-ellipsis",children:a.title.charAt(0).toUpperCase()+a.title.slice(1)}),e.jsx("li",{children:e.jsx("span",{className:a.status==="pending_approval"?"tb-table-tags tag-gray":a.status==="approved"?"tb-table-tags tag-green":"tb-table-tags tag-red",children:a.status==="pending_approval"?"Pending":a.status.charAt(0).toUpperCase()+a.status.slice(1)})}),e.jsx("li",{children:ce(a.dateCreated)})]},l))}),o&&e.jsx("div",{className:"loader height-min",children:e.jsx(G,{})}),!o&&n.caseList.length<1&&de(n.error)]})})}const Ne=(p,u,h,n,o,d,a)=>l=>{var r={type:u,status:h,...n&&{users:n},...o&&{groups:o},skip:d,limit:a};return U.fetchApprovalCase(r).then(i=>{let A=i.caseList.length>=a;return l({type:ue,payload:{data:i.caseList,loadMore:A}}),l({type:m,payload:{internetAvailable:!0}}),i}).catch(i=>(l({type:me,payload:{error:i}}),i.type==="network"?l({type:m,payload:{internetAvailable:!1}}):l({type:m,payload:{internetAvailable:!0}}),Promise.reject(i)))},Oe=(p,u,h,n,o,d,a)=>l=>{var r={type:u,status:h,...n&&{users:n},...o&&{groups:o},skip:d,limit:a};return U.fetchApprovalCase(r).then(i=>{let A=i.caseList.length>=a;return l({type:Ae,payload:{data:i.caseList,loadMore:A}}),l({type:m,payload:{internetAvailable:!0}}),i}).catch(i=>(l({type:Se,payload:{error:i}}),i.type==="network"?l({type:m,payload:{internetAvailable:!1}}):l({type:m,payload:{internetAvailable:!0}}),Promise.reject(i)))},qe=(p,u,h,n)=>o=>{var d={search:u,skip:h,limit:n,includeInactiveUsers:!!u.length};return U.fetchApprovalRequesUsersGroups(d).then(a=>(o({type:ve,payload:{listUsersDropDown:a}}),o({type:m,payload:{internetAvailable:!0}}),a)).catch(a=>(o({type:he,payload:{error:a}}),a.type==="network"?o({type:m,payload:{internetAvailable:!1}}):o({type:m,payload:{internetAvailable:!0}}),Promise.reject(a)))},Me=p=>{const{leftNavExpand:u,userProfile:h,selectedCompany:n,approvalCaseRequests:o,approvalCaseUsersDropDown:d,approvalCaseSelectedUsers:a,approvalCaseSelectedGroup:l}=p;F();const r=ye(),A=Ce().state||{};s.useState(!1);const[P,T]=s.useState(!1),[H,D]=s.useState(!1),[y,S]=s.useState("all"),[C,K]=s.useState("pending_approval"),[L,W]=s.useState("Pending"),[B,Q]=s.useState("All"),[I,g]=s.useState(0),f=10;s.useState(""),s.useState("");const[k,N]=s.useState(!1),[J,$]=s.useState("group"),[E,R]=s.useState(a.map(t=>
1t.id)),[x,O]=s.useState(l!=null&&l.id?[l.id]:[]),q=ge([fe,Ee,Re,xe],n.user.userRole);s.useState(!1),s.useState("updateRequest"),s.useState(""),s.useEffect(()=>{Y(n.id,y,C,E,x,0,f)},[C,E,x,y]),s.useEffect(()=>{},[A]),s.useEffect(()=>{q&&b("",0,20)},[]);const z=(t,v,_)=>{},X=(t,v,_,j)=>{};function Y(t,v,_,j,pe,w,V){T(!0),r(Ne(t,v,_,j,pe,w,V)).then(()=>{}).catch(Ve=>{}).finally(()=>{T(!1)}),g(w+V)}function Z(){D(!0),r(Oe(n.id,y,C,E,x,I,f)).then(()=>{}).catch(t=>{}).finally(()=>{D(!1)}),g(I+f)}const ee=t=>{K({Pending:"pending_approval",Approved:"approved",Disapproved:"disapproved"}[t]||""),W(t)},ae=t=>{Q(t),g(0),t==="All"?S("all"):t==="Timesheet"?S("timesheet_manual_time"):t==="Timesheet Import"?S("timesheet_import_manual_time"):t==="Leave Request"?S("leave_request"):t==="Invoice Request"&&S("invoice_request")};function b(t,v,_){N(!0),r(qe(n.id,t,v,_)).then(()=>{}).catch(j=>{}).finally(()=>{N(!1)})}const te=t=>{b(t,0,20)},se=t=>{$(t),t==="user"?(R(a.map(v=>v.id)),O(null)):(R(null),O([l.id]))},re=t=>{r({type:je,payload:{userAdded:t}})},le=t=>{r({type:Ue,payload:{userRemoved:t}})},oe=()=>{r({type:Pe}),R([])},ne=()=>{r({type:Te})};function ie(t){r({type:De,payload:{changedGroup:t}})}const{setHeaderData:M}=be();return s.useEffect(()=>{M({title:"Approvals",description:"Details of pending time approvals.",fullUrl:"https://timebee.app/",contentUrl:"https://timebee.app/",pageClass:"approvals-pg",contentAreaClass:""})},[M]),e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"tb-everypage-head",children:e.jsxs("div",{className:"contant-head",children:[q&&e.jsx(Le,{loading:k,onChangeSearchWord:te,searchedUsersGroups:d,selectedUsers:a,slectedTab:J,onSelectUser:re,onRemoveUser:le,onClearUsers:oe,onGroupSelectionChange:ie,onClearGroups:ne,onBlur:se,getUsersDropDown:b,leftNavExpand:u}),e.jsxs(c,{className:"tb-db-dropdown",onSelect:ae,children:[e.jsx(c.Toggle,{children:B}),e.jsx(c.Menu,{children:e.jsxs("ul",{children:[e.jsx(c.Item,{eventKey:"All",children:"All"}),e.jsx(c.Item,{eventKey:"Timesheet",children:"Timesheet"}),e.jsx(c.Item,{eventKey:"Timesheet Import",children:"Timesheet Import"}),e.jsx(c.Item,{eventKey:"Leave Request",children:"Leave Request"}),e.jsx(c.Item,{eventKey:"Invoice Request",children:"Invoice Request"})]})})]}),e.jsxs(c,{className:"tb-db-dropdown",title:L,onSelect:ee,children:[e.jsx(c.Toggle,{children:L}),e.jsx(c.Menu,{children:e.jsxs("ul",{children:[e.jsx(c.Item,{eventKey:"Pending",children:"Pending"}),e.jsx(c.Item,{eventKey:"Approved",children:"Approved"}),e.jsx(c.Item,{eventKey:"Disapproved",children:"Disapproved"})]})})]})]})}),e.jsxs("div",{className:"tb-page-new-section tb-card-box",children:[e.jsx(Ie,{openApprovalModal:z,openApprovalLeaveModal:X,approvalCaseRequests:o,approvalCaseLoading:P}),(()=>{if(H)return e.jsx("div",{className:"loader-blue see-more",children:e.jsx(G,{})});if(!P)return o.loadMore?e.jsx(e.Fragment,{children:e.jsx("div",{className:"loader-blue see-more",onClick:()=>{Z()},children:e.jsx("span",{className:"loading",children:"Show More"})})}):e.jsx(e.Fragment,{})})()]})]})},we=p=>({selectedCompany:p.UserReducer.selectedCompany,approvalCaseRequests:p.ApprovalCaseReducer.approvalCaseRequests,approvalCaseUsersDropDown:p.ApprovalCaseReducer.approvalCaseUsersDropDown,approvalCaseSelectedUsers:p.ApprovalCaseReducer.approvalCaseSelectedUsers,approvalCaseSelectedGroup:p.ApprovalCaseReducer.approvalCaseSelectedGroups,leftNavExpand:p.SupportReducer.leftNavExpand,userProfile:p.UserReducer.userProfile}),He=_e(we)(Me);export{He 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.