text: (window.webpackJsonp=window.webpackJsonp||[]).push([[6],{"6ZY7":function(t,e,n){"use strict";n.r(e);var u=n("CcnG"),o=n("0bV8"),l=function(){return function(){}}();function r(t){return new o.a(t)}var i=n("y5Pl"),s=n("M+1Z"),c=n("JEFa"),a=n("pMnS"),b=n("aQxW"),d=n("NMrR"),p=n("A7o+"),m=n("cyBs"),f=n("OMr1"),h=n("Ip0R"),O=function(t){return t.CUSTOMERS_QUERY="[Customers] Query",t.CUSTOMERS_LOADED="[Customers] Fetched",t.CUSTOMERS_ADDED="[Customers] Added",t.CUSTOMERS_EDITED="[Customers] Edited",t.CUSTOMERS_DELETED="[Customers] Deleted",t.CUSTOMERS_ERROR="[Customers] Error",t}({}),y=function(){return function(){this.type=O.CUSTOMERS_QUERY}}(),j=function(){return function(t){this.payload=t,this.type=O.CUSTOMERS_LOADED}}(),E=function(){return function(t){this.payload=t,this.type=O.CUSTOMERS_ADDED}}(),A=function(){return function(t){this.payload=t,this.type=O.CUSTOMERS_EDITED}}(),S=function(){return function(t){this.payload=t,this.type=O.CUSTOMERS_DELETED}}(),C=function(){return function(t){this.payload=t,this.type=O.CUSTOMERS_ERROR}}(),g=n("yGQT"),R=Object(g.v)("customers"),v=Object(g.x)(R,(function(t){return t.customers})),D=Object(g.x)(R,(function(t){return t.isLoading})),_=(Object(g.x)(R,(function(t){return t.error})),n("67Y/")),M=n("t9fZ"),T=n("d2bA"),k=n("h9cb"),w=function(){function t(t,e,n,u){this.modalService=t,this.store=e,this.afAuth=n,this.translate=u,this.modalConfig={class:"modal-dialog-centered"},u.addLangs(["en","es"]),u.setDefaultLang("es")}return t.prototype.switchLang=function(t){this.translate.use(t)},t.prototype.ngOnInit=function(){var t=this;this.isLoading$=this.store.select(D),this.customersSub=this.store.select(v).pipe(Object(_.a)((function(e){return t.user&&!e&&t.store.dispatch(new y),e}))).subscribe((function(e){if(e&&0!==e.length){var n=Number(e[e.length-1].id);t.lastCustomerIndex=n}else t.lastCustomerIndex=0;t.customers=e}))},Object.defineProperty(t.prototype,"user",{get:function(){return this.afAuth.auth.currentUser},enumerable:!0,configurable:!0}),t.prototype.ngOnDestroy=function(){this.customersSub&&this.customersSub.unsubscribe()},t.prototype.onAddCustomer=function(){var t=this;this.modalRef=this.modalService.show(k.a,this.modalConfig),this.modalRef.content.heading="Add new customer",this.modalRef.content.customer.id=this.lastCustomerIndex+1,this.modalRef.content.customerData.pipe(Object(M.a)(1)).subscribe((function(e){t.store.dispatch(new E({customer:e}))}))},t.prototype.openEditCustomerModal=function(t){var e=this;this.modalRef=this.modalService.show(k.a,this.modalConfig),this.modalRef.content.heading="Edit customer",this.modalRef.content.customer={key:t.key,id:t.id||null,name:t.name||null,description:t.description||null},this.modalRef.content.customerData.pipe(Object(M.a)(1)).subscribe((function(t){e.store.dispatch(new A({customer:t}))}))},t.prototype.openConfirmModal=function(t){var e=this;this.modalRef=this.modalService.show(T.a,this.modalConfig),this.modalRef.content.confirmation.pipe(Object(M.a)(1)).subscribe((function(n){n&&e.store.dispatch(new S({customer:t}))}))},t.prototype.onCustomerEdit=function(t){this.openEditCustomerModal(t)},t.prototype.onCustomerDelete=function(t){this.openConfirmModal(t)},t}(),U=n("ZBkt"),I=u.ob({encapsulation:0,styles:[[""]],data:{}});function L(t){return u.Kb(0,[(t()(),u.qb(0,0,null,null,2,"div",[["class","mt-4 white"]],null,null,null,null,null)),(t()(),u.qb(1,0,null,null,1,"app-customers-list",[],null,[[null,"customerEdited"],[null,"customerDeleted"]],(function(t,e,n){var u=!0,o=t.component;return"customerEdited"===e&&(u=!1!==o.onCustomerEdit(n)&&u),"customerDeleted"===e&&(u=!1!==o.onCustomerDelete(n)&&u),u}),b.b,b.a)),u.pb(2,114688,null,0,d.a,[p.k],{customers:[0,"customers"]},{customerDeleted:"customerDeleted",customerEdited:"customerEdited"})],(function(t,e){t(e,2,0,e.component.customers)}),null)}function x(t){return u.Kb(0,[(t()(),u.qb(0,0,null,null,4,"div",[["class","d-flex justify-content-center align-items-center"],["style","margin-top: 200px"]],null,null,null,null,null)),(t()(),u.qb(1,0,null,null,3,"div",[["class","spinner-grow text-primary"],["role","status"],["style","width: 4rem; height: 4rem;"]],null,null,null,null,null)),(t()(),u.qb(2,0,null,null,2,"span",[["class","sr-only"]],null,null,null,null,null)),(t()(),u.Ib(3,null,["","..."])),u.Db(131072,p.j,[p.k,u.h])],null,(function(t,e){t(e,3,0,u.Jb(e,3,0,u.Cb(e,4).transform("Loading")))}))}function $(t){return u.Kb(0,[(t()(),u.qb(0,0,null,null,6,"div",[["class","white px-4 section-header"]],null,null,null,null,null)),(t()(),u.qb(1,0,null,null,2,"h3",[],null,null,null,null,null)),(t()(),u.Ib(2,null,["",""])),u.Db(131072,p.j,[p.k,u.h]),(t()(),u.qb(4,0,null,null,2,"p",[["class","grey-text pt-3"]],null,null,null,null,null)),(t()(),u.Ib(5,null,["",""])),u.Db(131072,p.j,[p.k,u.h]),(t()(),u.qb(7,0,null,null,10,"div",[["class","container-fluid pt-5 pb-5"]],null,null,null,null,null)),(t()(),u.qb(8,0,null,null,9,"div",[["class","pt-3 pb-5"]],null,null,null,null,null)),(t()(),u.qb(9,0,null,null,3,"button",[["color","primary"],["mdbBtn",""]],null,[[null,"click"]],(function(t,e,n){var u=!0;return"click"===e&&(u=!1!==t.component.onAddCustomer()&&u),u}),m.x,m.i)),u.pb(10,638976,null,0,f.I,[u.k,u.B],{color:[0,"color"]},null),(t()(),u.Ib(11,0,["",""])),u.Db(131072,p.j,[p.k,u.h]),(t()(),u.fb(16777216,null,null,1,null,L)),u.pb(14,16384,null,0,h.k,[u.N,u.J],{ngIf:[0,"ngIf"]},null),(t()(),u.fb(16777216,null,null,2,null,x)),u.pb(16,16384,null,0,h.k,[u.N,u.J],{ngIf:[0,"ngIf"]},null),u.Db(131072,h.b,[u.h])],(function(t,e){var n=e.component;t(e,10,0,"primary"),t(e,14,0,n.customers),t(e,16,0,u.Jb(e,16,0,u.Cb(e,17).transform(n.isLoading$)))}),(function(t,e){t(e,2,0,u.Jb(e,2,0,u.Cb(e,3).transform("TableList"))),t(e,5,0,u.Jb(e,5,0,u.Cb(e,6).transform("TableSubtitle"))),t(e,11,0,u.Jb(e,11,0,u.Cb(e,12).transform("AddClient")))}))}function q(t){return u.Kb(0,[(t()(),u.qb(0,0,null,null,1,"app-customers",[],null,null,null,$,I)),u.pb(1,245760,null,0,w,[f.E,g.n,U.a,p.k],null,null)],(function(t,e){t(e,1,0)}),null)}var J=u.mb("app-customers",w,q,{},{},[]),Y=n("gIcY"),N=n("t/Na"),Q=n("PCNd"),F=n("ZYCi"),K=function(){return function(){}}(),Z={customers:null,isLoading:!0,error:null};function P(t,e){switch(void 0===t&&(t=Z),e.type){case O.CUSTOMERS_QUERY:return Object.assign({},t,{isLoading:!0});case O.CUSTOMERS_LOADED:return Object.assign({},t,{customers:e.payload.customers,isLoading:!1});case O.CUSTOMERS_ERROR:return Object.assign({},t,{isLoading:!1,error:e.payload.error});default:return t}}var B=n("mrSG"),H=n("jYNz"),G=n("/PH2"),W=n("15JJ"),z=n("9Z1F"),X=n("F/XL"),V=n("Xd88"),tt=function(){function t(t,e,n){var u=this;this.actions$=t,this.customersService=e,this.store=n,this.query$=this.actions$.pipe(Object(H.f)(O.CUSTOMERS_QUERY),Object(G.a)(this.store.pipe(Object(g.y)(V.e))),Object(W.a)((function(t){return u.customersService.get(t[1].uid).pipe(Object(_.a)((function(t){var e=t.map((function(t){var e=t.payload.key,n=t.payload.val();return{key:e,id:n.id,name:n.name,description:n.description}}));return new j({customers:e})})),Object(z.a)((function(t){return Object(X.a)(new C({error:t}))})))}))),this.added$=this.actions$.pipe(Object(H.f)(O.CUSTOMERS_ADDED),Object(_.a)((function(t){return t.payload})),Object(G.a)(this.store.pipe(Object(g.y)(V.e))),Object(W.a)((function(t){return u.customersService.add(t[0].customer,t[1].uid)}))),this.edit$=this.actions$.pipe(Object(H.f)(O.CUSTOMERS_EDITED),Object(_.a)((function(t){return t.payload})),Object(G.a)(this.store.pipe(Object(g.y)(V.e))),Object(W.a)((function(t){return u.customersService.update(t[0].customer,t[1].uid).pipe(Object(z.a)((function(t){return Object(X.a)(new C({error:t}))})))}))),this.delete$=this.actions$.pipe(Object(H.f)(O.CUSTOMERS_DELETED),Object(_.a)((function(t){return t.payload})),Object(G.a)(this.store.pipe(Object(g.y)(V.e))),Object(W.a)((function(t){return u.customersService.delete(t[0].customer,t[1].uid)})))}return Object(B.__decorate)([Object(H.b)(),Object(B.__metadata)("design:type",Object)],t.prototype,"query$",void 0),Object(B.__decorate)([Object(H.b)({dispatch:!1}),Object(B.__metadata)("design:type",Object)],t.prototype,"added$",void 0),Object(B.__decorate)([Object(H.b)({dispatch:!1}),Object(B.__metadata)("design:type",Object)],t.prototype,"edit$",void 0),Object(B.__decorate)([Object(H.b)({dispatch:!1}),Object(B.__metadata)("design:type",Object)],t.prototype,"delete$",void 0),t}(),et=n("7dA5");n.d(e,"CustomersModuleNgFactory",(function(){return nt}));var nt=u.nb(l,[],(function(t){return u.zb([u.Ab(512,u.j,u.Y,[[8,[i.a,s.a,c.a,a.a,J,m.c,m.d,m.b]],[3,u.j],u.v]),u.Ab(4608,h.m,h.l,[u.s,[2,h.y]]),u.Ab(4608,Y.u,Y.u,[]),u.Ab(5120,p.g,r,[N.c]),u.Ab(4608,p.d,p.f,[]),u.Ab(4608,p.i,p.e,[]),u.Ab(4608,p.c,p.b,[]),u.Ab(4608,p.l,p.l,[]),u.Ab(4608,p.k,p.k,[p.l,p.g,p.d,p.i,p.c,p.m,p.o,p.n,p.a]),u.Ab(4608,f.W,f.W,[]),u.Ab(1073742336,h.c,h.c,[]),u.Ab(1073742336,f.y,f.y,[]),u.Ab(1073742336,f.x,f.x,[]),u.Ab(1073742336,f.w,f.w,[]),u.Ab(1073742336,Y.t,Y.t,[]),u.Ab(1073742336,Y.i,Y.i,[]),u.Ab(1073742336,f.j,f.j,[]),u.Ab(1073742336,f.k,f.k,[]),u.Ab(1073742336,p.h,p.h,[]),u.Ab(1073742336,Q.a,Q.a,[]),u.Ab(1073742336,F.o,F.o,[[2,F.t],[2,F.k]]),u.Ab(1073742336,K,K,[]),u.Ab(1073742336,f.bb,f.bb,[]),u.Ab(1073742336,f.mb,f.mb,[]),u.Ab(1024,g.I,(function(){return[{}]}),[]),u.Ab(1024,g.j,(function(){return[{key:"customers",reducerFactory:g.s,metaReducers:[],initialState:void 0}]}),[]),u.Ab(1024,g.J,g.P,[u.p,g.I,g.j]),u.Ab(1024,g.H,(function(){return[P]}),[]),u.Ab(1024,g.K,(function(t){return[t]}),[g.H]),u.Ab(1024,g.b,(function(t,e,n){return[g.Q(t,e,n)]}),[u.p,g.H,g.K]),u.Ab(1073873408,g.o,g.o,[g.J,g.b,g.g,g.p]),u.Ab(512,tt,tt,[H.a,et.a,g.n]),u.Ab(1024,H.k,(function(t){return[H.g(t)]}),[tt]),u.Ab(1073742336,H.d,H.d,[H.e,H.k,[2,g.p],[2,g.o]]),u.Ab(1073742336,l,l,[]),u.Ab(256,p.o,void 0,[]),u.Ab(256,p.m,void 0,[]),u.Ab(256,p.n,void 0,[]),u.Ab(256,p.a,void 0,[]),u.Ab(1024,F.i,(function(){return[[{path:"",component:w}]]}),[])])}))}}]);