text: (window.webpackJsonp=window.webpackJsonp||[]).push([[5],{TDBs:function(t,e,n){"use strict";n.r(e),n.d(e,"DashboardModule",function(){return lt});var r=n("ofXK"),i=n("hctd"),a=n("3Pt+"),s=n("tyNb"),c=n("fXoL");let o=(()=>{class t{}return t.\u0275mod=c.Lb({type:t}),t.\u0275inj=c.Kb({factory:function(e){return new(e||t)},imports:[[r.c,i.a,a.q,a.h,s.f]]}),t})(),b=(()=>{class t{}return t.\u0275mod=c.Lb({type:t}),t.\u0275inj=c.Kb({factory:function(e){return new(e||t)},imports:[[r.c,i.a,a.q,s.f]]}),t})(),m=(()=>{class t{}return t.\u0275mod=c.Lb({type:t}),t.\u0275inj=c.Kb({factory:function(e){return new(e||t)},imports:[[r.c,i.a,s.f]]}),t})();var l=n("pLZG"),d=n("v8Ou"),p=n("l7P3"),u=n("lJxs"),f=n("I/3d");let h=(()=>{class t{constructor(t){this.firestore=t}createDepartment(t){return delete t.id,this.firestore.firestore.collection("departments").add(Object.assign({},t))}modifyDepartment(t){const e=t.id;return delete t.id,this.firestore.firestore.doc("departments/"+e).set(Object.assign({},t))}initDepartmentsListener(){return this.firestore.collection("departments").snapshotChanges().pipe(Object(u.a)(t=>t.map(t=>Object.assign({id:t.payload.doc.id},t.payload.doc.data()))))}deleteDepartment(t){return this.firestore.doc("departments/"+t).delete()}}return t.\u0275fac=function(e){return new(e||t)(c.Xb(f.a))},t.\u0275prov=c.Jb({token:t,factory:t.\u0275fac,providedIn:"root"}),t})(),g=(()=>{class t{constructor(t){this.firestore=t}createEmployee(t){return delete t.id,this.firestore.firestore.collection("staff").add(Object.assign({},t))}modifyEmployee(t){const e=t.id;return delete t.id,this.firestore.firestore.doc("staff/"+e).set(Object.assign({},t))}initstaffListener(){return this.firestore.collection("staff").snapshotChanges().pipe(Object(u.a)(t=>t.map(t=>Object.assign({id:t.payload.doc.id},t.payload.doc.data()))))}deleteEmployee(t){return this.firestore.doc("staff/"+t).delete()}}return t.\u0275fac=function(e){return new(e||t)(c.Xb(f.a))},t.\u0275prov=c.Jb({token:t,factory:t.\u0275fac,providedIn:"root"}),t})();var S=n("lGQG"),T=n("/t3+"),y=n("bTqV"),v=n("STbY"),A=n("MutI"),O=n("NFeN"),C=n("FKr1");let w=(()=>{class t{constructor(t,e,n){this.store=t,this.AuthService=e,this.router=n}logOut(){this.AuthService.logOut().then(()=>{this.router.navigate(["/login"])})}ngOnInit(){this.userSubscription=this.store.select("user").pipe(Object(l.a)(({user:t})=>null!==t)).subscribe(({user:t})=>{this.username=t.name})}ngOnDestroy(){this.userSubscription.unsubscribe()}}return t.\u0275fac=function(e){return new(e||t)(c.Nb(p.h),c.Nb(S.a),c.Nb(s.b))},t.\u0275cmp=c.Hb({type:t,selectors:[["app-toolbar"]],decls:21,vars:2,consts:[["color","primary",1,"w-100","mat-elevation-z3"],["mat-button",""],["src","favicon.ico"],[1,"spacer"],["src","assets/images/avatar.png","alt","profile image","height","40","width","40",1,"pointer","br-50",3,"matMenuTriggerFor"],["menu","matMenu"],[1,"flex-box","flex-column","w-100","text-center","p-2"],["src","assets/images/avatar.png","alt","profile image","height","40","width","40",1,"pointer","br-50"],[1,"text-capitalize"],[3,"click"],["matListIcon",""],["matLine",""]],template:function(t,e){if(1&t&&(c.Tb(0,"mat-toolbar",0),c.Tb(1,"mat-toolbar-row"),c.Tb(2,"button",1),c.Ob(3,"img",2),c.Ac(4," COMPANY "),c.Sb(),c.Ob(5,"span",3),c.Ob(6,"img",4),c.Tb(7,"mat-menu",null,5),c.Tb(9,"div",6),c.Ob(10,"br"),c.Ob(11,"img",7),c.Ob(12,"br"),c.Tb(13,"h3",8),c.Ac(14),c.Sb(),c.Tb(15,"mat-action-list"),c.Tb(16,"mat-list-item",9),c.ac("click",function(){return e.logOut()}),c.Tb(17,"mat-icon",10),c.Ac(18,"exit_to_app"),c.Sb(),c.Tb(19,"h3",11),c.Ac(20," Logout "),c.Sb(),c.Sb(),c.Sb(),c.Sb(),c.Sb(),c.Sb(),c.Sb()),2&t){const t=c.oc(8);c.Cb(6),c.jc("matMenuTriggerFor",t),c.Cb(8),c.Bc(e.username)}},directives:[T.a,T.c,y.a,v.d,v.a,A.a,A.c,O.a,A.b,C.j],styles:[""]}),t})(),x=(()=>{class t{constructor(t,e,n){this.store=t,this.departmentsService=e,this.staffService=n}ngOnInit(){this.userSubscription=this.store.select("user").pipe(Object(l.a)(t=>null!==t.user)).subscribe(({})=>{this.departmentsSubscription=this.departmentsService.initDepartmentsListener().subscribe(t=>{this.store.dispatch(d.b({departments:t}))}),this.staffSubscription=this.staffService.initstaffListener().subscribe(t=>{this.store.dispatch(d.c({staff:t}))})})}ngOnDestroy(){var t,e,n;null===(t=this.userSubscription)||void 0===t||t.unsubscribe(),null===(e=this.departmentsSubscription)||void 0===e||e.unsubscribe(),null===(n=this.staffSubscription)||void 0===n||n.unsubscribe()}}return t.\u0275fac=function(e){return new(e||t)(c.Nb(p.h),c.Nb(h),c.Nb(g))},t.\u0275cmp=c.Hb({type:t,selectors:[["app-dashboard"]],decls:2,vars:0,template:function(t,e){1&t&&(c.Ob(0,"app-toolbar"),c.Ob(1,"router-outlet"))},directives:[w,s.g],styles:[""]}),t})();var j=n("PSD3"),D=n.n(j);class N{constructor(t,e,n,r,i,a){this.name=t,this.last_name=e,this.age=n,this.department=r,this.date_discharge=i,this.id=a}}var I=n("Wp6s"),k=n("kmnG"),F=n("qFsG"),_=n("d3UM");function M(t,e){if(1&t&&(c.Tb(0,"mat-option",18),c.Ac(1),c.Sb()),2&t){const t=e.$implicit;c.jc("value",t.id),c.Cb(1),c.Bc(t.name)}}function E(t,e){if(1&t&&(c.Tb(0,"mat-form-field",5),c.Tb(1,"mat-label"),c.Ac(2,"Department"),c.Sb(),c.Tb(3,"mat-select",16),c.yc(4,M,2,2,"mat-option",17),c.Sb(),c.Sb()),2&t){const t=c.ec();c.Cb(4),c.jc("ngForOf",t.departments)}}function L(t,e){1&t&&(c.Tb(0,"p",19),c.Ac(1,"There is no departments. Please, create a new one."),c.Sb())}function q(t,e){1&t&&(c.Tb(0,"span"),c.Ac(1,"Loading..."),c.Sb())}function B(t,e){1&t&&(c.Tb(0,"span"),c.Ac(1,"Modify"),c.Sb())}function G(t,e){1&t&&(c.Tb(0,"span"),c.Ac(1,"Add"),c.Sb())}const H=function(){return["/"]};let K=(()=>{class t{constructor(t,e,n,r,i){this.fb=t,this.staffService=e,this.store=n,this.router=r,this.route=i,this.loading=!1,this.departments=[]}save(){if(this.employeeForm.invalid)return;const{name:t,last_name:e,age:n,department:r}=this.employeeForm.value,i=new Date;let a;this.store.dispatch(d.a()),this.id?(a=new N(t,e,n,r,i,this.id),this.staffService.modifyEmployee(a).then(()=>{D.a.fire("Employee modified",a.name+" "+a.last_name,"success"),this.store.dispatch(d.e()),this.employeeForm.reset(),this.router.navigate(["/"])}).catch(t=>{this.store.dispatch(d.e()),D.a.fire("Error",t,"error")})):(a=new N(t,e,n,r,i),this.staffService.createEmployee(a).then(()=>{D.a.fire("Employee created",a.name+" "+a.last_name,"success"),this.store.dispatch(d.e()),this.employeeForm.reset(),this.router.navigate(["/"])}).catch(t=>{this.store.dispatch(d.e()),D.a.fire("Error",t,"error")}))}ngOnInit(){this.loadingSubscription=this.store.select("ui").subscribe(({isLoading:t})=>this.loading=t),this.departmentsSubscription=this.store.select("departments").subscribe(({departments:t})=>this.departments=t),this.employeeForm=this.fb.group({name:["",a.s.required],last_name:["",a.s.required],age:[null,a.s.required],department:["",a.s.required]}),this.activeRoutingSubscription=this.route.params.subscribe(t=>{this.id=t.id,this.staffSubscription=this.store.select("staff").subscribe(({staff:t})=>t.map(t=>{t.id===this.id&&this.employeeForm.setValue({name:t.name,last_name:t.last_name,age:t.age,department:t.department})}))})}ngOnDestroy(){this.loadingSubscription.unsubscribe(),this.departmentsSubscription.unsubscribe(),this.activeRoutingSubscription.unsubscribe(),this.staffSubscription.unsubscribe()}}return t.\u0275fac=function(e){return new(e||t)(c.Nb(a.d),c.Nb(g),c.Nb(p.h),c.Nb(s.b),c.Nb(s.a))},t.\u0275cmp=c.Hb({type:t,selectors:[["app-staff-form"]],decls:36,vars:9,consts:[[1,"container","flex-box","h-75"],[1,"margin-auto","col-sm-12","col-xs-12","col-md-6","col-lg-4","col-xl-4"],[3,"formGroup","ngSubmit"],["mat-card-avatar",""],[1,"flex-box","flex-column"],["appearance","fill"],["matInput","","type","text","placeholder","Write the name","formControlName","name"],["matInput","","type","text","placeholder","Write the last name","formControlName","last_name"],["matInput","","type","number","placeholder","Write the age","formControlName","age"],["appearance","fill",4,"ngIf","ngIfElse"],["ngNoDepartmentsTemplate",""],[1,"flex-box","flex-row"],["mat-button","","routerLinkActive","router-link-active",3,"routerLink"],[1,"spacer"],["mat-raised-button","","type","submit",3,"disabled"],[4,"ngIf"],["formControlName","department"],[3,"value",4,"ngFor","ngForOf"],[3,"value"],[1,"text-center"]],template:function(t,e){if(1&t&&(c.Tb(0,"div",0),c.Tb(1,"div",1),c.Tb(2,"form",2),c.ac("ngSubmit",function(){return e.save()}),c.Tb(3,"mat-card"),c.Tb(4,"mat-card-header"),c.Tb(5,"div",3),c.Tb(6,"mat-icon"),c.Ac(7,"person"),c.Sb(),c.Sb(),c.Tb(8,"mat-card-title"),c.Ac(9,"New employee"),c.Sb(),c.Tb(10,"mat-card-subtitle"),c.Ac(11,"Define the name, last name, age and department"),c.Sb(),c.Sb(),c.Tb(12,"mat-card-content",4),c.Tb(13,"mat-form-field",5),c.Tb(14,"mat-label"),c.Ac(15,"Name"),c.Sb(),c.Ob(16,"input",6),c.Sb(),c.Tb(17,"mat-form-field",5),c.Tb(18,"mat-label"),c.Ac(19,"last name"),c.Sb(),c.Ob(20,"input",7),c.Sb(),c.Tb(21,"mat-form-field",5),c.Tb(22,"mat-label"),c.Ac(23,"Age"),c.Sb(),c.Ob(24,"input",8),c.Sb(),c.yc(25,E,5,1,"mat-form-field",9),c.yc(26,L,2,0,"ng-template",null,10,c.zc),c.Sb(),c.Tb(28,"mat-card-actions",11),c.Tb(29,"button",12),c.Ac(30,"Cancel"),c.Sb(),c.Ob(31,"span",13),c.Tb(32,"button",14),c.yc(33,q,2,0,"span",15),c.yc(34,B,2,0,"span",15),c.yc(35,G,2,0,"span",15),c.Sb(),c.Sb(),c.Sb(),c.Sb(),c.Sb(),c.Sb()),2&t){const t=c.oc(27);c.Cb(2),c.jc("formGroup",e.employeeForm),c.Cb(23),c.jc("ngIf",e.departments.length>0)("ngIfElse",t),c.Cb(4),c.jc("routerLink",c.kc(8,H)),c.Cb(3),c.jc("disabled",e.employeeForm.invalid),c.Cb(1),c.jc("ngIf",e.loading),c.Cb(1),c.jc("ngIf",e.id&&!e.loading),c.Cb(1),c.jc("ngIf",!e.id&&!e.loading)}},directives:[a.t,a.m,a.g,I.a,I.e,I.c,O.a,I.h,I.g,I.d,k.c,k.f,F.b,a.c,a.l,a.f,a.p,r.l,I.b,y.a,s.d,s.c,_.a,r.k,C.m],styles:[""]}),t})();class J{constructor(t,e){this.name=t,this.id=e}}function P(t,e){1&t&&(c.Tb(0,"span"),c.Ac(1,"Loading..."),c.Sb())}function W(t,e){1&t&&(c.Tb(0,"span"),c.Ac(1,"Modify"),c.Sb())}function $(t,e){1&t&&(c.Tb(0,"span"),c.Ac(1,"Add"),c.Sb())}const R=function(){return["/"]};let U=(()=>{class t{constructor(t,e,n,r,i){this.fb=t,this.departmentsService=e,this.store=n,this.router=r,this.route=i,this.loading=!1}save(){if(this.departmentForm.invalid)return;const{name:t}=this.departmentForm.value;let e;this.store.dispatch(d.a()),this.id?(e=new J(t,this.id),this.departmentsService.modifyDepartment(e).then(()=>{D.a.fire("Department modified",e.name,"success"),this.store.dispatch(d.e()),this.departmentForm.reset(),this.router.navigate(["/"])}).catch(t=>{this.store.dispatch(d.e()),D.a.fire("Error",t,"error")})):(e=new J(t),this.departmentsService.createDepartment(e).then(()=>{D.a.fire("Department created",e.name,"success"),this.store.dispatch(d.e()),this.departmentForm.reset(),this.router.navigate(["/"])}).catch(t=>{this.store.dispatch(d.e()),D.a.fire("Error",t,"error")}))}ngOnInit(){this.loadingSubscription=this.store.select("ui").subscribe(({isLoading:t})=>this.loading=t),this.departmentForm=this.fb.group({name:["",a.s.required]}),this.activeRoutingSubscription=this.route.params.subscribe(t=>{this.id=t.id,this.departmentsSubscription=this.store.select("departments").subscribe(({departments:t})=>t.map(t=>{t.id===this.id&&this.departmentForm.setValue({name:t.name})}))})}ngOnDestroy(){this.loadingSubscription.unsubscribe(),this.departmentsSubscription.unsubscribe(),this.activeRoutingSubscription.unsubscribe()}}return t.\u0275fac=function(e){return new(e||t)(c.Nb(a.d),c.Nb(h),c.Nb(p.h),c.Nb(s.b),c.Nb(s.a))},t.\u0275cmp=c.Hb({type:t,selectors:[["app-departments-form"]],decls:25,vars:7,consts:[[1,"container","flex-box","h-75"],[1,"margin-auto","col-sm-12","col-xs-12","col-md-6","col-lg-4","col-xl-4"],[3,"formGroup","ngSubmit"],["mat-card-avatar",""],[1,"flex-box","flex-column"],["appearance","fill"],["matInput","","type","text","placeholder","Write the name","formControlName","name"],[1,"flex-box","flex-row"],["mat-button","","routerLinkActive","router-link-active",3,"routerLink"],[1,"spacer"],["mat-raised-button","","type","submit",3,"disabled"],[4,"ngIf"]],template:function(t,e){1&t&&(c.Tb(0,"div",0),c.Tb(1,"div",1),c.Tb(2,"form",2),c.ac("ngSubmit",function(){return e.save()}),c.Tb(3,"mat-card"),c.Tb(4,"mat-card-header"),c.Tb(5,"div",3),c.Tb(6,"mat-icon"),c.Ac(7,"people"),c.Sb(),c.Sb(),c.Tb(8,"mat-card-title"),c.Ac(9,"New department"),c.Sb(),c.Tb(10,"mat-card-subtitle"),c.Ac(11,"Define the name"),c.Sb(),c.Sb(),c.Tb(12,"mat-card-content",4),c.Tb(13,"mat-form-field",5),c.Tb(14,"mat-label"),c.Ac(15,"Name"),c.Sb(),c.Ob(16,"input",6),c.Sb(),c.Sb(),c.Tb(17,"mat-card-actions",7),c.Tb(18,"button",8),c.Ac(19,"Cancel"),c.Sb(),c.Ob(20,"span",9),c.Tb(21,"button",10),c.yc(22,P,2,0,"span",11),c.yc(23,W,2,0,"span",11),c.yc(24,$,2,0,"span",11),c.Sb(),c.Sb(),c.Sb(),c.Sb(),c.Sb(),c.Sb()),2&t&&(c.Cb(2),c.jc("formGroup",e.departmentForm),c.Cb(16),c.jc("routerLink",c.kc(6,R)),c.Cb(3),c.jc("disabled",e.departmentForm.invalid),c.Cb(1),c.jc("ngIf",e.loading),c.Cb(1),c.jc("ngIf",e.id&&!e.loading),c.Cb(1),c.jc("ngIf",!e.id&&!e.loading))},directives:[a.t,a.m,a.g,I.a,I.e,I.c,O.a,I.h,I.g,I.d,k.c,k.f,F.b,a.c,a.l,a.f,I.b,y.a,s.d,s.c,r.l],styles:[""]}),t})(),X=(()=>{class t{constructor(t,e){this.departmentsService=t,this.router=e}editDepartment(t){this.router.navigate(["edit-department",t.id])}deleteDepartment(t){const e=this;D.a.fire({title:"Are you sure?",text:"You will not be able to recover it!",icon:"warning",showDenyButton:!0,denyButtonText:"No please",confirmButtonText:"Sure"}).then(function(n){n.isConfirmed&&e.departmentsService.deleteDepartment(t.id).then(()=>{D.a.fire("Deleted","Department deleted","success")}).catch(t=>{D.a.fire("Error",t.message,"error")})})}ngOnInit(){}}return t.\u0275fac=function(e){return new(e||t)(c.Nb(h),c.Nb(s.b))},t.\u0275cmp=c.Hb({type:t,selectors:[["app-departments-child"]],inputs:{department:"department"},decls:19,vars:2,consts:[["role","listitem"],[1,"pl-05"],[1,"spacer"],["mat-icon-button","",3,"matMenuTriggerFor"],["menu","matMenu"],["mat-menu-item","",3,"click"]],template:function(t,e){if(1&t&&(c.Tb(0,"mat-list-item",0),c.Tb(1,"mat-icon"),c.Ac(2,"people"),c.Sb(),c.Tb(3,"span",1),c.Ac(4),c.Sb(),c.Ob(5,"span",2),c.Tb(6,"button",3),c.Tb(7,"mat-icon"),c.Ac(8,"more_vert"),c.Sb(),c.Sb(),c.Tb(9,"mat-menu",null,4),c.Tb(11,"button",5),c.ac("click",function(){return e.editDepartment(e.department)}),c.Tb(12,"mat-icon"),c.Ac(13,"edit"),c.Sb(),c.Ac(14,"Edit"),c.Sb(),c.Tb(15,"button",5),c.ac("click",function(){return e.deleteDepartment(e.department)}),c.Tb(16,"mat-icon"),c.Ac(17,"delete"),c.Sb(),c.Ac(18,"Delete"),c.Sb(),c.Sb(),c.Sb()),2&t){const t=c.oc(10);c.Cb(4),c.Bc(e.department.name),c.Cb(2),c.jc("matMenuTriggerFor",t)}},directives:[A.c,O.a,y.a,v.d,v.a,v.b],styles:[""]}),t})();function Y(t,e){1&t&&(c.Tb(0,"mat-list-item",6),c.Ac(1," No department "),c.Sb())}function z(t,e){1&t&&c.Ob(0,"app-departments-child",7),2&t&&c.jc("department",e.$implicit)}let V=(()=>{class t{constructor(t,e){this.store=t,this.router=e,this.departments=[]}ngOnInit(){this.departmentsSubscription=this.store.select("departments").subscribe(({departments:t})=>this.departments=t)}addDepartment(){this.router.navigate(["new-department"])}ngOnDestroy(){this.departmentsSubscription.unsubscribe()}}return t.\u0275fac=function(e){return new(e||t)(c.Nb(p.h),c.Nb(s.b))},t.\u0275cmp=c.Hb({type:t,selectors:[["app-departments-list"]],decls:9,vars:2,consts:[["role","list"],["mat-subheader","",1,"flex-box"],[1,"spacer"],["mat-icon-button","",3,"click"],["role","listitem",4,"ngIf"],[3,"department",4,"ngFor","ngForOf"],["role","listitem"],[3,"department"]],template:function(t,e){1&t&&(c.Tb(0,"mat-list",0),c.Tb(1,"div",1),c.Ac(2," Departments "),c.Ob(3,"span",2),c.Tb(4,"button",3),c.ac("click",function(){return e.addDepartment()}),c.Tb(5,"mat-icon"),c.Ac(6,"add"),c.Sb(),c.Sb(),c.Sb(),c.yc(7,Y,2,0,"mat-list-item",4),c.yc(8,z,1,1,"app-departments-child",5),c.Sb()),2&t&&(c.Cb(7),c.jc("ngIf",0===e.departments.length),c.Cb(1),c.jc("ngForOf",e.departments))},directives:[A.a,A.e,y.a,O.a,r.l,r.k,A.c,X],styles:[""]}),t})();var Q=n("Qu3c"),Z=n("iadO");let tt=(()=>{class t{constructor(t,e,n){this.staffService=t,this.router=e,this.store=n}editEmployee(t){this.router.navigate(["edit-employee",t.id])}deleteEmployee(t){const e=this;D.a.fire({title:"Are you sure?",text:"You will not be able to recover it!",icon:"warning",showDenyButton:!0,denyButtonText:"No please",confirmButtonText:"Sure"}).then(function(n){n.isConfirmed&&e.staffService.deleteEmployee(t.id).then(()=>{D.a.fire("Deleted","Employee deleted","success")}).catch(t=>{D.a.fire("Error",t.message,"error")})})}ngOnInit(){this.name=this.employee.name,this.last_name=this.employee.last_name,this.age=this.employee.age,this.date_discharge=this.employee.date_discharge.toDate(),this.departmentsSubscription=this.store.select("departments").subscribe(({departments:t})=>t.map(t=>{t.id===this.employee.department&&(this.department=t.name)}))}ngOnDestroy(){this.departmentsSubscription.unsubscribe()}}return t.\u0275fac=function(e){return new(e||t)(c.Nb(g),c.Nb(s.b),c.Nb(p.h))},t.\u0275cmp=c.Hb({type:t,selectors:[["app-staff-child"]],inputs:{employee:"employee"},decls:23,vars:8,consts:[[1,"mb-05"],["mat-card-avatar",""],["mat-icon-button","",1,"icon-corner",3,"matMenuTriggerFor"],["menu","matMenu"],["mat-menu-item","",3,"click"]],template:function(t,e){if(1&t&&(c.Tb(0,"mat-card",0),c.Tb(1,"mat-card-header"),c.Tb(2,"div",1),c.Tb(3,"mat-icon"),c.Ac(4,"person"),c.Sb(),c.Sb(),c.Tb(5,"mat-card-title"),c.Ac(6),c.Sb(),c.Tb(7,"mat-card-subtitle"),c.Ac(8),c.fc(9,"date"),c.Sb(),c.Sb(),c.Tb(10,"button",2),c.Tb(11,"mat-icon"),c.Ac(12,"more_vert"),c.Sb(),c.Sb(),c.Tb(13,"mat-menu",null,3),c.Tb(15,"button",4),c.ac("click",function(){return e.editEmployee(e.employee)}),c.Tb(16,"mat-icon"),c.Ac(17,"edit"),c.Sb(),c.Ac(18,"Edit"),c.Sb(),c.Tb(19,"button",4),c.ac("click",function(){return e.deleteEmployee(e.employee)}),c.Tb(20,"mat-icon"),c.Ac(21,"delete"),c.Sb(),c.Ac(22,"Delete"),c.Sb(),c.Sb(),c.Sb()),2&t){const t=c.oc(14);c.Cb(6),c.Ec("",e.name," ",e.last_name," (",e.age,")"),c.Cb(2),c.Dc("",e.department," - since ",c.gc(9,6,e.date_discharge),""),c.Cb(2),c.jc("matMenuTriggerFor",t)}},directives:[I.a,I.e,I.c,O.a,I.h,I.g,y.a,v.d,v.a,v.b],pipes:[r.e],styles:[""]}),t})();function et(t,e){if(1&t){const t=c.Ub();c.Tb(0,"mat-form-field",12),c.Tb(1,"mat-label"),c.Ac(2,"Search employee"),c.Sb(),c.Tb(3,"input",13),c.ac("ngModelChange",function(e){return c.qc(t),c.ec().search_name=e}),c.Sb(),c.Sb()}if(2&t){const t=c.ec();c.Cb(3),c.jc("ngModel",t.search_name)}}function nt(t,e){if(1&t&&(c.Tb(0,"mat-option",16),c.Ac(1),c.Sb()),2&t){const t=e.$implicit;c.jc("value",t.id),c.Cb(1),c.Cc(" ",t.name," ")}}function rt(t,e){if(1&t){const t=c.Ub();c.Tb(0,"mat-form-field",12),c.Tb(1,"mat-label"),c.Ac(2,"Departments"),c.Sb(),c.Tb(3,"mat-select",14),c.ac("ngModelChange",function(e){return c.qc(t),c.ec().search_department=e}),c.yc(4,nt,2,2,"mat-option",15),c.Sb(),c.Sb()}if(2&t){const t=c.ec();c.Cb(3),c.jc("ngModel",t.search_department),c.Cb(1),c.jc("ngForOf",t.departments)}}function it(t,e){if(1&t){const t=c.Ub();c.Tb(0,"mat-form-field",12),c.Tb(1,"mat-label"),c.Ac(2,"Search by minimum date"),c.Sb(),c.Tb(3,"input",17),c.ac("ngModelChange",function(e){return c.qc(t),c.ec().search_date=e}),c.Sb(),c.Ob(4,"mat-datepicker-toggle",18),c.Ob(5,"mat-datepicker",null,19),c.Sb()}if(2&t){const t=c.oc(6),e=c.ec();c.Cb(3),c.jc("matDatepicker",t)("ngModel",e.search_date),c.Cb(1),c.jc("for",t)}}function at(t,e){1&t&&(c.Tb(0,"mat-list-item",20),c.Ac(1," No employee "),c.Sb())}function st(t,e){if(1&t&&c.Ob(0,"app-staff-child",22),2&t){const t=c.ec().$implicit;c.jc("employee",t)}}function ct(t,e){if(1&t&&(c.Tb(0,"div"),c.yc(1,st,1,1,"app-staff-child",21),c.Sb()),2&t){const t=e.$implicit,n=c.ec();c.Cb(1),c.jc("ngIf",n.filterStaff(t))}}let ot=(()=>{class t{constructor(t,e){this.store=t,this.router=e,this.staff=[],this.filter="name"}filterStaff(t){switch(this.filter){case"name":return!this.search_name||(t.name+" "+t.last_name).toLowerCase().indexOf(this.search_name.toLowerCase())>-1;case"department":return!this.search_department||this.search_department===t.department;case"date":if(this.search_date){let e=t.date_discharge;e=e.toDate();let n=new Date(this.search_date);return console.log(e,n),e>=n}return!0;default:return!1}}ngOnInit(){this.staffSubscription=this.store.select("staff").subscribe(({staff:t})=>this.staff=t),this.departmentsSubscription=this.store.select("departments").subscribe(({departments:t})=>this.departments=t)}addEmployee(){this.router.navigate(["new-employee"])}ngOnDestroy(){this.staffSubscription.unsubscribe(),this.departmentsSubscription.unsubscribe()}}return t.\u0275fac=function(e){return new(e||t)(c.Nb(p.h),c.Nb(s.b))},t.\u0275cmp=c.Hb({type:t,selectors:[["app-staff-list"]],decls:25,vars:6,consts:[["role","list"],["mat-subheader","",1,"h-auto","flex-box","flex-column"],[1,"w-100","flex-box","flex-row"],[1,"flex-box","text-center"],[1,"spacer"],["mat-stroked-button","",3,"click"],["class","w-100",4,"ngIf"],["mat-icon-button","","matTooltip","More filters",3,"matMenuTriggerFor"],["menu","matMenu"],["mat-menu-item","",3,"click"],["role","listitem",4,"ngIf"],[4,"ngFor","ngForOf"],[1,"w-100"],["matInput","","placeholder","John Doe",3,"ngModel","ngModelChange"],[3,"ngModel","ngModelChange"],[3,"value",4,"ngFor","ngForOf"],[3,"value"],["matInput","",3,"matDatepicker","ngModel","ngModelChange"],["matSuffix","",3,"for"],["picker",""],["role","listitem"],[3,"employee",4,"ngIf"],[3,"employee"]],template:function(t,e){if(1&t&&(c.Tb(0,"mat-list",0),c.Tb(1,"div",1),c.Tb(2,"div",2),c.Tb(3,"span",3),c.Ac(4,"Staff"),c.Sb(),c.Ob(5,"span",4),c.Tb(6,"button",5),c.ac("click",function(){return e.addEmployee()}),c.Ac(7,"Create employee"),c.Sb(),c.Sb(),c.Tb(8,"div",2),c.yc(9,et,4,1,"mat-form-field",6),c.yc(10,rt,5,2,"mat-form-field",6),c.yc(11,it,7,3,"mat-form-field",6),c.Tb(12,"button",7),c.Tb(13,"mat-icon"),c.Ac(14,"filter_list"),c.Sb(),c.Sb(),c.Tb(15,"mat-menu",null,8),c.Tb(17,"button",9),c.ac("click",function(){return e.filter="name"}),c.Ac(18,"Name"),c.Sb(),c.Tb(19,"button",9),c.ac("click",function(){return e.filter="department"}),c.Ac(20,"Department"),c.Sb(),c.Tb(21,"button",9),c.ac("click",function(){return e.filter="date"}),c.Ac(22,"Discharge date"),c.Sb(),c.Sb(),c.Sb(),c.Sb(),c.yc(23,at,2,0,"mat-list-item",10),c.yc(24,ct,2,1,"div",11),c.Sb()),2&t){const t=c.oc(16);c.Cb(9),c.jc("ngIf","name"===e.filter),c.Cb(1),c.jc("ngIf","department"===e.filter),c.Cb(1),c.jc("ngIf","date"===e.filter),c.Cb(1),c.jc("matMenuTriggerFor",t),c.Cb(11),c.jc("ngIf",0===e.staff.length),c.Cb(1),c.jc("ngForOf",e.staff)}},directives:[A.a,A.e,y.a,r.l,Q.a,v.d,O.a,v.a,v.b,r.k,k.c,k.f,F.b,a.c,a.l,a.o,_.a,C.m,Z.b,Z.d,k.g,Z.a,A.c,tt],styles:[""]}),t})();const bt=[{path:"",component:x,children:[{path:"",component:(()=>{class t{constructor(){}ngOnInit(){}}return t.\u0275fac=function(e){return new(e||t)},t.\u0275cmp=c.Hb({type:t,selectors:[["app-home"]],decls:5,vars:0,consts:[[1,"container","pt-1"],[1,"col-xs-12","col-sm-12","col-md-4","col-lg-4","col-xl-4"],[1,"col-xs-12","col-sm-12","col-md-8","col-lg-8","col-xl-8"]],template:function(t,e){1&t&&(c.Tb(0,"div",0),c.Tb(1,"div",1),c.Ob(2,"app-departments-list"),c.Sb(),c.Tb(3,"div",2),c.Ob(4,"app-staff-list"),c.Sb(),c.Sb())},directives:[V,ot],styles:[""]}),t})()},{path:"new-employee",component:K},{path:"edit-employee/:id",component:K},{path:"new-department",component:U},{path:"edit-department/:id",component:U}]}];let mt=(()=>{class t{}return t.\u0275mod=c.Lb({type:t}),t.\u0275inj=c.Kb({factory:function(e){return new(e||t)},imports:[[s.f.forChild(bt)],s.f]}),t})(),lt=(()=>{class t{}return t.\u0275mod=c.Lb({type:t}),t.\u0275inj=c.Kb({factory:function(e){return new(e||t)},imports:[[r.c,a.q,s.f,i.a,b,o,m,mt]]}),t})()}}]);