UNPKG

cluedin-widget

Version:
1 lines 6.37 kB
(window.webpackJsonp=window.webpackJsonp||[]).push([[5],{1778:function(e,t,n){"use strict";var r=n(20);n.d(t,"b",function(){return a}),n.d(t,"c",function(){return o}),n.d(t,"a",function(){return i});var a=function(){return Object(r.a)("GET","api/v1/clean/getprojects").then(r.e).then(function(e){return e.map(function(e){var t=e.name,n=e.id,r=e.rowCount,a=e.created,o=e.modified,i=e.importOptionMetadata,c=void 0===i?[]:i;return{name:t,id:n,rowCount:r,created:a,modified:o,fileSource:c&&c[0]&&c[0].fileSource||null}})})},o=function(e){return Object(r.a)("POST","api/v1/clean/saveproject?projectId=".concat(e))},i=function(e){return Object(r.a)("POST","api/v1/clean/createprojects",e)}},2220:function(e,t,n){"use strict";n.r(t);var r=n(11),a=n.n(r),o=n(12),i=n.n(o),c=n(13),s=n.n(c),l=n(14),u=n.n(l),d=n(15),p=n.n(d),m=n(26),v=n.n(m),h=n(3),f=n.n(h),g=n(7),S=n.n(g),y=n(0),j=n.n(y),E=n(8),C=n(5),w=n(23),b=n.n(w),x=n(144),O=n.n(x),k=n(54),P=n(801),I=n.n(P),T=n(9),F=n(17),N=n.n(F),D=n(1778),M=n(38),A=n(575),R=n(30),W=n.n(R),q=n(138),z=function(e){function t(e){var n;return a()(this,t),n=s()(this,u()(t).call(this,e)),f()(v()(v()(n)),"handleSaveRequest",function(){var e=n.props,t=e.project,r=e.onSaveSuccess,a=e.onSaveError;Object(D.c)(t.id).catch(function(e){a(),n.setState({saved:!1,isSaving:!1,errorSaving:e||!0})}).then(function(e){var t={};t=200===e.status?{saved:!0,isSaving:!1,errorSaving:!1}:{saved:!1,isSaving:!1,errorSaving:!0},r(),n.setState(t)}).catch(function(e){a(),n.setState({saved:!1,isSaving:!1,errorSaving:e||!0})}),n.setState({isSaving:!0})}),n.state={isSaving:!1,saved:!1,errorSaving:!1},n}return p()(t,e),i()(t,[{key:"render",value:function(){var e=this.state.isSaving;return j.a.createElement(F.Button,{loading:e,text:"Commit",disabled:e,onClick:this.handleSaveRequest})}}]),t}(y.Component),J=Object(E.connect)(function(){return{}},function(e){return{onSaveSuccess:function(){return e(Object(q.showSuccess)({message:"Your changes have been saved on the server! It will take a bit of time to process. We will notify you once it is done."}))},onSaveError:function(){return e(Object(q.showError)({message:"An error occurred while attempting to save your changes. Try again in a few seconds. If the issue persists, please contact our support (support@cluedin.com)"}))}}})(z),B=n(10).j.cluedInCleanUrl,G=function(e){var t=e.value,n=void 0===t?Date.now():t;return W()(n).fromNow()},L=[{property:"name",displayName:"Name",isComputed:!0,Component:function(e){var t=e.entity,n=void 0===t?{}:t;return j.a.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:"".concat(B,"project?project=").concat(n.id)},n.name)}},{property:"rowCount",displayName:"Rows count"},{property:"created",displayName:"Created",Component:G},{property:"modified",displayName:"Modified",Component:G},{property:"fileSource",displayName:"Source file"},{property:"Action",displayName:"",isComputed:!0,Component:function(e){var t=e.entity;return j.a.createElement("div",null,j.a.createElement(J,{project:t}))}}],U={entityTypes:["/Organization","/Person","/Infrastructure/Contact","/Sales/Lead"],SkipMin:20,SkipMax:100,TakeMin:20,TakeMax:100},Y=n(60);function _(){var e=S()(["\n thead td:nth-of-type(6) {\n width: 130px;\n text-align:right;\n }\n"]);return _=function(){return e},e}var H=C.default.div(_()),K=function(e){function t(e){var n;return a()(this,t),n=s()(this,u()(t).call(this,e)),f()(v()(v()(n)),"handleProjectsCreation",function(){var e=n.props,t=e.onCreateSuccess,r=e.onCreateError;n.setState({createFetching:!0,createDone:!1,createError:!1}),Object(D.a)(U).then(function(){n.setState({createFetching:!1,createError:!1,createDone:!0}),t(),setTimeout(function(){window.location.reload()},1e3)}).catch(function(e){n.setState({createFetching:!1,createError:e||!0,createDone:!1}),r(),console.log("Error while creating cleaning projects:"),console.log(e)})}),n.state={fetching:!1,invalid:!1,projects:null,createFetching:!1,createError:!1,createDone:!1},n.handleProjectsCreation=n.handleProjectsCreation.bind(v()(v()(n))),n}return p()(t,e),i()(t,[{key:"componentDidMount",value:function(){var e=this;Object(D.b)().then(function(t){e.setState({loading:!1,invalid:!1,projects:t})}).catch(function(t){e.setState({invalid:t||!0,projects:null,loading:!1})}),this.setState({loading:!0})}},{key:"render",value:function(){var e=this.state,t=e.loading,n=e.invalid,r=e.projects,a=e.createFetching;return t?j.a.createElement(M.a,null):n||!r?j.a.createElement(k.Flex,{style:{width:"100%",height:"100%",padding:"32px"}},j.a.createElement(b.a,{type:"danger"},j.a.createElement("div",null,j.a.createElement("div",null,"An error occurred while retrieving your cleaning projects."),j.a.createElement("div",null,"We apologize for the inconvenience, try reloading the page"),j.a.createElement("div",null,"If the issue persists, contact our ",j.a.createElement("a",{href:"mailto:support@cluedin.com"},"support")," for immediate assistance.")))):r&&0===r.length?j.a.createElement(k.Flex,{style:{width:"100%",height:"100%",padding:"32px",flexDirection:"column"}},j.a.createElement(b.a,{style:{minWidth:"500px"}},j.a.createElement("div",null,j.a.createElement("div",null,"0 cleaning project found."))),j.a.createElement("div",{style:{marginTop:"14px"}},j.a.createElement(N.a,{disabled:a,loading:a,icon:j.a.createElement(T.Add,null),text:"Create CluedIn Clean Projects",onClick:this.handleProjectsCreation,type:"primary"}))):j.a.createElement(A.a,null,j.a.createElement("div",{style:{padding:"16px"}},j.a.createElement(I.a,{title:"CluedIn Clean projects",menu:j.a.createElement(k.Flex,{style:{height:"100%",paddingRight:"16px"}},j.a.createElement(N.a,{disabled:a,loading:a,icon:j.a.createElement(T.Add,null),text:"Create CluedIn Clean Projects",onClick:this.handleProjectsCreation,type:"primary"}))},j.a.createElement(H,null,j.a.createElement(O.a,{data:r,properties:L})))))}}]),t}(y.Component);t.default=Object(E.connect)(function(){return{}},function(e){return{onCreateSuccess:function(){return e(Object(Y.c)({description:"Projects creation request successful. We will reload the page to get our the new projects.",type:"success"}))},onCreateError:function(){return e(Object(Y.c)({description:"An error occurred while attempting to create projects. Try again in a few seconds. If the issue persists, please contact our support (support@cluedin.com)",type:"error"}))}}})(K)}}]);