whoami7 - Manager
:
/
home
/
qbizpnmr
/
arif.umairtax.com
/
public
/
Upload File:
files >> //home/qbizpnmr/arif.umairtax.com/public/Import-BX9PEpNz.js
import{u as v,a as k,p as d,fx as E,bf as m,j as t,by as $,fy as L,c6 as P,ay as R,eR as B,ae as z,H as U,r as A,e as M,L as O,Q as q,ck as H,C as K}from"./bundle.OlIVtvc7.js";const Q=U.div` border-color: ${a=>a.theme.borderColor}; &:hover { border-color: ${a=>a.theme.hoverBorderColor}; } `;function W(a){const[n]=v(),{entity:u}=a,c=k(),[l,h]=d.useState([]),[g,j]=d.useState(),[i,p]=d.useState(new FormData),[y,b]=d.useState(!1),w=()=>{if(!y){if(!l.length){m.error("select_file");return}return m.processing(),b(!0),j(void 0),A("POST",M("/api/v1/edocument/upload"),i).then(e=>{var s;m.success(((s=e==null?void 0:e.data)==null?void 0:s.message)??"success")}).catch(e=>{var s;((s=e.response)==null?void 0:s.status)===422&&(m.dismiss(),j(e.response.data))}).finally(()=>{h([]),b(!1),p(new FormData)})}},C=()=>{l.forEach(e=>{i.append("documents[]",e)}),p(i)},D=e=>{const s=l.filter((o,f)=>e!==f),r=new FormData;r.append("import_type",u),r.append("_method","PUT"),h(s),p(r)},_=e=>new Promise(s=>{try{const r=new FileReader;r.onload=o=>{var F;const x=(((F=o.target)==null?void 0:F.result)||"").split(` `);!x.length||x.length===1||x.length===2&&!x[1]?s(!1):s(!0)},r.readAsText(e)}catch{s(!1)}}),N=async e=>{for(let s=0;s<e.length;s++)if(!await _(e[s]))return!1;return!0},{getRootProps:T,getInputProps:I,isDragActive:S}=E({accept:{"application/xml":[".xml"]},onDrop:async e=>{if(await N(e))if(e.every(({type:o})=>o.includes(o))){let o=[];e.map(f=>{o=[...o,f]}),h(o),i.append("import_type",u),i.append("_method","PUT"),p(i)}else m.error("wrong_file_extension");else m.error("xml_lines_length")}});return d.useEffect(()=>{C()},[l]),d.useEffect(()=>()=>{h([]),p(new FormData)},[]),t.jsxs("div",{className:"flex flex-col space-y-4",children:[t.jsx($,{leftSide:n("xml_file"),children:l.length?t.jsx("ul",{className:"grid xs:grid-rows-6 lg:grid-cols-2 gap-3",children:l.map((e,s)=>t.jsxs("li",{className:"flex items-center justify-between cursor-pointer p-2",style:{backgroundColor:c.$4},children:[e.name," - ",(e.size/1024).toPrecision(2)," KB"," ",t.jsx(R,{element:B,size:19,className:"cursor-pointer",onClick:()=>D(s)})]},s))}):t.jsxs("div",{...T(),className:"flex flex-col md:flex-row md:items-center",children:[t.jsxs(Q,{className:"relative block w-full border-2 border-dashed rounded-lg p-12 text-center",theme:{borderColor:c.$21,hoverBorderColor:c.$17},children:[t.jsx("input",{...I()}),t.jsx("div",{className:"flex justify-center",children:t.jsx(L,{size:"2.3rem",color:c.$3})}),t.jsx("span",{className:"mt-2 block text-sm font-medium",style:{color:c.$3,colorScheme:c.$0},children:n(S?"drop_file_here":"dropzone_default_message")})]}),g&&Object.keys(g.errors).map((e,s)=>t.jsx(P,{children:g.errors[e]},s))]})}),t.jsx("div",{className:"flex justify-end pr-5",children:t.jsx(z,{behavior:"button",onClick:w,disableWithoutIcon:!0,disabled:!l.length||y,children:n("import")})})]})}function G(){const{t:a}=v(),{documentTitle:n}=O("import"),u=[{name:a("expenses"),href:"/expenses"},{name:a("import"),href:"/expenses/import"}];return t.jsx(q,{title:n,breadcrumbs:u,children:t.jsx("div",{className:"grid grid-cols-12",children:t.jsxs("div",{className:"col-span-12 xl:col-span-10 space-y-4",children:[t.jsx(H,{entity:"expense",onSuccess:!1,type:"csv"}),t.jsx(K,{children:t.jsx(W,{entity:"expense",type:"xml"})})]})})})}export{G as default};
Copyright ©2021 || Defacer Indonesia