1
|
import {Component, Input, OnInit} from '@angular/core';
|
2
|
import { MatDialog } from '@angular/material';
|
3
|
import { AddDaysOffDialogComponent } from '../../add-days-off-dialog/add-days-off-dialog.component';
|
4
|
import {UsersService} from '../../services/users.service';
|
5
|
import {Requests} from '../../models/requests.model';
|
6
|
import {UserProfile} from '../../models/user-profile.model';
|
7
|
import {UserService} from '../../services/user.service';
|
8
|
import {ProfileService} from "../../services/profile.service";
|
9
|
|
10
|
@Component({
|
11
|
selector: 'app-employer-dashboard',
|
12
|
templateUrl: './employer-dashboard.component.html',
|
13
|
styleUrls: ['./employer-dashboard.component.sass']
|
14
|
})
|
15
|
export class EmployerDashboardComponent implements OnInit {
|
16
|
|
17
|
@Input() profile: UserProfile;
|
18
|
private authorizationRequests: Requests;
|
19
|
private daysOffRequests: Requests;
|
20
|
|
21
|
constructor(
|
22
|
public dialog: MatDialog,
|
23
|
private profileService: ProfileService,
|
24
|
// API
|
25
|
private userService: UserService,
|
26
|
private usersService: UsersService
|
27
|
) { }
|
28
|
|
29
|
ngOnInit() {
|
30
|
this.profileService.getProfile()
|
31
|
.subscribe((data: UserProfile) => this.profile = data);
|
32
|
|
33
|
this.usersService.getAuthorizationRequests()
|
34
|
.subscribe((data: Requests) => this.authorizationRequests = data);
|
35
|
|
36
|
this.usersService.getVacationRequests()
|
37
|
.subscribe((data: Requests) => this.daysOffRequests = data);
|
38
|
}
|
39
|
|
40
|
private userApproved(requestId: number, approved: boolean) {
|
41
|
// TODO api post call
|
42
|
this.authorizationRequests.authorization.splice(0, 1);
|
43
|
}
|
44
|
|
45
|
private daysOffApproved(requestId: number, approved: boolean) {
|
46
|
// TODO api post call
|
47
|
this.daysOffRequests.vacation.splice(0, 1);
|
48
|
}
|
49
|
|
50
|
onDateSelect( date: Date ) {
|
51
|
this.dialog.open(AddDaysOffDialogComponent, {
|
52
|
data: {
|
53
|
fromDate: date
|
54
|
}
|
55
|
});
|
56
|
}
|
57
|
}
|