(this["webpackJsonpgonzo-test-client"]=this["webpackJsonpgonzo-test-client"]||[]).push([[91],{"/kh7":function(e,t,a){},CgkG:function(e,t,a){"use strict";a.r(t),a.d(t,"SellView",(function(){return Z}));var n=a("q1tI"),r=a.n(n),s=a("XSU/"),o=a("/MKj"),l=a("2tEe"),i=a("VyNe"),c=a("55Ip"),m=a("Ty5D"),d=a("BkRI"),u=a.n(d),p=a("IXwn"),h=a("uSQv"),E=a("wQmL"),f=a("d/v1"),b=a("pJVQ"),g=a("26mJ"),O=a("OtO2"),v=a("4huo"),D=a("Y+p1"),w=a.n(D),y=a("5Z9N"),j=a("pxzG"),I=a("eASP"),S=a("10H7");var P=a("LCzB"),U=a("wd8a");function A(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function C(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class L extends r.a.Component{constructor(e){super(e);let t=u()(this.props.sale);this.props.dispatch(Object(E.c)("edit-sale",function(e){for(var t=1;t({name:e.Value,value:e.ID}))}render(){const{t:e,handleSubmit:t,user:{UserType:a}}=this.props;return r.a.createElement("form",{onSubmit:t},r.a.createElement(f.a,{name:"Price",component:g.a,label:e("price"),type:"number"}),(a===U.MANAGER||a===U.OWNER)&&r.a.createElement(f.a,{name:"OperID",component:O.a,label:e("operator")}),r.a.createElement(f.a,{name:"Buyer",component:v.b,label:e("buyer"),options:this.getClientsOptions()}),r.a.createElement(f.a,{name:"Hcw",component:g.a,label:e("hotWeight"),type:"number",unit:Object(j.l)("weight",I.a.MEDIUM)}),r.a.createElement(p.a,{fixed:!0,renderInPortal:!1},r.a.createElement(h.a,{buttonColor:"success",buttonStyle:"round",icon:r.a.createElement("i",{className:"fad fa-save"})})))}}L=Object(b.a)({form:"edit-sale",onSubmit:function(e,t,a){const{SaleID:n,Price:r,OperID:s,Buyer:o,Hcw:l}=e,{events:i,user:c}=a;let m=[],d=u()(i).filter(e=>e.EvCode===S.b.SELL&&e.EvData.SaleID===n);for(let p of d){let e=u()(p);p.EvData.Price=+r,p.EvData.OperID=s,p.EvData.Buyer=o,p.EvData.Hcw=Object(j.i)(+l,{fromUnit:I.a.MEDIUM}),w()(e,p)||(p.DtaModTime=+new Date,delete p.$loki,m.push(p))}m.length&&t(Object(y.e)(m,c.ClientID,c.LocalUserID)),a.onFinish()},validate:function(e,t){const a={};return e.Price||(a.Price=t.t("required")),e.OperID||(a.OperID=t.t("required")),e.Buyer||(a.Buyer=t.t("required")),e.Hcw||(a.Hcw=t.t("required")),a}})(L),L=Object(o.connect)(e=>({clients:e.dictionary.clients,lang:e.language.lang.lang,user:e.user.user,farm:e.location.farm}))(L);var N=Object(P.a)()(L),V=a("mwIZ"),x=a.n(V),q=a("bt/X"),T=a.n(q),F=a("17UY"),M=a("i7k/"),k=a("Lqn+"),H=a("AAik"),R=a("wd/R"),B=a.n(R);class _ extends r.a.Component{constructor(e){super(e),this.changePath=e=>{const{events:t}=this.state;this.props.onSelect(e?"/".concat(this.props.farm,"/sell/edit/").concat(e.SaleID):null,e,t)},this.buyerValueFormatter=e=>Object(k.d)(e),this.dateValueFormatter=e=>e?B()(e).format("DD.MM.YY"):"",this.weightValueFormatter=e=>Object(j.j)(e,{unit:I.a.MEDIUM,fixed:1});const{farm:t}=this.props;let a=F.a.getAllEventsForFarm(t).filter(e=>e.EvCode===S.b.SELL);this.state={events:a,sales:this.prepareData(a)}}UNSAFE_componentWillReceiveProps(e,t){if(!w()(e.events,this.state.events)&&e.events.length){let t=e.events.filter(e=>e.EvCode===S.b.SELL);e.events.length&&this.setState({events:t,sales:this.prepareData(t)})}}prepareData(e){let t=[],a=e.slice(0).filter(e=>e.EvData.SaleID),n=T()(a,e=>x()(e,"EvData.SaleID"));for(const r of Object.values(n)){let e={AnmCnt:0};e.SaleID=r[0].EvData.SaleID,e.OperID=r[0].EvData.OperID,e.Price=r[0].EvData.Price,e.Buyer=r[0].EvData.Buyer,e.Date=r[0].EvTime,e.Hcw=r[0].EvData.Hcw?r[0].EvData.Hcw:0;for(let t of r)e.AnmCnt=e.AnmCnt+=t.EvData.AnmCnt;t.push(e)}return t}render(){const{sales:e}=this.state,{t:t}=this.props,a=[{name:t("animalCount"),field:"AnmCnt"},{name:t("price"),field:"Price"},{name:t("hotWeight"),field:"Hcw",valueFormatter:this.weightValueFormatter},{name:t("buyer"),field:"Buyer",valueFormatter:this.buyerValueFormatter,customSort:M.b},{name:t("date"),field:"Date",valueFormatter:this.dateValueFormatter,customSort:M.c},{name:"",headerClassName:"index",itemClassName:"index",component:e=>r.a.createElement("i",{className:"fad fa-edit",onClick:()=>this.changePath(e.value)})}];return r.a.createElement("div",{className:"position-relative w-100"},r.a.createElement(H.a,{data:e,headers:a,shouldIndex:!0,showPagination:!0,paginationItems:20}))}}_=Object(o.connect)(e=>({farm:e.location.farm,clients:e.dictionary.clients,events:e.events.events}))(_);var z=Object(P.a)()(_);class Z extends r.a.Component{constructor(e){super(e),this.onEditClick=(e,t,a)=>{const{history:n}=this.props;this.setState({saleData:t,eventData:a},()=>n.push(e))},this.onFinish=()=>{const{farm:e,history:t}=this.props;this.setState({saleData:[],eventData:[]},()=>t.push("/".concat(e,"/sell")))},this.getHeader=()=>{const{t:e}=this.props;try{const{location:{pathname:t}}=this.props;return t.split("/")[3]?e("sale")+" - "+e("sellView.edition"):e("sale")}catch(t){return console.error(t),e("sale")}},this.state={saleData:[],eventData:[]}}render(){const{saleData:e,eventData:t}=this.state;return r.a.createElement("div",{className:"sell-view"},r.a.createElement(s.a,{text:r.a.createElement(r.a.Fragment,null,this.props.history.location.pathname!=="/".concat(this.props.farm,"/sell")&&r.a.createElement(c.Link,{to:"/".concat(this.props.farm,"/sell")},r.a.createElement("i",{className:"fas fa-fw fa-arrow-left"})),this.getHeader())}),r.a.createElement(l.a,{addPaddingForButtons:!0},r.a.createElement(i.a,null,r.a.createElement(m.g,null,r.a.createElement(m.d,{path:"/".concat(this.props.farm,"/sell/edit/:id"),render:()=>r.a.createElement(N,{sale:e,events:t,onFinish:this.onFinish})}),r.a.createElement(m.d,{render:()=>r.a.createElement(z,{onSelect:this.onEditClick})})))))}}Z=Object(o.connect)(e=>({farm:e.location.farm,events:e.events.events}))(Z),Z=Object(P.a)()(Z);t.default=Z},d07K:function(e,t,a){"use strict";a.r(t);var n,r=a("q1tI"),s=a.n(r),o=a("XSU/"),l=a("2tEe"),i=a("/MKj"),c=a("tQsb"),m=a("55Ip"),d=(a("/kh7"),a("r9cP")),u=a("2wEF"),p=a("pBTy");let h=Object(i.connect)(e=>({documents:e.documents.documents}))(n=class extends s.a.Component{render(){const{documents:e=[]}=this.props;let t=e.filter(e=>"PRICING"===e.Type).sort((e,t)=>t.DtaModTime-e.DtaModTime)[0],a=Object(d.b)(t),n=Object(d.a)(t);return s.a.createElement("div",{className:"pricing-view"},s.a.createElement(o.a,{text:s.a.createElement(s.a.Fragment,null,s.a.createElement(m.Link,{to:"/"},s.a.createElement("i",{className:"fas fa-fw fa-arrow-left"}))," ",n||"")}),s.a.createElement(l.a,null,!a&&s.a.createElement(u.a,null),a&&s.a.createElement(c.a,{path:a})),s.a.createElement(p.a,null))}})||n;t.default=h},iU21:function(e,t,a){"use strict";a.r(t);var n=a("mwIZ"),r=a.n(n),s=a("BkRI"),o=a.n(s),l=a("Y+p1"),i=a.n(l),c=a("q1tI"),m=a.n(c),d=a("XSU/"),u=a("2tEe"),p=a("/MKj"),h=a("55Ip"),E=a("udB/"),f=a("5WSC"),b=a("wQmL"),g=a("d/v1"),O=a("jjk5"),v=a("pJVQ"),D=a("Rs7A"),w=a("w2lk"),y=a("2wEF"),j=a("26mJ"),I=a("r9cP"),S=a("VyNe"),P=a("IXwn"),U=a("uSQv"),A=a("JI6e"),C=a("3Z9Z"),L=a("AO/9"),N=a("ST2B"),V=a("PoRY"),x=a("vzZS"),q=a("42xM"),T=a("pBTy"),F=a("ra4M"),M=a("+PoS"),k=a("LCzB"),H=a("XzT5");function R(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function B(e){for(var t=1;t{const{documents:t}=e;let a=o()(t);a.sort((e,t)=>t.DtaModTime-e.DtaModTime),this.fetchDocument(Object(I.b)(a.filter(e=>"EULA"===e.Type)[0]),"eula"),this.fetchDocument(Object(I.b)(a.filter(e=>"RODO"===e.Type)[0]),"rodo"),this.props.dispatch(Object(b.a)("sign-up-view","eulaId",r()(a.filter(e=>"EULA"===e.Type)[0],"DocID"))),this.props.dispatch(Object(b.a)("sign-up-view","rodoId",r()(a.filter(e=>"RODO"===e.Type)[0],"DocID")))},this.fetchDocument=(e,t="")=>{this.setState({["".concat(t)]:z},()=>{fetch(e).then(t=>e&&200===t.status?t.text():Promise.reject(t)).then(e=>{this.setState({["".concat(t)]:B({},z,{fetched:!0,loaded:!0,data:e})})}).catch(()=>{this.setState({["".concat(t)]:B({},z,{fetched:!0,loaded:!1})})})})},this.state={eula:z,rodo:z},this.props.initialize({phone:"+48"})}componentDidMount(){this.getDocuments()}async componentDidUpdate(e,t,a){const{lang:n,synchronousError:r,documents:s}=this.props;if(i()(s,e.documents)||this.getDocuments(this.props),!i()(r,e.synchronousError)||!i()(s,e.documents)){let e={};await H.a.changeLanguage(n),Object.keys(r).map(t=>{e[t]=H.a.t(r[t])}),e&&this.props.dispatch({type:"@@redux-form/CHANGE",meta:{form:"sign-up-view"},payload:{syncErrors:e}})}}render(){const{eula:e,rodo:t}=this.state,{handleSubmit:a,t:n,submitting:r,submitSucceeded:s,error:o}=this.props;return m.a.createElement("div",{className:"pricing-view"},m.a.createElement(d.a,{text:m.a.createElement(m.a.Fragment,null,m.a.createElement(h.Link,{to:"/"},m.a.createElement("i",{className:"fas fa-fw fa-arrow-left"})),n("signUpView.header"))}),m.a.createElement(u.a,null,m.a.createElement("form",{onSubmit:a},o&&m.a.createElement(x.a,{boxColor:"error"},o),m.a.createElement(S.a,null,m.a.createElement(C.a,null,m.a.createElement(A.a,{md:6},m.a.createElement(g.a,{id:"login",name:"login",label:n("signUpView.login"),component:j.a,required:!0})),m.a.createElement(A.a,{md:6},m.a.createElement(g.a,{id:"mail",name:"mail",label:n("email2"),component:j.a,required:!0}))),m.a.createElement(C.a,null,m.a.createElement(A.a,{md:6},m.a.createElement(g.a,{id:"name",name:"name",label:n("nameAndSurrname"),component:j.a,required:!0})),m.a.createElement(A.a,{md:6},m.a.createElement(g.a,{id:"address",name:"address",label:n("adres"),component:j.a,required:!0}))),m.a.createElement(C.a,null,m.a.createElement(A.a,{md:6},m.a.createElement(g.a,{id:"pass",name:"pass",label:n("login.password"),type:"password",component:j.a,required:!0})),m.a.createElement(A.a,{md:6},m.a.createElement(g.a,{id:"confirmPass",name:"confirmPass",label:n("signUpView.confirmPass"),type:"password",component:j.a,required:!0}))),m.a.createElement(C.a,null,m.a.createElement(A.a,{md:6},m.a.createElement(g.a,{id:"license",name:"license",label:n("signUpView.license"),component:j.a,required:!0})),m.a.createElement(A.a,{md:6},m.a.createElement(g.a,{id:"phone",name:"phone",label:n("signUpView.phone"),component:j.a,required:!0}))),m.a.createElement(C.a,null,m.a.createElement(A.a,{md:6},m.a.createElement("div",{className:"license-box",style:{minHeight:"10rem"}},m.a.createElement("label",null,n("signUpView.eula")),m.a.createElement(E.a,{isLoading:!e.fetched}),e.fetched&&e.loaded&&m.a.createElement(m.a.Fragment,null,m.a.createElement(q.a,null,m.a.createElement(f.a,{style:{maxHeight:"20rem"},onTriggered:t=>this.setState({eula:B({},e,{time:t})})},m.a.createElement("div",{dangerouslySetInnerHTML:{__html:e.data}}))),m.a.createElement(g.a,{required:!0,label:n("readAndAccept"),id:"eula",name:"eula",component:w.a,disabled:!e.time})),e.fetched&&!e.loaded&&m.a.createElement(y.a,null))),m.a.createElement(A.a,{md:6},m.a.createElement("div",{className:"license-box",style:{minHeight:"10rem"}},m.a.createElement("label",null,n("signUpView.rodo")),m.a.createElement(E.a,{isLoading:!t.fetched}),t.fetched&&t.loaded&&m.a.createElement(m.a.Fragment,null,m.a.createElement(q.a,null,m.a.createElement(f.a,{style:{maxHeight:"20rem"},onTriggered:e=>this.setState({rodo:B({},t,{time:e})})},m.a.createElement("div",{dangerouslySetInnerHTML:{__html:t.data}}))),m.a.createElement(g.a,{required:!0,label:n("readAndAccept"),id:"rodo",name:"rodo",component:w.a,disabled:!t.time})),t.fetched&&!t.loaded&&m.a.createElement(y.a,null))))),m.a.createElement(P.a,{fixed:!0,renderInPortal:!1},m.a.createElement(U.a,{buttonStyle:"round",buttonColor:"info",isLoading:r,icon:m.a.createElement("i",{className:"fas fa-paper-plane"})})))),m.a.createElement(T.a,null),s&&m.a.createElement(F.a,{show:s,counter:5,action:()=>{this.props.dispatch(Object(M.a)("/login"))}}))}}Z=Object(v.a)({form:"sign-up-view",onSubmit:async function(e,t,a){const{t:n}=a,r={password:e.pass,username:e.login,attributes:{phone_number:e.phone.replace(/\s/g,""),email:e.mail,address:e.address,locale:a.locale||"en",name:e.name,"custom:EULA":e.eulaId,"custom:RODO":e.rodoId,"custom:LicKey":e.license}};return L.a.configure({identityPoolId:N.a.cognito.IDENTITY_POOL_ID,region:N.a.cognito.REGION,userPoolId:N.a.cognito.USER_POOL_ID,userPoolWebClientId:N.a.cognito.APP_CLIENT_ID}),L.a.signUp(r).then(()=>{t({type:"USER_SET_ERROR",payload:100})}).catch(e=>{let t={};throw e.message.includes("AlreadyUsedLicense")?t.license=n("signUpView.licenseAlreadyUsed"):e.message.includes("InvalidLicense")?t.license=n("signUpView.invalidLicense"):e.name.includes("UsernameExists")?t.login=n("signUpView.userNameExist"):t={_error:n("signUpView.unexpectedError")},new O.a(t)})},validate:(e,t)=>{let{t:a}=t;const n={};/^([a-zA-Z0-9]{8,})$/.test(e.login||"")||(n.login=a("signUpView.userNameShould")),/^(.{4,})$/.test(e.name||"")||(n.name=a("required")),/^(.{4,})$/.test(e.address||"")||(n.address=a("required")),/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$/.test(e.pass||"")||(n.pass=a("signUpView.passwordShouldContain")),/^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/.test(e.mail||"")||(n.mail=a("required")),/^([A-Z0-9]{4}-){8}[A-Z0-9]{4}$/.test(e.license||"")||(n.license=a("signUpView.licenseInput")),e.confirmPass&&e.confirmPass===e.pass||(n.confirmPass=a("required"));let r=Object(V.a)(e.phone||"");return e.phone&&"+"!==e.phone.charAt(0)?n.phone=a("errors.phoneNumberError"):(r&&r.isValid()||(n.phone=a("errors.phoneError")),e.phone||(n.phone=a("required"))),e.rodo||(n.rodo=a("required")),e.eula||(n.eula=a("required")),n},destroyOnUnmount:!1,forceUnregisterOnUnmount:!0})(Z),Z=Object(k.a)()(Z),Z=Object(p.connect)(e=>({locale:e.language.locale,documents:e.documents.documents,lang:e.language.lang.lang,synchronousError:Object(D.a)("sign-up-view")(e)}))(Z),t.default=Z}}]); //# sourceMappingURL=main~d1a93df1.2957cf80.chunk.js.map