(this["webpackJsonpgonzo-test-client"]=this["webpackJsonpgonzo-test-client"]||[]).push([[66],{"3iEP":function(e,t,a){"use strict";var s=a("Y+p1"),n=a.n(s),r=a("E+oP"),o=a.n(r),i=a("q1tI"),l=a.n(i),c=a("/MKj"),m=(a("meOw"),a("f0Wu")),h=a.n(m),d=a("LCzB"),u=a("v9qu");class p extends i.Component{constructor(e){super(e),this.state={}}getClassName(){let e="technical-break-banner";return Object(u.a)()&&(e+=" mobile"),e}componentDidUpdate(e,t,a){const{maintenance:s}=this.props,r=h.a.tz.guess();!s.futureMaintenance||o()(s.futureMaintenance)||n()(s,e.maintenance)||this.setState({DateStart:h.a.tz(s.futureMaintenance.DtaStartTime,r).format("DD-MM-YYYY (H:mm)"),DateEnd:h.a.tz(s.futureMaintenance.DtaEndTime,r).format("DD-MM-YYYY (H:mm)"),show:!0})}render(){const{t:e}=this.props,{DateStart:t,DateEnd:a,show:s}=this.state;return l.a.createElement(l.a.Fragment,null,s&&t&&a&&l.a.createElement("div",{className:this.getClassName()},e("technicalBreakComponent.technicalBreak",{from:t,to:a})))}}p=Object(c.connect)(e=>({maintenance:e.maintenance}))(p),t.a=Object(d.a)("login")(p)},BQza:function(e,t,a){"use strict";var s=a("q1tI"),n=a.n(s),r=a("2HEh"),o=a("v9qu"),i=a("3xDe");class l extends s.Component{constructor(e){super(e),this.state={name:void 0}}getTheme(e){const{cookies:t}=e;let a=Object(o.a)()?" mobile":"",s=t.get("theme")||"normal";if(s!==this.state.name){this.setState({name:s||"normal"});try{document.body.className="theme theme-".concat(s).concat(a)}catch(n){console.error(n)}Object(i.f)()}}componentDidMount(){this.getTheme(this.props)}UNSAFE_componentWillReceiveProps(e,t){this.getTheme(e)}shouldComponentUpdate(e,t,a){return t.name!==this.state.name}render(){const{children:e}=this.props;return n.a.createElement(n.a.Fragment,null,e)}}l=Object(r.a)(l),t.a=l},CjPc:function(e,t,a){"use strict";a.d(t,"a",(function(){return o}));var s=a("q1tI"),n=a.n(s),r=a("Hlay");class o extends n.a.Component{render(){const{input:{value:e,onChange:t},farm:a,selectedUserType:s}=this.props;return console.log("ACTUAL VALUE",e),console.log("SELECTED FARM",a),n.a.createElement(r.a,{selectedUserType:s,value:e||[],onChange:t,farm:a})}}},Csjg:function(e,t,a){"use strict";var s=a("q1tI"),n=a.n(s),r=a("17x9"),o=a.n(r),i=a("bU1z"),l=a("LCzB"),c=a("3xDe");class m extends s.Component{constructor(...e){super(...e),this.getStyles=()=>{const e=window.getComputedStyle(document.getElementsByClassName("fetura-card")[0]||document.getElementById("root"));return{arrowColor:e.getPropertyValue("background-color"),backgroundColor:e.getPropertyValue("background-color"),overlayColor:"rgba(0, 0, 0, 0.4)",primaryColor:Object(c.c)("primary"),textColor:e.getPropertyValue("color"),zIndex:1200}}}render(){const{t:e,showSkipButton:t,autoStart:a,callback:s,continuous:r,debug:o,getHelpers:l,run:c,scrollOffset:m,scrollToFirstStep:h,stepIndex:d,steps:u}=this.props;return n.a.createElement(i.d,{callback:s,continuous:r,debug:o,autoStart:a,getHelpers:l,run:c,showSkipButton:t,scrollOffset:m,scrollToFirstStep:h,stepIndex:d,steps:u,styles:{options:this.getStyles()},locale:{back:e("back"),close:e("close"),last:e("last"),next:e("next"),skip:e("skip")}})}}m.propTypes={callback:o.a.func,continuous:o.a.bool,debug:o.a.bool,getHelpers:o.a.func,run:o.a.bool,scrollOffset:o.a.number,scrollToFirstStep:o.a.bool,stepIndex:o.a.number,steps:o.a.array.isRequired,showSkipButton:o.a.bool},t.a=Object(l.a)()(m)},FKDI:function(e,t,a){"use strict";var s=a("UB5X"),n=a.n(s),r=a("lSCD"),o=a.n(r),i=a("mwIZ"),l=a.n(i),c=a("BkRI"),m=a.n(c),h=a("q1tI"),d=a.n(h),u=a("D1y2"),p=a.n(u),f=a("eDuk"),g=a.n(f),E=a("Ipig"),b=a.n(E),v=a("MOuv");var R=a("3t43"),y=a("d/v1"),O=a("HIda"),D=a("pJVQ"),C=a("tDQA"),I=a("26mJ"),P=a("uSQv"),S=a("4huo"),w=a("AF5L"),k=a("/MKj"),j=a("ovOe"),A=a.n(j),N=a("42xM"),T=a("w2lk"),F=a("wd/R"),L=a.n(F),M=a("IXwn"),_=a("vzZS"),V=a("VyNe"),Y=a("LCzB");function B(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,s)}return a}function x(e){for(var t=1;t{const s={params:m()(t),oneOfOptions:[],oneOfSelected:[],schema:m()(e)};try{const t=e.oneOf.filter(e=>Array.isArray(e.required)).map(e=>({name:e.label||JSON.stringify(e.required),value:e.required}));t.length&&(s.oneOfOptions=t,s.oneOfSelected=a||t[0].value,Object.keys(s.params).forEach(e=>{s.oneOfSelected.includes(e)||delete s.params[e]}),Object.keys(s.schema.properties).forEach(e=>{s.oneOfSelected.includes(e)||delete s.schema.properties[e]}))}catch(n){console.error(n)}return s},this.changeSchema=(e,t=null)=>{const{initialize:a,device:s,validation:n}=this.props;let r={};if(e||null){const t=new g.a({useDefaults:"empty"}).compile(e);let a="array"===e.type?[]:{};t(a),r=a}const{params:o,oneOfOptions:i,oneOfSelected:l,schema:c}=this.getOneOfParams(e,r,t);a({schema:e||null,device:s,oneOfOptions:i,oneOfSelected:t||l,data:{params:o},validation:!!n}),this.generateSchemaForm(c)},this.generateSchemaForm=(e={})=>{this.setState({schemaForm:this.renderInputs(e||{})})},this.changeDevice=e=>{const{initialize:t,device:a,validation:s}=this.props;e&&(l()(e,"DevType")===l()(a,"DevType")&&l()(e,"GatewayID")===l()(a,"GatewayID")&&this.state.schemas.length||Object(w.j)(e,e.DevType,this.clearSchemas,this.loadSchemas,this.clearSchemas)),t({schema:null,device:e||null,oneOf:null,data:{params:{}},validation:!!s}),this.generateSchemaForm()},this.loadSchemas=e=>{const t=e.CAnsw.schema||{};this.setState({schemas:Object.keys(t).map(e=>({value:x({},t[e],{__command:e}),name:"".concat(e," - ").concat(t[e].info||"")}))})},this.clearSchemas=()=>{const{change:e}=this.props;this.setState({schemas:[]}),e("schema",null),this.generateSchemaForm()},this.getComponent=e=>{let t=e.type;const{validation:a}=this.props;return a&&e.enum?S.b:"boolean"===t?T.a:I.a},this.getType=e=>{let t=e.inputType||e.type;return"date"===t&&(t="datetime-local"),t},this.format=e=>"datetime-local"===this.getType(e)?e=>isFinite(e)?L()(e).format(L.a.HTML5_FMT.DATETIME_LOCAL):"":void 0,this.parse=e=>{let t=this.getType(e);if(!e.enum)switch(t){case"number":return e=>isNaN(parseFloat(e))?null:parseFloat(e);case"integer":return e=>isNaN(parseInt(e,10))?null:parseInt(e,10);case"datetime-local":return e=>e?+L()(e,L.a.HTML5_FMT.DATETIME_LOCAL):null;default:return}},this.options=e=>{if(e.enum)return e.enum.map(e=>({name:e,value:e}))},this.renderInputs=(e,t="params",a=!1)=>{let s=[];if("array"===e.type)s.push(d.a.createElement(R.a,{name:t,key:"array_".concat(t),component:({fields:a,meta:{touched:s,error:n,submitFailed:r}})=>d.a.createElement(d.a.Fragment,null,n&&d.a.createElement(_.a,{boxColor:"error"},n),d.a.createElement("label",null,"".concat(t," (").concat([e.inputType,e.type].filter(e=>e).join(" > "),") - ").concat(e.info||"")),d.a.createElement(M.a,null,d.a.createElement(P.a,{buttonColor:"info",type:"button",icon:d.a.createElement("i",{className:"fas fa-plus"}),onClick:()=>a.push({})}),d.a.createElement(P.a,{buttonColor:"secondary",type:"button",icon:d.a.createElement("i",{className:"fas fa-minus"}),onClick:()=>a.remove(a.length-1)})),a.map((t,a)=>d.a.createElement(V.a,{key:a,colorDensity:a%2===0?300:500},this.renderInputs(e.items,"".concat(t),!0))))}));else if("object"===e.type)for(let n of Object.keys(e.properties||{}))s=[...s,this.renderInputs(e.properties[n],t?t+"."+n:n)];else if(["number","integer","string","boolean"].includes(e.type)){let a=this.getType(e);s.push(d.a.createElement(y.a,{name:t,id:t,type:a,format:this.format(e),parse:this.parse(e),component:this.getComponent(e),options:this.options(e),label:"".concat(t," (").concat([e.inputType,e.type].filter(e=>e).join("/"),") - ").concat(e.info||""),key:t}))}return s},this.showParsed=({name:e,namescape:t,type:a,value:s})=>{clearTimeout(this.timer);let r=null;n()(s)&&(r=d.a.createElement(V.a,{colorDensity:200,className:"position-fixed fixed-bottom text-center shadow-big float-right"},d.a.createElement("div",null,"DEC (10): ",s.toString(10)),d.a.createElement("div",null,"HEX (16): ",s.toString(16)),d.a.createElement("div",null,"BIN (2): ",s.toString(2)),d.a.createElement("div",null,"DATE: ",L()(s).format("DD.MM.YYYY HH:mm:ss")),d.a.createElement("div",null,"DATE (UTC): ",L.a.utc(s).format("DD.MM.YYYY HH:mm:ss")))),this.setState({parsed:r}),this.timer=setTimeout(()=>{this.setState({parsed:""})},7500)};const{initialize:t,devices:a}=this.props;this.state={schemas:[],schemaForm:null,options:H.getOptions(this.props),devices:a},t({validation:!0,schema:null,data:{params:{}}})}static getDerivedStateFromProps(e,t){return e.devices!==t.devices?{options:H.getOptions(e),devices:e.devices}:null}render(){const{handleSubmit:e,schema:t,device:a,t:s,terminal:n,dispatch:r,error:o,oneOfOptions:i=[]}=this.props,{schemas:l,schemaForm:c,parsed:m,options:h}=this.state;return d.a.createElement("div",{className:"terminal-form"},d.a.createElement(y.a,{name:"device",id:"device",label:s("device"),component:S.b,options:h,onChange:e=>this.changeDevice(e)}),d.a.createElement(y.a,{name:"schema",id:"schema",label:s("terminalView.terminalForm.commandSchema"),onChange:e=>this.changeSchema(e),options:l,component:S.b}),t&&d.a.createElement(d.a.Fragment,null,d.a.createElement("hr",null),d.a.createElement("label",null,s("terminalView.terminalForm.input"))),d.a.createElement("form",{onSubmit:e,noValidate:!0},!!i.length&&d.a.createElement(y.a,{name:"oneOfSelected",id:"oneOfSelected",label:s("terminalView.terminalForm.oneOfSelector"),onChange:e=>this.changeSchema(t,e),options:i,component:S.b}),d.a.createElement(O.a,{name:"data"},o&&d.a.createElement(_.a,{boxColor:"error"},o),c),d.a.createElement(M.a,{className:"float-right"},d.a.createElement(P.a,{icon:d.a.createElement("i",{className:"fas fa-eraser"}),type:"button",onClick:()=>r({type:"TERMINAL_CLEAR_MESSAGES"})},s("terminalView.terminalForm.clearTerminal")),d.a.createElement(P.a,{disabled:!t,icon:d.a.createElement("i",{className:"fas fa-paper-plane fa-fw"}),buttonColor:"primary"},s("send"))),d.a.createElement(y.a,{name:"validation",id:"validation",label:s("terminalView.terminalForm.validation"),component:T.a})),m,a&&d.a.createElement(d.a.Fragment,null,d.a.createElement("hr",null),d.a.createElement("label",null,s("terminalView.terminalForm.output")),d.a.createElement(N.a,null,d.a.createElement(A.a,{src:n.filter(e=>e&&Object.keys(e)[0].includes(a.GatewayID)),name:" ",onSelect:this.showParsed,collapsed:4,theme:{base00:" ",base01:"#000000",base02:"#000000",base03:"#000000",base04:"purple",base05:"#000000",base06:"#000000",base07:"#000000",base08:"#000000",base09:"#000000",base0A:"#000000",base0B:"#ffc007",base0C:"#000000",base0D:"#33cc33",base0E:"#fd3b60",base0F:"#00afff"}}))))}}H.getOptions=e=>e.devices.map(e=>({name:o()(e.getSelectName)?e.getSelectName():e.Name,value:e})),H=Object(D.a)({form:"terminal-form",onSubmit:function(e,t,a){Object(v.a)(e.device,e.schema.__command,e.data&&e.data.params||{}),console.log(e,a,"eh")},validate:function(e,t){const{locale:a,validation:s}=t,n={};if(!s)return n;const r=new g.a({allErrors:!0,errorMessages:!0}),o=e.schema;if(o){let t=l()(e,"data.params")||("array"===o.type?[]:{});const s=r.compile(o);if(!s(t)){let e=b.a[a]?a:"en";b.a[e](s.errors);const t=m()(s.errors);for(let a of t)if("required"===a.keyword)p()(n,"data.params".concat(a.dataPath,".").concat(a.params.missingProperty),a.message);else{if(""===a.dataPath)return{_error:a.message};p()(n,"data.params".concat(a.dataPath),a.message)}if(0===Object.keys(n).length)return{_error:"Error"}}}return n},touchOnBlur:!0,touchOnChange:!0})(H);const U=Object(C.a)("terminal-form");H=Object(k.connect)(e=>({farm:e.location.farm,schema:U(e,"schema"),device:U(e,"device"),validation:U(e,"validation"),oneOfOptions:U(e,"oneOfOptions"),terminal:e.terminal.messages,locale:e.language.locale,devices:e.farmDevices.devices}))(H);t.a=Object(Y.a)()(H)},Hlay:function(e,t,a){"use strict";var s=a("Y+p1"),n=a.n(s),r=a("E+oP"),o=a.n(r),i=a("mwIZ"),l=a.n(i),c=a("UfWW"),m=a.n(c),h=a("BkRI"),d=a.n(h),u=a("q1tI"),p=a.n(u),f=a("17x9"),g=a.n(f),E=a("/MKj"),b=(a("aXae"),a("LCzB")),v=a("ANjH"),R=a("f0zD"),y=a("KzZF"),O=a("uSQv");class D extends p.a.Component{constructor(...e){super(...e),this.onChange=(e,t)=>{const{itemKey:a,field:s}=this.props;let n=t||[];a&&(0===e?n=[]:2===e&&(n=["*"])),this.props.onChange({type:e,farms:n,itemKey:a,name:s})},this.openModal=()=>{const{currentFarm:e,Plcmnts:t}=this.props;this.props.show(y.a,{farm:e,initialPlacements:t,onModalSubmit:(e,t)=>this.onChange(e,t)})},this.renderItem=(e,t,a,s,n)=>p.a.createElement(O.a,{disabled:n,className:"option",type:"button",icon:s,buttonStyle:"text",onClick:()=>t(),buttonColor:n?"":this.props.type===a?a?1!==a?"success":"info":"error":""},e),this.getOptions=(e=[])=>{const t=[],{t:a,isPrivilege:s}=this.props;return e.forEach(e=>{switch(e){case 0:t.push(this.renderItem(a("userRolePicker.noRights"),()=>this.onChange(0),0,p.a.createElement("i",{className:"fad fa-ban"}),!s));break;case 1:t.push(this.renderItem(a("userRolePicker.readOnly"),()=>this.onChange(1),1,p.a.createElement("i",{className:"far fa-glasses-alt"}),!s));break;case 2:t.push(this.renderItem(a("userRolePicker.fullAccess"),()=>this.onChange(2),2,p.a.createElement("i",{className:"fas fa-pencil"}),!s));break;case 3:t.push(this.renderItem(a("userRolePicker.customAccess"),()=>this.openModal(),3,p.a.createElement("i",{className:"fas fa-clipboard-list-check"}),!s))}}),t}}render(){const{header:e,options:t}=this.props,a=this.getOptions(t);return p.a.createElement("div",{className:"role"},p.a.createElement("label",null,e),p.a.createElement("div",{className:"options"},a.map(e=>e)),p.a.createElement("hr",null))}}D.defaultProps={onChange:()=>{}},D=Object(E.connect)(null,e=>Object(v.b)({show:R.d},e))(D);var C=Object(b.a)()(D),I=a("s506"),P=a("wd8a"),S=a("B/gD");function w(){return(w=Object.assign||function(e){for(var t=1;t{const{value:t,farm:a}=e,{isPrivilege:s}=this.state;if(!o()(t)&&s){let e=t.filter(e=>e.LocalRights.find(e=>e.FarmID===a));const s=e=>0===e.length?1:"*"===e[0]?2:3;o()(e)||e.forEach(a=>{const n=Array.isArray(a.LocalRights.Plcmnts);e=this.setRole(t,a.Role,!0,n?"Plcmnts":void 0,n?a.LocalRights.Plcmnts:[],n?s(a.LocalRights.Plcmnts):2)})}},this.getAllRoles=e=>({general:this.getRoles(e,I.d.GENERAL_READ),breeding:this.getRoles(e,I.d.BREEDING),cage:this.getRoles(e,I.d.DEVICE_CAGE,"Plcmnts"),silo:this.getRoles(e,I.d.DEVICE_SILO,"Plcmnts"),config:this.getRoles(e,I.d.DEVICE_CONFIG),reports:this.getRoles(e,I.d.REPORTS),feeding:this.getRoles(e,I.d.DEVICE_FEEDING,"Plcmnts"),climate:this.getRoles(e,I.d.DEVICE_CLIMATE,"Plcmnts"),chain:this.getRoles(e,I.d.DEVICE_CHAIN,"Plcmnts"),billing:this.getRoles(e,I.d.BILLING),pigletCage:this.getRoles(e,I.d.DEVICE_PIGLET_CAGE,"Plcmnts"),counter:this.getRoles(e,I.d.DEVICE_COUNTER,"Plcmnts"),users:this.getRoles(e,I.d.USER_MANAGE)}),this.findRole=(e,t)=>{const{value:a,farm:s}=e;let n=a.find(e=>e.Role===t);return n&&(n=n.LocalRights.find(e=>e.FarmID===s)),n},this.getRoles=(e,t,a)=>{let s=0;if(a){const n=this.findRole(e,t),r=l()(n,a,[]);return o()(r)||"*"!==r[0]?o()(r)||"*"===r[0]||(s=3):s=2,{type:s,Plcmnts:r}}if(t===I.d.REPORTS){let t=this.findRole(e,I.d.REPORT_READ),a=this.findRole(e,I.d.REPORT_WRITE);t?s=1:a&&(s=2)}else{this.findRole(e,t)&&(s=2)}return{type:s,Plcmnts:[]}},this.onRoleChange=({type:e,farms:t,itemKey:a,name:s})=>{const{value:n,onChange:r}=this.props;let o=d()(n);s===I.d.REPORTS?(1!==e&&0!==e||(o=this.setRole(o,"".concat(s,"_READ"),e>0,a,t,e)),2!==e&&0!==e||(o=this.setRole(o,"".concat(s,"_WRITE"),e>1,a,t,e))):o=this.setRole(o,s,e>1,a,t,e),r(o)},this.onPrivilegeChange=e=>{this.setState({isPrivilege:e},()=>{const{isPrivilege:e}=this.state,{value:t,farm:a,onChange:s,selectedUserType:n}=this.props;if(e||o()(t)){if(e){let e=d()(t);e=this.setRole(e,I.d.GENERAL_READ,!0,void 0,[],2);const a=n===P.MANAGER,r=a?2:0;e=this.setRole(e,I.d.BREEDING,a,void 0,[],r),e=this.setRole(e,I.d.DEVICE_CAGE,a,"Plcmnts",["*"],r),e=this.setRole(e,I.d.DEVICE_SILO,a,"Plcmnts",["*"],r),e=this.setRole(e,I.d.DEVICE_CONFIG,a,void 0,[],r),e=this.setRole(e,I.d.REPORT_READ,a,void 0,[],a?1:0),e=this.setRole(e,I.d.REPORT_WRITE,a,void 0,[],r),e=this.setRole(e,I.d.DEVICE_FEEDING,a,"Plcmnts",["*"],r),e=this.setRole(e,I.d.DEVICE_CLIMATE,a,"Plcmnts",["*"],r),e=this.setRole(e,I.d.DEVICE_CHAIN,a,"Plcmnts",["*"],r),e=this.setRole(e,I.d.BUILDING,a,void 0,[],r),e=this.setRole(e,I.d.DEVICE_PIGLET_CAGE,a,"Plcmnts",["*"],r),e=this.setRole(e,I.d.DEVICE_COUNTER,a,"Plcmnts",["*"],r),a||(e=this.setRole(e,I.d.BILLING,!1,void 0,[],0),e=this.setRole(e,I.d.USER_MANAGE,!1,void 0,[],0)),s(e)}}else{s(t.map(e=>{const t=e.LocalRights.filter(e=>e.FarmID!==a);return function(e){for(var t=1;te.LocalRights.length))}})};const t=this.getAllRoles(this.props);this.state={roles:t,isPrivilege:!1}}componentDidUpdate(e,t,a){if(!n()(e.value,this.props.value)){const e=this.getAllRoles(this.props);this.setState({roles:e})}if(e.farm!==this.props.farm){const e=this.getAllRoles(this.props),{value:t,farm:a}=this.props,s=!!t.find(e=>e.LocalRights.find(e=>e.FarmID===a));this.setState({roles:e,isPrivilege:s},()=>this.checkCurrentRoles(this.props))}e.selectedUserType!==this.props.selectedUserType&&this.state.isPrivilege&&this.onPrivilegeChange(!0)}setRole(e,t,a,s,n=[],r){const{farm:o}=this.props;let i=d()(e)||[],l=m()(i,e=>e.Role===t),c=l>-1?d()(i[l]):{Role:t,LocalRights:[]},h=m()(c.LocalRights,e=>e.FarmID===o);if(h>=0)a?s&&(c.LocalRights[h][s]=n):c.LocalRights.splice(h,1);else if(a){let e={FarmID:o};s&&(e[s]=n),c.LocalRights.push(e)}if(l>-1?i[l]=c:i.push(c),(t===I.d.REPORT_READ||t===I.d.REPORT_WRITE)&&(1===r||2===r)){const e=t===I.d.REPORT_READ?I.d.REPORT_WRITE:I.d.REPORT_READ;let a=m()(i,t=>t.Role===e);if(a>=0){let e=m()(i[a].LocalRights,e=>e.FarmID===o);e>=0&&i[a].LocalRights.splice(e,1)}}return i=i.filter(e=>e.LocalRights.length),i}render(){const{roles:{general:e,breeding:t,cage:a,silo:s,config:n,reports:r,feeding:i,climate:l,chain:c,billing:m,pigletCage:h,counter:d,users:u},isPrivilege:f}=this.state,{farm:g,t:E,selectedUserType:b,user:v}=this.props,R=e=>b===P.MANAGER&&!!v.Roles.find(t=>t.Role===e&&!!t.LocalRights.find(e=>e.FarmID===g)),O=v.UserType,D=b===P.MANAGER,k=[{header:E("userRolePicker.general"),field:I.d.GENERAL_READ,options:[],role:e,hasRole:!0},{header:E("breeding"),field:I.d.BREEDING,options:D?[]:[0,2],role:t,hasRole:!0},{header:E("userRolePicker.cages"),field:I.d.DEVICE_CAGE,options:D?[]:[0,2,3],role:a,itemKey:"Plcmnts",hasRole:!0},{header:E("weights"),field:I.d.DEVICE_SILO,options:D?[]:[0,2,3],role:s,itemKey:"Plcmnts",hasRole:!0},{header:E("userRolePicker.configuration"),field:I.d.DEVICE_CONFIG,options:D?[]:[0,2],role:n,hasRole:!0},{header:E("reports"),field:I.d.REPORTS,options:D?[]:[0,1,2],role:r,hasRole:!0},{header:E("feeding"),field:I.d.DEVICE_FEEDING,options:D?[]:[0,2,3],role:i,itemKey:"Plcmnts",hasRole:!0},{header:E("climate"),field:I.d.DEVICE_CLIMATE,options:D?[]:[0,2,3],role:l,itemKey:"Plcmnts",hasRole:!0},{header:E("userRolePicker.chains"),field:I.d.DEVICE_CHAIN,options:D?[]:[0,2,3],role:c,itemKey:"Plcmnts",hasRole:!0},{header:E("billing"),field:I.d.BILLING,options:D?[0,2]:[],role:m,managerOption:!0,hasRole:R(I.d.BILLING)&&O===P.OWNER},{header:E("userRolePicker.userManage"),field:I.d.USER_MANAGE,options:D?[0,2]:[],role:u,managerOption:!0,hasRole:R(I.d.USER_MANAGE)},{header:E("userRolePicker.smallCages"),field:I.d.DEVICE_PIGLET_CAGE,options:D?[]:[0,2,3],role:h,itemKey:"Plcmnts",hasRole:!0},{header:E("userRolePicker.counters"),field:I.d.DEVICE_COUNTER,options:D?[]:[0,2,3],role:d,itemKey:"Plcmnts",hasRole:!0}].filter(e=>D&&e.hasRole?e:!e.managerOption);return p.a.createElement("div",{className:"fetura-role-picker"},p.a.createElement(S.a,{value:f,label:E(f?"userRolePicker.turnOffPrivilege":"userRolePicker.turnOnPrivilege"),onChange:e=>this.onPrivilegeChange(e)}),p.a.createElement("hr",null)&&k.filter(e=>!o()(e.options)).map((e,t)=>p.a.createElement(C,w({key:t,isPrivilege:f,currentFarm:g,onChange:this.onRoleChange,header:e.header,options:e.options,field:e.field},e.role,{itemKey:e.itemKey}))),p.a.createElement(y.b,null))}}(A=Object(E.connect)((e,t)=>({farm:t.farm||e.location.farm,user:e.user.user}))(A)).propTypes={value:g.a.array.isRequired},A.defaultProps={onChange:()=>{},value:[]};t.a=Object(b.a)()(A)},PkCZ:function(e,t,a){},RFVy:function(e,t,a){"use strict";var s=a("mwIZ"),n=a.n(s),r=a("q1tI"),o=a.n(r),i=a("AAik"),l=a("i7k/"),c=a("Zsfn"),m=a("wd/R"),h=a.n(m),d=a("/MKj"),u=a("17x9"),p=a.n(u);class f extends o.a.Component{render(){const{object:e,onClick:t}=this.props;return o.a.createElement("div",{className:"transaction-item-mobile",onClick:()=>t(e)},o.a.createElement("div",{className:"transaction-item-mobile-data"},o.a.createElement(c.a,{value:e}),o.a.createElement("div",null,o.a.createElement("div",{className:"font-weight-bold"},h()(e.createdAt).format("DD.MM.YYYY HH:mm")),o.a.createElement("div",null,e.amount," ",e.currencyIsoCode))),o.a.createElement("i",{className:"fas fa-chevron-right"}))}}f.propTypes={object:p.a.object,onClick:p.a.func};var g=f,E=(a("PkCZ"),a("VyNe")),b=a("LCzB");class v extends o.a.Component{getError(){const{object:{processorResponseCode:e},t:t}=this.props;return+e>2100?t("transactions.errors")[2101]:t("transactions.errors")[e]}render(){const{object:e,t:t}=this.props;return o.a.createElement("div",null,e&&o.a.createElement(E.a,null,o.a.createElement("div",{className:"transaction-item"},o.a.createElement("div",{className:"font-weight-bold"},t("date")),o.a.createElement("div",null,h()(e.createdAt).format("DD.MM.YYYY HH:mm"))),o.a.createElement("div",{className:"transaction-item"},o.a.createElement("div",{className:"font-weight-bold"},t("sum")),o.a.createElement("div",null,e.amount," ",e.currencyIsoCode)),o.a.createElement("div",{className:"transaction-item"},o.a.createElement("div",{className:"font-weight-bold"},t("cardNumber")),o.a.createElement("div",null,e.creditCard.maskedNumber)),o.a.createElement("div",{className:"transaction-item"},o.a.createElement("div",{className:"font-weight-bold"},t("farmSettings.transactionHistory.period")),o.a.createElement("div",null,h()(e.subscription.billingPeriodStartDate).format("DD.MM.YYYY")," - ",h()(e.subscription.billingPeriodEndDate).format("DD.MM.YYYY"))),o.a.createElement("div",{className:"transaction-item"},o.a.createElement("div",{className:"font-weight-bold"},t("status")),o.a.createElement("div",null,"settled"===e.status?"Zaksi\u0119gowana":this.getError()))))}}v.propTypes={show:p.a.bool,object:p.a.object,onHide:p.a.func},v=Object(d.connect)(e=>({}))(v);var R=Object(b.a)()(v),y=a("ahsf");class O extends o.a.Component{constructor(e){super(e),this.dateValueFormatter=e=>h()(e).format("DD.MM.YYYY HH:mm"),this.maskedNumberValueFormatter=e=>"".concat(e.substr(0,4)," ").concat(e.substr(4,4)," ").concat(e.substr(8,4)," ").concat(e.substr(12,4)),this.subscriptionValueFormatter=e=>"".concat(h()(e.billingPeriodStartDate).format("DD.MM.YYYY")," - ").concat(h()(e.billingPeriodEndDate).format("DD.MM.YYYY")),this.amountValueFormatter=e=>"".concat(e.amount," ").concat(e.currencyIsoCode),this.sortAmount=(e,t,a,s)=>{let n=e.amount,r=t.amount;return Object(l.a)(e,t,a,s,n,r)},this.sortStatus=(e,t,a,s)=>{let n="settled"===e.status,r="settled"===t.status;return Object(l.a)(e,t,a,s,n,r)},this.sortPeriod=(e,t,a,s,n,r)=>{let o=n.billingPeriodStartDate,i=r.billingPeriodStartDate;return Object(l.c)(e,t,a,s,o,i)},this.farmValueFormatter=e=>{const{subscriptions:t}=this.props,a=t.find(t=>t.id===e);return n()(a,"farmName","-")},this.state={show:!1,selected:null}}render(){const{transactions:e,t:t}=this.props,a=[{name:"Ferma",field:"subscriptionId",valueFormatter:this.farmValueFormatter,customSort:l.c},{name:t("date"),field:"createdAt",valueFormatter:this.dateValueFormatter,customSort:l.c},{name:t("sum"),customSort:this.sortAmount,valueFormatter:this.amountValueFormatter},{name:t("cardNumber"),field:"creditCard.maskedNumber",valueFormatter:this.maskedNumberValueFormatter},{name:t("farmSettings.transactionHistory.period"),field:"subscription",valueFormatter:this.subscriptionValueFormatter,customSort:this.sortPeriod},{name:t("status"),component:o.a.createElement(c.a,null),customSort:this.sortStatus},{name:"Faktura",component:o.a.createElement(y.a,null)}];return o.a.createElement(i.a,{data:e,headers:a,shouldIndex:!0,showPagination:!0,paginationItems:20,mobileRow:o.a.createElement(g,null),mobileAdditionalInfo:o.a.createElement(R,null),mobileAdditionalInfoName:t("farmSettings.transactionHistory.name")})}}O=Object(d.connect)(e=>({transactions:e.braintree.transactions,subscriptions:e.braintree.subscriptionList}))(O);t.a=Object(b.a)()(O)},Y8wI:function(e,t,a){"use strict";var s=a("q1tI"),n=a.n(s),r=a("v9qu"),o=a("i8MS"),i=a("7e/R"),l=a("j1RV"),c=a("t9AZ"),m=a("/MKj"),h=a("55Ip"),d=a("Ty5D"),u=a("xLJS"),p=a("gNnm"),f=a("hw2D"),g=a("tkTQ"),E=a("uSQv"),b=a("n7pt"),v=a("I8zd"),R=a("LCzB"),y=a("XzT5");class O extends n.a.Component{constructor(e){super(e),this.keyboardListener=e=>{const{key:t}=e;if(!isNaN(+t)){clearTimeout(this.state.timeout);let e=this.state.rfid+t,a=setTimeout(()=>{this.setState({rfid:""})},Object(r.a)()?500:100);this.setState({rfid:e,timeout:a})}if("Enter"===t&&15===this.state.rfid.length){switch(this.state.worktype){case"documents":this.handleDocuments(this.state.rfid);break;case"feeding":this.handleFeeding(this.state.rfid);break;case"events":this.handleEvents(this.state.rfid);break;default:case"input":console.warn("TODO")}this.props.dispatch(Object(c.b)(Object(i.a)(this.state.rfid))),this.setState({show:!1}),e.preventDefault()}},this.onEventChange=e=>{this.setState({event:e})},this.onDrawerMouseEnter=()=>{this.setState({show:!0})},this.onDrawerMouseLeave=()=>{this.setState({show:!1})},this.state={rfid:"",timeout:null,worktype:"documents",event:"insemination",show:!1}}componentDidMount(){document.addEventListener("keydown",this.keyboardListener)}handleDocuments(e){const{farm:t,t:a}=this.props;let s=o.a.getAnimalByRfid(Object(i.a)(e),t);if(!s){let t=b.a.getBoxBIDByRfid(Object(i.a)(e));t&&(s=o.a.getAllAnimalsForLocation(t,v.a.BOX)[0])}if(s)this.props.history.push("/".concat(t,"/animalDocuments?RFID=").concat(Object(i.a)(e))),this.props.dispatch(Object(c.a)({RFID:Object(i.a)(e),animal:s,type:"documents",data:null}));else{let e={title:a("tagReaderDrawer.noAnimal"),message:y.a.t("tagReaderDrawer.noAnimalText",{number:this.state.rfid}),status:"error",dismissible:!0,dismissAfter:5e3};this.props.dispatch(Object(l.addNotification)(e))}}handleEvents(e){const{farm:t,t:a}=this.props;let s=o.a.getAnimalByRfid(Object(i.a)(e),t);if(!s){let t=b.a.getBoxBIDByRfid(Object(i.a)(e));t&&(s=o.a.getAllAnimalsForLocation(t,v.a.BOX)[0])}if(s){if((!this.props.location.pathname.includes("rfidEvents/insemination")||s.AnimalKind!==g.a.BOAR)&&!this.props.location.pathname.includes("/rfidEvents/transfer")){const e=["insemination","usg","noPregnancy","parturition","separationToPorkhouse","separationToMommy","mommy","activeNipples"];if(s.AnimalKind!==g.a.SOW&&e.includes(this.state.event)){let e={title:a("tagReaderDrawer.wrongEvent"),message:a("tagReaderDrawer.wrongEventText"),status:"error",dismissible:!0,dismissAfter:5e3};this.props.dispatch(Object(l.addNotification)(e))}else this.props.history.push("/".concat(t,"/rfidEvents/").concat(this.state.event,"/").concat(Object(i.a)(this.state.rfid)))}}else if(!this.props.location.pathname.includes("rfidEvents/separationToPorkhouse")&&!this.props.location.pathname.includes("/rfidEvents/transfer")){let e={title:a("tagReaderDrawer.noAnimal"),message:y.a.t("tagReaderDrawer.noAnimalText",{number:this.state.rfid}),status:"error",dismissible:!0,dismissAfter:5e3};this.props.dispatch(Object(l.addNotification)(e))}}handleFeeding(e){const{farm:t}=this.props;let a=Object(i.a)(e),s=o.a.getAnimalByRfid(a,t);if(s)this.props.history.push("/".concat(t,"/feeding/").concat(a));else{let e=b.a.getLocationByRFID(a);e&&(e.BID?(s=o.a.getAllAnimalsForLocation(e,v.a.BOX)[0],this.props.history.push("/".concat(t,"/feeding/").concat(a))):this.props.history.push("/".concat(t,"/feedingLocation/").concat(e.BgID||e.SID||e.CID)))}this.props.dispatch(Object(c.a)({RFID:a,animal:s,type:"feeding",data:null}))}onWorktypeChange(e){this.setState({worktype:e})}render(){const{worktype:e,event:t,show:a}=this.state,{t:s}=this.props;return n.a.createElement(u.a,{name:s("tagReaderDrawer.rfidReader"),show:a,onMouseLeave:this.onDrawerMouseLeave,onMouseEnter:this.onDrawerMouseEnter},n.a.createElement("h6",null,s("tagReaderDrawer.worktype")),n.a.createElement("div",null,n.a.createElement(p.a,{label:s("tagReaderDrawer.documents"),checked:"documents"===e,onChange:()=>this.onWorktypeChange("documents")})),n.a.createElement("div",null,n.a.createElement(p.a,{label:s("tagReaderDrawer.feeding"),checked:"feeding"===e,onChange:()=>this.onWorktypeChange("feeding")})),n.a.createElement("div",null,n.a.createElement("div",null,n.a.createElement(p.a,{label:s("tagReaderDrawer.event"),checked:"events"===e,onChange:()=>this.onWorktypeChange("events")})),n.a.createElement("div",null,n.a.createElement(f.a,{value:t,options:[{name:s("insemination"),value:"insemination"},{name:s("usgTest"),value:"usg"},{name:s("noPregnancy"),value:"noPregnancy"},{name:s("birth"),value:"parturition"},{name:s("separationToPigletHouse"),value:"separationToPorkhouse"},{name:s("separationToMommy"),value:"separationToMommy"},{name:s("treatment"),value:"grafting"},{name:s("scheduleOfTreatment"),value:"treatment"},{name:s("allPiglets"),value:"fallPiglets"},{name:s("transfer"),value:"transfer"},{name:s("fall"),value:"fall"},{name:s("sale"),value:"sell"},{name:s("selection"),value:"selection"},{name:s("mommy"),value:"mommy"},{name:s("weighting"),value:"weighting"},{name:s("activeNipples"),value:"activeNipples"}],renderInPortal:!1,onChange:this.onEventChange,clearButton:!1,disabled:"events"!==e}))),n.a.createElement("div",null,n.a.createElement(p.a,{label:s("tagReaderDrawer.insert"),checked:"input"===e,onChange:()=>this.onWorktypeChange("input")})),n.a.createElement(h.Link,{to:"/".concat(this.props.farm,"/lastScannedRFID")},n.a.createElement(E.a,null,s("tagReaderDrawer.lastScanned"))))}}O=Object(m.connect)(e=>({farm:e.location.farm}))(O),O=Object(d.o)(O),t.a=Object(R.a)(O)},aXae:function(e,t,a){},meOw:function(e,t,a){}}]); //# sourceMappingURL=main~a0cae88c.3cc9f42a.chunk.js.map