dappros/ethora

View on GitHub
client-web/build/static/js/177.503185eb.chunk.js

Summary

Maintainability
A
0 mins
Test Coverage
"use strict";(self.webpackChunkweb_app=self.webpackChunkweb_app||[]).push([[177],{3177:function(e,n,t){t.r(n);var r=t(74165),a=t(15861),o=t(70885),i=t(36459),l=t(72791),c=t(50228),s=t(17205),u=t(37924),d=t(59911),p=t(55705),m=t(47409),f=t(52775),h=t(80184);n.default=function(e){(0,i.Z)(e);var n=(0,l.useState)(!1),t=(0,o.Z)(n,2),x=t[0],v=t[1],g=(0,l.useRef)(null),y=(0,f.D)().showSnackbar,b=(0,l.useState)({_id:"",createdAt:"",expiresAt:0,filename:"",isVisible:!0,location:"",locationPreview:"",mimetype:"",originalname:"",ownerKey:"",size:0,updatedAt:"",userId:""}),w=(0,o.Z)(b,2),Z=w[0],k=w[1],j=(0,p.TA)({initialValues:{documentName:"",file:null},validate:function(e){var n={};return e.documentName||(n.documentName="Required"),Z||(n.file="File required"),n},onSubmit:function(){var e=(0,a.Z)((0,r.Z)().mark((function e(n){var t;return(0,r.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return v(!0),e.prev=1,t=Z.location,e.next=5,m.Vy().post("/docs",{documentName:n.documentName,files:[t]});case 5:e.sent,y("success","Document uploaded successfully"),v(!1),e.next=15;break;case 10:e.prev=10,e.t0=e.catch(1),console.log(e.t0),y("error","Uploading failed"),v(!1);case 15:case"end":return e.stop()}}),e,null,[[1,10]])})));return function(n){return e.apply(this,arguments)}}()}),N=function(){var e=(0,a.Z)((0,r.Z)().mark((function e(n){var t,a;return(0,r.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return v(!0),console.log(n),e.prev=2,(t=new FormData).append("files",n.target.files[0]),e.next=7,m.Vy().post("/files",t);case 7:a=e.sent,k(a.data.results[0]),j.setValues(a.data.results[0]),e.next=15;break;case 12:e.prev=12,e.t0=e.catch(2),console.log(e.t0);case 15:v(!1);case 16:case"end":return e.stop()}}),e,null,[[2,12]])})));return function(n){return e.apply(this,arguments)}}();return(0,h.jsx)(c.Z,{children:(0,h.jsx)(c.Z,{sx:{width:"100%"},children:(0,h.jsx)(c.Z,{sx:{width:"50%",typography:"body1",padding:1,margin:"auto"},children:(0,h.jsxs)("form",{style:{flex:"1"},onSubmit:j.handleSubmit,children:[(0,h.jsxs)(c.Z,{style:{padding:"10px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:Z.locationPreview?"end":"center",border:Z.locationPreview?"none":"1px solid gray",borderRadius:"10px",height:"300px",backgroundImage:Z.locationPreview?"url(".concat(Z.locationPreview,")"):"none",backgroundSize:"contain",backgroundPosition:"center",backgroundRepeat:"no-repeat"},children:[(0,h.jsx)("input",{onChange:N,ref:g,type:"file",style:{display:"none"}}),(0,h.jsx)(s.Z,{disabled:x,color:"secondary",variant:"contained",onClick:function(){var e;return null===g||void 0===g||null===(e=g.current)||void 0===e?void 0:e.click()},children:"Upload File"})]}),j.touched.file&&j.errors.file&&(0,h.jsx)(u.Z,{error:!0,children:j.errors.file}),(0,h.jsx)(d.Z,{margin:"dense",inputProps:{autoComplete:"off"},label:"Document Name",name:"documentName",type:"text",fullWidth:!0,variant:"standard",onChange:function(e){j.handleChange(e)},onBlur:j.handleBlur,error:j.touched.documentName&&Boolean(j.errors.documentName),helperText:j.touched.documentName&&j.errors.documentName?j.errors.documentName:""}),(0,h.jsx)(c.Z,{sx:{margin:2,display:"flex",justifyContent:"center"},children:(0,h.jsx)(s.Z,{disabled:x,type:"submit",variant:"contained",children:"Create"})})]})})})})}}}]);
//# sourceMappingURL=177.503185eb.chunk.js.map