whoami7 - Manager
:
/
home
/
qbizpnmr
/
arif.umairtax.com
/
public
/
Upload File:
files >> /home/qbizpnmr/arif.umairtax.com/public/AddUninvoicedItemsButton-tU0BNzSr.js
import{f as C,j as e,c5 as I,e as k,l as _,c6 as T,u as M,a as O,c7 as R,w as W,c8 as D,c9 as H,ca as L,p as o,a$ as G,cb as U,ad as X,bx as q,cc as J,bb as g,cd as S,ae as w,H as A}from"./bundle.OlIVtvc7.js";function K(n){const{dateFormat:i}=C(),s=n.clientId?`&client_id=${n.clientId}`:"",m=n.clientStatus?`&client_status=${n.clientStatus}`:"";return e.jsxs(e.Fragment,{children:[e.jsx(I,{endpoint:k(`/api/v1/expenses?per_page=800${m}${s}`),inputOptions:{value:n.defaultValue??null,label:n.label},entryOptions:{id:"id",label:"number",value:"id",dropdownLabelFn:l=>e.jsxs("div",{className:"flex space-x-1",children:[e.jsxs("span",{children:["# ",l.number]}),l.date&&e.jsx("span",{children:"-"}),l.date&&e.jsx("span",{children:_(l.date,i)})]})},onChange:l=>n.onValueChange&&n.onValueChange(l),onDismiss:n.onClearButtonClick,sortBy:"created_at|desc",nullable:!0,clearInputAfterSelection:n.clearInputAfterSelection,exclude:n.exclude,withShadow:n.withShadow}),e.jsx(T,{className:"mt-2",children:n.errorMessage})]})}function Q(n){const{dateFormat:i}=C(),s=n.clientId?`&client_id=${n.clientId}`:"",m=n.clientStatus?`&client_status=${n.clientStatus}`:"";return e.jsxs(e.Fragment,{children:[e.jsx(I,{endpoint:k(`/api/v1/tasks?per_page=800${m}${s}`),inputOptions:{value:n.defaultValue??null,label:n.label},entryOptions:{id:"id",label:"number",value:"id",dropdownLabelFn:l=>e.jsxs("div",{className:"flex space-x-1",children:[e.jsxs("span",{children:["# ",l.number]}),l.date&&e.jsx("span",{children:"-"}),l.date&&e.jsx("span",{children:_(l.date,i)})]})},onChange:l=>n.onValueChange&&n.onValueChange(l),onDismiss:n.onClearButtonClick,sortBy:"created_at|desc",nullable:!0,clearInputAfterSelection:n.clearInputAfterSelection,exclude:n.exclude,withShadow:n.withShadow}),e.jsx(T,{className:"mt-2",children:n.errorMessage})]})}const Y=A.div` display: flex; align-items: center; justify-content: center; width: 50px; height: 50px; border-radius: 50%; `;A.div` background-color: ${n=>n.theme.color}; &:hover { background-color: ${n=>n.theme.hoverColor}; } `;function ee(n){const[i]=M(),{invoice:s,setInvoice:m}=n,l=O();R(),W();const{dateFormat:y}=C(),B=D({onlyAddToInvoice:!0}),{create:F}=H({onlyAddToInvoice:!0}),E=L({onlyAddToInvoice:!0}),[P,$]=o.useState(!1),[b,V]=o.useState(0),[d,h]=o.useState([]),[r,f]=o.useState([]),[u,j]=o.useState([]),v=()=>{$(!1),j([])},z=()=>{b===0?j([]):b===1?h([]):b===2&&f([])},N=()=>!u.length&&!d.filter(t=>!(s!=null&&s.line_items.find(a=>a.task_id===t.id))).length&&!r.filter(t=>!(s!=null&&s.line_items.find(a=>a.expense_id===t.id))).length;return o.useEffect(()=>{s&&(h([]),f([]),m(t=>t&&{...t,line_items:t.line_items.filter(a=>!d.find(c=>c.id===a.task_id)&&!r.find(c=>c.id===a.expense_id))}))},[s==null?void 0:s.client_id]),o.useEffect(()=>()=>{h([]),j([]),f([])},[]),e.jsxs(e.Fragment,{children:[s?e.jsx("div",{className:"fixed right-10 bottom-10",children:e.jsx(G,{placement:"top",message:i("add_item"),width:"auto",withoutArrow:!0,withoutWrapping:!0,children:e.jsx(Y,{onClick:()=>$(!0),style:{backgroundColor:l.$3},children:e.jsx(U,{size:"1.2rem",color:l.$1})})})}):e.jsx(e.Fragment,{}),e.jsxs(X,{size:"extraSmall",title:i("add_item"),visible:P,onClose:v,overflowVisible:!0,withoutBorderLine:!0,withoutVerticalMargin:!0,withoutHorizontalPadding:!0,children:[e.jsxs(q,{tabs:[i("products"),i("tasks"),i("expenses")],width:"full",withHorizontalPadding:!0,horizontalPaddingWidth:"1.5rem",onTabChange:t=>V(t),children:[e.jsxs("div",{className:"flex flex-col space-y-4 pt-1 px-4",children:[e.jsx(J,{label:i("products"),onChange:t=>j(a=>[...a,t.resource]),withoutAction:!0,clearInputAfterSelection:!0,withShadow:!0}),e.jsxs("div",{className:"flex flex-col space-y-0.5",children:[!!u.length&&e.jsx("span",{className:"text-sm font-medium",style:{color:l.$22},children:i("selected_products")}),e.jsxs("div",{className:"flex flex-col max-h-96 overflow-y-auto",children:[u.map((t,a)=>e.jsxs("div",{className:"flex items-center justify-between py-2 space-x-3",children:[e.jsxs("div",{className:"flex flex-col truncate min-w-0",children:[e.jsx("span",{className:"text-sm font-medium",style:{color:l.$3},children:t.product_key}),e.jsx("span",{className:"text-xs",style:{color:l.$17},children:t.notes})]}),e.jsx("div",{className:"cursor-pointer",onClick:()=>j(c=>c.filter((x,p)=>p!==a)),children:e.jsx(g,{color:l.$16,hoverColor:l.$3,borderColor:l.$5,hoverBorderColor:l.$17,size:"1.6rem"})})]},`${t.id}${a}Products`)),!u.length&&e.jsx("span",{className:"text-center font-medium",children:i("no_items_selected")})]})]})]}),e.jsx("div",{className:"flex flex-col space-y-4 pt-1 px-4",children:s!=null&&s.client_id?e.jsxs(e.Fragment,{children:[e.jsx(Q,{label:i("tasks"),clientId:s==null?void 0:s.client_id,clientStatus:"uninvoiced",onValueChange:t=>h(a=>[...a,t.resource]),clearInputAfterSelection:!0,exclude:[...s.line_items.filter(t=>t.type_id===S.Task&&t.task_id).map(t=>t.task_id),...d.map(t=>t.id)],withShadow:!0}),e.jsxs("div",{className:"flex flex-col space-y-0.5",children:[!!d.length&&e.jsx("span",{className:"text-sm font-medium",style:{color:l.$22},children:i("selected_tasks")}),e.jsxs("div",{className:"flex flex-col max-h-96 overflow-y-auto",children:[d.map((t,a)=>e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("span",{className:"text-sm font-medium",style:{color:l.$3},children:["# ",t.number]}),t.date&&e.jsx("span",{className:"text-xs",style:{color:l.$17},children:_(t.date,y)})]}),!(s!=null&&s.line_items.find(c=>c.task_id===t.id))&&e.jsx("div",{className:"cursor-pointer",onClick:()=>h(c=>c.filter((x,p)=>p!==a)),children:e.jsx(g,{color:l.$16,hoverColor:l.$3,borderColor:l.$5,hoverBorderColor:l.$17,size:"1.6rem"})})]},`${t.id}${a}Tasks`)),!d.length&&e.jsx("span",{className:"text-center font-medium",children:i("no_items_selected")})]})]})]}):e.jsxs("span",{className:"text-center font-medium",children:[i("no_client_selected"),"."]})}),e.jsx("div",{className:"flex flex-col space-y-4 pt-1 px-4",children:s!=null&&s.client_id?e.jsxs(e.Fragment,{children:[e.jsx(K,{label:i("expenses"),clientId:s==null?void 0:s.client_id,clientStatus:"uninvoiced",onValueChange:t=>f(a=>[...a,t.resource]),clearInputAfterSelection:!0,exclude:[...s.line_items.filter(t=>t.type_id===S.Product&&t.expense_id).map(t=>t.expense_id),...r.map(t=>t.id)],withShadow:!0}),e.jsxs("div",{className:"flex flex-col space-y-0.5",children:[!!r.length&&e.jsx("span",{className:"text-sm font-medium",style:{color:l.$22},children:i("selected_expenses")}),e.jsxs("div",{className:"flex flex-col max-h-96 overflow-y-auto",children:[r.map((t,a)=>e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("span",{className:"text-sm font-medium",style:{color:l.$3},children:["# ",t.number]}),t.date&&e.jsx("span",{className:"text-xs",style:{color:l.$17},children:_(t.date,y)})]}),!(s!=null&&s.line_items.find(c=>c.expense_id===t.id))&&e.jsx("div",{className:"cursor-pointer",onClick:()=>f(c=>c.filter((x,p)=>p!==a)),children:e.jsx(g,{color:l.$16,hoverColor:l.$3,borderColor:l.$5,hoverBorderColor:l.$17,size:"1.6rem"})})]},`${t.id}${a}Expenses`)),!r.length&&e.jsx("span",{className:"text-center font-medium",children:i("no_items_selected")})]})]})]}):e.jsxs("span",{className:"text-center font-medium",children:[i("no_client_selected"),"."]})})]}),e.jsxs("div",{className:"flex space-x-2 self-end px-4",children:[e.jsx(w,{behavior:"button",type:"secondary",onClick:z,disabled:N(),disableWithoutIcon:!0,children:i("reset")}),e.jsx(w,{behavior:"button",onClick:()=>{u.length&&E(u);const t=d.filter(c=>!(s!=null&&s.line_items.find(x=>x.task_id===c.id)));t.length&&B(t);const a=r.filter(c=>!(s!=null&&s.line_items.find(x=>x.expense_id===c.id)));a.length&&F(a),v()},disabled:N(),disableWithoutIcon:!0,children:i("save")})]})]})]})}export{ee as A};
Copyright ©2021 || Defacer Indonesia