(this["webpackJsonpmy-app"]=this["webpackJsonpmy-app"]||[]).push([[0],{134:function(e,t,a){"use strict";a.r(t);var n=a(0),i=a.n(n),r=a(12),o=a.n(r),s=(a(56),a(15)),c=a(16),l=a(18),u=a(17),d=a(21),f=a.n(d),m={endpointUrl:"https://dsvstfuf73.execute-api.ap-southeast-1.amazonaws.com/dev/",tagLabel:"Vehicle No"};m.token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wYW55SWQiOiJLVEMtTGl2ZS1JbWFnZXMifQ.bUJPfW2tVeR5XptHUMfSbCAr6c8uNhWlif4T-W7qxV0";var p=m,g=function(e){Object(l.a)(a,e);var t=Object(u.a)(a);function a(){return Object(s.a)(this,a),t.apply(this,arguments)}return Object(c.a)(a,[{key:"render",value:function(){return i.a.createElement("div",{style:{width:"100%",display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column",textAlign:"center",marginTop:100}},i.a.createElement("img",{src:"./assets/forbidden.png",alt:"outlet",width:"100",style:{objectFit:"cover"}}),"Could not find token.",i.a.createElement("br",null),"Please re-access this page by including token as a parameter")}}]),a}(i.a.Component),h=a(8),b=a.n(h),y=a(11),x=a(19),w=a(147),v=a(148),C=a(149),k=a(150),E=a(151),S=a(152),T=a(153),O=a(154),B=a(27),L=a(40),j=a(43),I=a.n(j),U=a(26),R=a.n(U),V=a(46),D=a.n(V),F=a(44),W=a.n(F);a(112);function A(e,t,a,n){return z.apply(this,arguments)}function z(){return(z=Object(y.a)(b.a.mark((function e(t,a,n,i){var r,o;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,i="Bearer ".concat(i),o={method:t,headers:{Authorization:i}},"GET"!==t&&(o.body=n),e.next=6,fetch(a,o).then(function(){var e=Object(y.a)(b.a.mark((function e(t){return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:r=e.sent;case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch(function(){var e=Object(y.a)(b.a.mark((function e(t){return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw t;case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}());case 6:return e.abrupt("return",200===r.resultCode?r:{status:"FAILED",resultCode:r.resultCode});case 9:return e.prev=9,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",{status:"FAILED",resultCode:500});case 13:case"end":return e.stop()}}),e,null,[[0,9]])})))).apply(this,arguments)}var J=a(129);function M(e){return i.a.createElement(B.a,Object.assign({},e,{size:"sm",centered:!0}),i.a.createElement(B.a.Body,{style:{height:100}},i.a.createElement("div",null,i.a.createElement(L.CircleToBlockLoading,null))))}var q=function(e){Object(l.a)(a,e);var t=Object(u.a)(a);function a(e){var n;return Object(s.a)(this,a),(n=t.call(this,e)).componentDidMount=Object(y.a)(b.a.mark((function e(){return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n.setState({isLoading:!0}),e.next=3,n.getData();case 3:n.setState({isLoading:!1});case 4:case"end":return e.stop()}}),e)}))),n.getData=Object(y.a)(b.a.mark((function e(){var t,a,i;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=sessionStorage.getItem("token"),a=sessionStorage.getItem("tagLabel"),"undefined"===typeof(i=sessionStorage.getItem("tagValue"))||"undefined"===i?i="":(sessionStorage.setItem("lastTagValue",i),n.setState({ViewTag:!1,screenUpload:!1})),e.next=4,n.getListTag(t);case 4:return e.next=6,n.searchByTag(i,t);case 6:n.setState({token:t,tag:sessionStorage.getItem("lastTagValue"),tagLabel:a});case 7:case"end":return e.stop()}}),e)}))),n.sortBy=function(e){return function(t,a){return t[e]>a[e]?-1:t[e]1&&void 0!==c[1]&&c[1],a=[],i=[],r=p.endpointUrl+"list",e.next=6,A("GET",r,{},t);case 6:200===(o=e.sent).resultCode?(a=[],o.data.sort(n.sortBy("latestData")),i=o.data,o.data.forEach((function(e){e.modifiedOn=R()().diff(e.modifiedOn,"days")})),a.push({text:"Today",data:o.data.filter((function(e){return 0===e.modifiedOn}))}),a.push({text:"This Week",data:o.data.filter((function(e){return e.modifiedOn>0&&e.modifiedOn<=7}))}),a.push({text:"Older",data:o.data.filter((function(e){return e.modifiedOn>7}))})):(s=400===o.resultCode?"Bad Request":"Failed to fetch api, cek your token",J.fire({text:s,icon:"error",showCancelButton:!1,confirmButtonColor:"#3085d6",confirmButtonText:"Ok"})),n.setState({pictTag:a,pictTagMaster:i});case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),n.handleS3Upload=Object(y.a)(b.a.mark((function e(){var t,a,i,r;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(""===n.state.tag){e.next=12;break}return n.setState({isLoading:!0}),t="https://dsvstfuf73.execute-api.ap-southeast-1.amazonaws.com/dev/upload/"+n.state.tag,(a=new FormData).append("image",n.state.pictures[0]),e.next=7,A("POST",t,a,n.state.token);case 7:200===(i=e.sent).resultCode?(n.state.pictThumb[0].data.unshift(i.data),n.getListTag(n.state.token),J.fire({title:"SUCCESS",text:"Image has been successfully uploaded",icon:"success",showCancelButton:!1,confirmButtonColor:"#3085d6",confirmButtonText:"Ok"}).then((function(e){e.value&&window.location.reload()}))):(r=400===i.resultCode?"Bad Request":"Failed to fetch api, cek your token",J.fire({title:"Failed to upload image",text:r,icon:"error",showCancelButton:!1,confirmButtonColor:"#3085d6",confirmButtonText:"Ok"})),n.setState({pictThumb:n.state.pictThumb,isLoading:!1,isChosen:!1}),e.next=13;break;case 12:J.fire({title:"FAILED",text:"Tag is empty",icon:"error",showCancelButton:!1,confirmButtonColor:"#3085d6",confirmButtonText:"Ok"});case 13:case"end":return e.stop()}}),e)}))),n.onDrop=function(){var e=Object(y.a)(b.a.mark((function e(t,a){return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:0===t.length?n.setState({pictures:t,isChosen:!1}):(n.setState({isLoading:!0}),new FileReader,W.a.imageFileResizer(t[0],1e3,1e3,"JPEG",96,0,(function(e){for(var a=e.split(";base64,")[0].split(":")[1],i=atob(e.split(";base64,")[1]),r=new Uint8Array(new ArrayBuffer(i.length)),o=0;o=0&&n.state.pictThumb[t].data.splice(s,1),-1!==(s=n.state.imageSelected.indexOf(e.fileURL))&&n.state.imageSelected.splice(s,1),J.fire({title:"SUCCESS",text:"Image has been successfully deleted",icon:"success",showCancelButton:!1,confirmButtonColor:"#3085d6",confirmButtonText:"Ok"})):(c=400===o.resultCode?"Bad Request":"Failed to fetch api, cek your token",J.fire({title:"Failed to delete image",text:c,icon:"error",showCancelButton:!1,confirmButtonColor:"#3085d6",confirmButtonText:"Ok"})),n.setState({pictThumb:n.state.pictThumb,isLoading:!1,imageSelected:n.state.imageSelected});case 8:case"end":return a.stop()}}),a)})));return function(e){return a.apply(this,arguments)}}())},n.ViewEmpty=function(){return i.a.createElement("div",{style:{width:"100%",display:"flex",justifyContent:"center",alignItems:"center",paddingTop:10}},i.a.createElement("img",{src:"./assets/emptyState.png",alt:"outlet",style:{objectFit:"cover"}}))},n.handleBack=function(){n.setState({ViewTag:!0})},n.ViewScreen=function(){return i.a.createElement(w.a,null,n.state.pictThumb?n.state.pictThumb.length<1||n.state.pictThumb[0].data.length<1&&n.state.pictThumb[1].data.length<1&&n.state.pictThumb[2].data.length<1?n.ViewEmpty():n.state.pictThumb.map((function(e,t){return e.data.length<1?null:i.a.createElement(v.a,{sm:"12",xs:"12",key:t},i.a.createElement("div",{style:{marginBottom:10,marginTop:10}},e.data.length>0?e.text+" Uploads":""),i.a.createElement(w.a,null,e.data.map((function(e,a){return i.a.createElement(v.a,{sm:"auto",xs:"12",key:a},i.a.createElement("div",{style:{marginBottom:20,height:150,border:"1px solid #c8ced3",cursor:"pointer",width:"100%",display:"flex",justifyContent:"center",boxShadow:n.state.imageSelected.includes(e.fileURL)?"0px 0px 10px #8f9ba6":null},onClick:function(){return n.selectImage(e.fileURL)}},n.state.imageSelected.includes(e.fileURL)?i.a.createElement(D.a,{style:{position:"absolute",color:"#dc3545",fontSize:"50",right:-10,top:-25,cursor:"pointer"},onClick:function(){return n.handleDelete(e,t)}}):null,i.a.createElement("img",{src:e.fileURL,alt:"outlet",height:"100%",style:{objectFit:"contain"}})))}))))})):null)},n.openViewScreen=function(e){n.searchByTag(e=e.path),n.setState({ViewTag:!1,tag:e}),sessionStorage.setItem("lastTagValue",e)},n.ViewTag=function(){return i.a.createElement("div",null,i.a.createElement(w.a,null,n.state.pictTag?n.state.pictTag.length<1?n.ViewEmpty():n.state.pictTag.map((function(e,t){return i.a.createElement(v.a,{sm:"12",xs:"12",key:t},i.a.createElement("div",{style:{marginBottom:10,marginTop:10}},e.data.length>0?e.text+" Uploads":""),i.a.createElement(w.a,null,e.data.map((function(e,t){return i.a.createElement(v.a,{sm:"4",xs:"12",key:t},i.a.createElement(C.a,{style:{marginBottom:10,cursor:"pointer"},onClick:function(){return n.openViewScreen(e)}},i.a.createElement(k.a,null,i.a.createElement("div",{style:{display:"flex",flexDirection:"row",alignItems:"center"}},i.a.createElement("div",{style:{width:"100%"}},e.path),i.a.createElement("div",{style:{textAlign:"center",color:"#5c6873",marginRight:"5%",display:"flex",flexDirection:"column",justifyContent:"center"}},i.a.createElement("div",null,e.numberOfFiles),i.a.createElement("div",{style:{fontSize:10}},"images"))))))}))))})):null))},n.formTag=function(){return i.a.createElement(E.a,{style:{display:"flex",flexDirection:"column",width:"100%"}},i.a.createElement(w.a,null,i.a.createElement(S.a,{sm:"2",xs:"12",htmlFor:"tag"},n.state.tagLabel,":"),i.a.createElement(v.a,{sm:"4",xs:"12"},i.a.createElement(T.a,{style:{borderRadius:10,paddingLeft:10,marginBottom:10},type:"text",id:"tag",value:n.state.tag,placeholder:"",onChange:n.handleChange})),i.a.createElement(v.a,{sm:"4",xs:"12"},i.a.createElement(O.a,{onClick:function(){return n.filterTag()},style:{borderRadius:10,color:"#ffffff",backgroundColor:"#3F4257",visibility:n.state.ViewTag&&!n.state.screenUpload?"visible":"hidden"}},"Search"))))},n.filterTag=function(){var e=[],t=n.state.pictTagMaster.filter((function(e){return e.path.toLowerCase().includes(n.state.tag.toLowerCase())}));e.push({text:"Today",data:t.filter((function(e){return 0===e.modifiedOn}))}),e.push({text:"This Week",data:t.filter((function(e){return e.modifiedOn>0&&e.modifiedOn<=7}))}),e.push({text:"Older",data:t.filter((function(e){return e.modifiedOn>7}))}),n.setState({pictTag:e})},n.searchByTag=Object(y.a)(b.a.mark((function e(){var t,a,i,r,o,s,c=arguments;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=c.length>0&&void 0!==c[0]?c[0]:n.state.tag,a=c.length>1&&void 0!==c[1]?c[1]:n.state.token,n.setState({isLoading:!0,showedScreen:null}),i=n.state.pictThumb,r=p.endpointUrl+"list/"+t,e.next=7,A("GET",r,{},a);case 7:200===(o=e.sent).resultCode?(i=[],o.data.forEach((function(e){e.createdOn=R()().diff(e.createdOn,"days")})),i.push({text:"Today",data:o.data.filter((function(e){return 0===e.createdOn}))}),i.push({text:"This Week",data:o.data.filter((function(e){return e.createdOn>0&&e.createdOn<=7}))}),i.push({text:"Older",data:o.data.filter((function(e){return e.createdOn>7}))})):(s=400===o.resultCode?"Bad Request":"Failed to fetch api, cek your token",J.fire({text:s,icon:"error",showCancelButton:!1,confirmButtonColor:"#3085d6",confirmButtonText:"Ok"})),n.setState({pictThumb:i,isLoading:!1});case 10:case"end":return e.stop()}}),e)}))),n.setSelected=function(e){n.setState({screenUpload:e})},n.setLoadingShow=function(e){n.setState({isLoading:e})},n.handleChange=function(e){n.setState({tag:e.target.value}),sessionStorage.setItem("lastTagValue",e.target.value)},n.handleChangeSelect=function(e){n.setState({filterImage:e.target.value})},n.state={isLoading:!1,screenUpload:!0,isChosen:!1,ViewTag:!0,tag:"",imageSelected:[],pictThumb:[],token:""},n.handleChange=n.handleChange.bind(Object(x.a)(n)),n.handleChangeSelect=n.handleChangeSelect.bind(Object(x.a)(n)),n.onDrop=n.onDrop.bind(Object(x.a)(n)),n}return Object(c.a)(a,[{key:"render",value:function(){var e=this;return i.a.createElement("div",null,i.a.createElement("div",{style:{marginLeft:"5%",marginRight:"5%",display:"flex",flexDirection:"column",justifyContent:"between",marginTop:10,marginBottom:20,backgroundColor:"#ffffff",padding:20,border:"1px solid #c8ced3",borderRadius:5}},i.a.createElement(M,{show:this.state.isLoading,onHide:function(){return e.setLoadingShow(!0)}}),i.a.createElement("div",{style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",padding:"0.5%",marginTop:-15}},i.a.createElement("div",{id:"buttonSelect",style:{display:"flex",flexDirection:"row",width:"100%",justifyContent:"center",alignItems:"center",backgroundColor:"#e4e7ea",padding:5,borderTopLeftRadius:5,borderTopRightRadius:5}},i.a.createElement("div",{onClick:function(){return e.setSelected(!0)},style:{border:"0px",width:"49.5%",borderRadius:5,padding:5,fontWeight:this.state.screenUpload?"bold":null,justifyContent:"center",backgroundColor:this.state.screenUpload?"#acb4bc":"#e4e7ea",display:"flex",alignItems:"center",cursor:"pointer"}},"Upload"),i.a.createElement("div",{style:{width:"1%"}}),i.a.createElement("div",{onClick:function(){return e.setSelected(!1)},style:{border:"0px",width:"49.5%",borderRadius:5,padding:5,fontWeight:this.state.screenUpload?null:"bold",justifyContent:"center",backgroundColor:this.state.screenUpload?"#e4e7ea":"#acb4bc",display:"flex",alignItems:"center",cursor:"pointer"}},"View"))),i.a.createElement(w.a,{style:{padding:10,paddingTop:"-3%",borderBottomLeftRadius:10,borderBottomRightRadius:10,marginLeft:"0.5%",marginRight:"0.5%"}},i.a.createElement(v.a,{sm:"12",xs:"12"},this.state.ViewTag||this.state.screenUpload?null:i.a.createElement(O.a,{onClick:function(){return e.handleBack()},style:{borderRadius:10,color:"#ffffff",backgroundColor:"#3F4257"}},"Back"),this.formTag()),i.a.createElement(v.a,{sm:"12",xs:"12"},this.state.screenUpload?this.UploadScreen():this.state.ViewTag?this.ViewTag():this.ViewScreen()))))}}]),a}(i.a.Component),G=function(e){Object(l.a)(a,e);var t=Object(u.a)(a);function a(e){var n;return Object(s.a)(this,a),(n=t.call(this,e)).componentDidMount=function(){var e=window.location.search,t=f.a.parse(e),a=Object.keys(t)[0];"undefined"===typeof a&&(a="Vechicle No"),t.token=p.token,n.setState({tag:t[a],token:t.token}),sessionStorage.setItem("tagLabel",p.tagLabel),sessionStorage.setItem("tagValue",t.tag),sessionStorage.setItem("token",t.token)},n.state={},n}return Object(c.a)(a,[{key:"render",value:function(){return i.a.createElement("div",{style:{backgroundColor:"#e4e7ea",minHeight:"100vh"}},i.a.createElement("div",{style:{height:65,backgroundColor:"#c8ced3"}}),i.a.createElement("div",null,this.state.token?i.a.createElement(q,null):i.a.createElement(g,null)),i.a.createElement("div",{style:{height:1,backgroundColor:"#c8ced3",width:"100%",position:"fixed",bottom:45}}),i.a.createElement("div",{style:{backgroundColor:"#ffffff",padding:10,width:"100%",textAlign:"right",color:"#5c6873",position:"fixed",bottom:0}},i.a.createElement("span",{className:"ml-auto"},"Version ","1.2.4"," || Powered by ",i.a.createElement("a",{href:"https://www.edgeworks.com.sg/"},"Edgeworks Solution"))),i.a.createElement("div",{style:{height:65,backgroundColor:"#c8ced3",position:"fixed",width:"100%",top:0}}),i.a.createElement("div",{style:{backgroundColor:"#ffffff",padding:20,width:"100%",fontWeight:"bold",color:"#5c6873",position:"fixed",top:0}},"Equip Drive KTC"))}}]),a}(i.a.Component);Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));a(132);o.a.render(i.a.createElement(i.a.StrictMode,null,i.a.createElement(G,null)),document.getElementById("root")),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then((function(e){e.unregister()})).catch((function(e){console.error(e.message)}))},51:function(e,t,a){e.exports=a(134)},56:function(e,t,a){}},[[51,1,2]]]);