Refactoring betreft date object
This commit is contained in:
@@ -12,8 +12,8 @@
|
|||||||
{{ appointment.customer.firstName }} {{ appointment.customer.lastName }}</span>
|
{{ appointment.customer.firstName }} {{ appointment.customer.lastName }}</span>
|
||||||
<span class="appointment-time">
|
<span class="appointment-time">
|
||||||
<tui-icon icon="@tui.clock" [style.font-size.rem]="1"></tui-icon>
|
<tui-icon icon="@tui.clock" [style.font-size.rem]="1"></tui-icon>
|
||||||
{{ getFormattedTime(appointment.startHour, appointment.startMinute) }}
|
{{ getFormattedTime(appointment.startDateTime.getHours(), appointment.startDateTime.getMinutes()) }}
|
||||||
- {{ getFormattedTime(appointment.endHour, appointment.endMinute) }}
|
- {{ getFormattedTime(appointment.endDateTime.getHours(), appointment.endDateTime.getMinutes()) }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ export class AppointmentComponent {
|
|||||||
getInlineStyles(appointment: AppointmentDto): { [key: string]: string } {
|
getInlineStyles(appointment: AppointmentDto): { [key: string]: string } {
|
||||||
return {
|
return {
|
||||||
'--duration': `${appointment.durationInMinutes}`,
|
'--duration': `${appointment.durationInMinutes}`,
|
||||||
'--start-minute': `${appointment.startMinute}`,
|
'--start-minute': `${appointment.startDateTime.getMinutes()}`,
|
||||||
'top': `${appointment.startMinute}px`, // Startpositie binnen het uur
|
'top': `${appointment.startDateTime.getMinutes()}px`, // Startpositie binnen het uur
|
||||||
'height': `${appointment.durationInMinutes}px`, // Hoogte over meerdere uren
|
'height': `${appointment.durationInMinutes}px`, // Hoogte over meerdere uren
|
||||||
'width': `${this.width}px`,
|
'width': `${this.width}px`,
|
||||||
};
|
};
|
||||||
@@ -39,8 +39,8 @@ export class AppointmentComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getAppointmentHeight(appointment: AppointmentDto): number {
|
getAppointmentHeight(appointment: AppointmentDto): number {
|
||||||
const startInMinutes = (appointment.startHour * 60) + appointment.startMinute;
|
const startInMinutes = (appointment.startDateTime.getHours() * 60) + appointment.startDateTime.getMinutes();
|
||||||
const endInMinutes = (appointment.endHour * 60) + appointment.endMinute;
|
const endInMinutes = (appointment.endDateTime.getHours() * 60) + appointment.endDateTime.getMinutes();
|
||||||
return (endInMinutes - startInMinutes); // 50px per uur
|
return (endInMinutes - startInMinutes); // 50px per uur
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,5 +22,5 @@
|
|||||||
<h2>
|
<h2>
|
||||||
Eerst volgende afspraak:
|
Eerst volgende afspraak:
|
||||||
</h2>
|
</h2>
|
||||||
<h2>{{ appointment.startDate }}</h2>
|
<h2>{{ appointment.startDateTime }}</h2>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
||||||
import {DatePipe, NgForOf, NgIf} from '@angular/common';
|
import {DatePipe, NgForOf} from '@angular/common';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'datepicker',
|
selector: 'datepicker',
|
||||||
imports: [
|
imports: [
|
||||||
NgForOf,
|
NgForOf,
|
||||||
DatePipe,
|
DatePipe
|
||||||
NgIf
|
|
||||||
],
|
],
|
||||||
templateUrl: './datepicker.component.html',
|
templateUrl: './datepicker.component.html',
|
||||||
styleUrl: './datepicker.component.scss'
|
styleUrl: './datepicker.component.scss'
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
<tui-icon
|
<tui-icon
|
||||||
icon="@tui.calendar"
|
icon="@tui.calendar"
|
||||||
[style.color]="'var(--tui-background-accent-1)'"/>
|
[style.color]="'var(--tui-background-accent-1)'"/>
|
||||||
{{ DateFormatter.getDate(appointment.startDate.toString()) }}
|
{{ DateFormatter.getDate(appointment.startDateTime.toString()) }}
|
||||||
</h2>
|
</h2>
|
||||||
<h2>
|
<h2>
|
||||||
<tui-icon
|
<tui-icon
|
||||||
icon="@tui.clock"
|
icon="@tui.clock"
|
||||||
[style.color]="'var(--tui-background-accent-1)'"/>
|
[style.color]="'var(--tui-background-accent-1)'"/>
|
||||||
{{ DateFormatter.getFormattedTime(appointment.startHour, appointment.startMinute) }}
|
{{ DateFormatter.getFormattedTime(appointment.startDateTime.getHours(), appointment.startDateTime.getMinutes()) }}
|
||||||
- {{ DateFormatter.getFormattedTime(appointment.endHour, appointment.endMinute) }}
|
- {{ DateFormatter.getFormattedTime(appointment.endDateTime.getHours(), appointment.endDateTime.getMinutes()) }}
|
||||||
</h2>
|
</h2>
|
||||||
<h2 *ngIf="appointment.customer">
|
<h2 *ngIf="appointment.customer">
|
||||||
<tui-icon
|
<tui-icon
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<tui-icon
|
<tui-icon
|
||||||
icon="@tui.arrow-left-right"
|
icon="@tui.arrow-left-right"
|
||||||
[style.color]="'var(--tui-background-accent-1)'"/>
|
[style.color]="'var(--tui-background-accent-1)'"/>
|
||||||
Agenda wisselen
|
Agenda beheren
|
||||||
</button>
|
</button>
|
||||||
</tui-data-list>
|
</tui-data-list>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -59,12 +59,12 @@ export class EditItemComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
let date = new Date(this.appointment.startDate);
|
let date = new Date(this.appointment.startDateTime);
|
||||||
this.testForm = new FormGroup({
|
this.testForm = new FormGroup({
|
||||||
title: new FormControl(this.appointment.title, Validators.required),
|
title: new FormControl(this.appointment.title, Validators.required),
|
||||||
notes: new FormControl(this.appointment.description),
|
notes: new FormControl(this.appointment.description),
|
||||||
startTime: new FormControl(new TuiTime(this.appointment.startHour, this.appointment.startMinute), Validators.required),
|
startTime: new FormControl(new TuiTime(this.appointment.startDateTime.getHours(), this.appointment.startDateTime.getMinutes()), Validators.required),
|
||||||
endTime: new FormControl(new TuiTime(this.appointment.endHour, this.appointment.endMinute), Validators.required),
|
endTime: new FormControl(new TuiTime(this.appointment.endDateTime.getHours(), this.appointment.endDateTime.getMinutes()), Validators.required),
|
||||||
date: new FormControl(new TuiDay(date.getFullYear(), date.getMonth(), date.getDate()), Validators.required),
|
date: new FormControl(new TuiDay(date.getFullYear(), date.getMonth(), date.getDate()), Validators.required),
|
||||||
})
|
})
|
||||||
this.control = new FormControl(this.appointment.customer)
|
this.control = new FormControl(this.appointment.customer)
|
||||||
@@ -84,17 +84,17 @@ export class EditItemComponent implements OnInit {
|
|||||||
const endTime = this.testForm.get('endTime').value
|
const endTime = this.testForm.get('endTime').value
|
||||||
let date = this.testForm.get('date').value
|
let date = this.testForm.get('date').value
|
||||||
let correctDate = new Date(date.year, date.month, date.day + 1)
|
let correctDate = new Date(date.year, date.month, date.day + 1)
|
||||||
|
let startDateTime = new Date(date.year, date.month, date.day, startTime.hours, startTime.minutes)
|
||||||
|
let endDateTime = new Date(date.year, date.month, date.day, endTime.hours, endTime.minutes)
|
||||||
|
|
||||||
const customer = this.control.value;
|
const customer = this.control.value;
|
||||||
this.appointment.startDate = correctDate;
|
this.appointment.startDateTime = correctDate;
|
||||||
this.appointment.title = title;
|
this.appointment.title = title;
|
||||||
this.appointment.description = description
|
this.appointment.description = description
|
||||||
this.appointment.startHour = startTime.hours
|
this.appointment.startDateTime = startDateTime;
|
||||||
this.appointment.startMinute = startTime.minutes
|
this.appointment.endDateTime = endDateTime;
|
||||||
this.appointment.endHour = endTime.hours
|
|
||||||
this.appointment.endMinute = endTime.minutes
|
|
||||||
this.appointment.customer = customer;
|
this.appointment.customer = customer;
|
||||||
this.appointment.durationInMinutes = (this.appointment.endHour * 60 + this.appointment.endMinute) - (this.appointment.startHour * 60 + this.appointment.startMinute);
|
this.appointment.durationInMinutes = (startDateTime.getTime() - startDateTime.getTime()) / 1000;
|
||||||
|
|
||||||
this.waiting = true
|
this.waiting = true
|
||||||
this.appointmentService.updateAppointment(this.appointment).subscribe(() => {
|
this.appointmentService.updateAppointment(this.appointment).subscribe(() => {
|
||||||
|
|||||||
@@ -91,7 +91,7 @@
|
|||||||
<ng-container *ngIf="appointments.length > 0">
|
<ng-container *ngIf="appointments.length > 0">
|
||||||
<h3>Geplande afspraken die dag:</h3>
|
<h3>Geplande afspraken die dag:</h3>
|
||||||
<div class="appointments-container">
|
<div class="appointments-container">
|
||||||
<div *ngFor="let appointment of appointments" class="appointment-object" [attr.id]="appointment.title.toLowerCase() + '-' + appointment.startDate + '-' + appointment.startHour + appointment.startMinute">
|
<div *ngFor="let appointment of appointments" class="appointment-object" [attr.id]="appointment.title.toLowerCase() + '-' + appointment.startDateTime + '-' + appointment.startDateTime.getHours() + appointment.startDateTime.getMinutes()">
|
||||||
<span class="title" id="titel-afspraak">{{ appointment.title }}</span>
|
<span class="title" id="titel-afspraak">{{ appointment.title }}</span>
|
||||||
<span class="name" id="titel-naam">
|
<span class="name" id="titel-naam">
|
||||||
<tui-icon
|
<tui-icon
|
||||||
@@ -104,8 +104,8 @@
|
|||||||
icon="@tui.clock"
|
icon="@tui.clock"
|
||||||
[style.font-size.rem]="1"
|
[style.font-size.rem]="1"
|
||||||
[style.color]="'var(--tui-background-accent-1)'"/>
|
[style.color]="'var(--tui-background-accent-1)'"/>
|
||||||
{{ getFormattedTime(appointment.startHour, appointment.startMinute) }} -
|
{{ getFormattedTime(appointment.startDateTime.getHours(), appointment.startDateTime.getMinutes()) }} -
|
||||||
{{ getFormattedTime(appointment.endHour, appointment.endMinute) }}
|
{{ getFormattedTime(appointment.endDateTime.getHours(), appointment.endDateTime.getMinutes()) }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import {
|
|||||||
TuiTextareaModule,
|
TuiTextareaModule,
|
||||||
TuiTextfieldControllerModule
|
TuiTextfieldControllerModule
|
||||||
} from "@taiga-ui/legacy";
|
} from "@taiga-ui/legacy";
|
||||||
import {Appointment} from '../../models/appointment';
|
|
||||||
import {TuiDay, TuiValidationError} from '@taiga-ui/cdk';
|
import {TuiDay, TuiValidationError} from '@taiga-ui/cdk';
|
||||||
import {AppointmentService} from '../../services/appointment.service';
|
import {AppointmentService} from '../../services/appointment.service';
|
||||||
import {TuiDataListWrapperComponent, TuiFilterByInputPipe, TuiStringifyContentPipe} from '@taiga-ui/kit';
|
import {TuiDataListWrapperComponent, TuiFilterByInputPipe, TuiStringifyContentPipe} from '@taiga-ui/kit';
|
||||||
@@ -75,7 +74,7 @@ export class NewItemComponent implements OnInit {
|
|||||||
this.appointmentForm.get('startTime').setValue('', Validators.required)
|
this.appointmentForm.get('startTime').setValue('', Validators.required)
|
||||||
this.appointmentForm.get('endTime').setValue('', [Validators.required, timeAfterStartValidator('startTime')])
|
this.appointmentForm.get('endTime').setValue('', [Validators.required, timeAfterStartValidator('startTime')])
|
||||||
this.appointments.sort((a, b) => {
|
this.appointments.sort((a, b) => {
|
||||||
return a.startHour - b.startHour || a.startMinute - b.startMinute;
|
return a.startDateTime.getHours() - b.startDateTime.getHours() || a.startDateTime.getMinutes() - b.startDateTime.getMinutes();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,9 +86,13 @@ export class NewItemComponent implements OnInit {
|
|||||||
let date = this.appointmentForm.get('date').value
|
let date = this.appointmentForm.get('date').value
|
||||||
let correctDate = new Date(date.year, date.month, date.day, startTime.hours, startTime.minutes);
|
let correctDate = new Date(date.year, date.month, date.day, startTime.hours, startTime.minutes);
|
||||||
|
|
||||||
|
let startDateTime = new Date(date.year, date.month, date.day, startTime.hours, startTime.minutes)
|
||||||
|
let endDateTime = new Date(date.year, date.month, date.day, endTime.hours, endTime.minutes)
|
||||||
|
|
||||||
const customer = this.customerControl.value;
|
const customer = this.customerControl.value;
|
||||||
|
|
||||||
const appointment = new AppointmentDto(title, description, startTime.hours, startTime.minutes, endTime.hours, endTime.minutes, correctDate, customer)
|
// constructor(id: string, title: string, description: string, startDateTime: Date, endDateTime: Date, customer: Customer, company: CompanyDTO)
|
||||||
|
const appointment = new AppointmentDto(title, description, startDateTime, endDateTime, customer)
|
||||||
this.waiting = true
|
this.waiting = true
|
||||||
this.appointmentService.addAppointment(appointment, this.userService.currentCompany.id).subscribe(() => {
|
this.appointmentService.addAppointment(appointment, this.userService.currentCompany.id).subscribe(() => {
|
||||||
this.waiting = false
|
this.waiting = false
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ export class WeekViewComponent implements OnInit {
|
|||||||
|
|
||||||
getAppointments() {
|
getAppointments() {
|
||||||
console.log(this.days[0], this.days[6])
|
console.log(this.days[0], this.days[6])
|
||||||
|
console.log('GETTING APPOINTMENTS')
|
||||||
this.appointmentService.getAppointmentsByWeek(this.days[0], this.days[6]).subscribe(appointments => {
|
this.appointmentService.getAppointmentsByWeek(this.days[0], this.days[6]).subscribe(appointments => {
|
||||||
this.appointments = appointments
|
this.appointments = appointments
|
||||||
console.log(appointments);
|
console.log(appointments);
|
||||||
@@ -86,12 +87,23 @@ export class WeekViewComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
searchAppointments(day: Date, hour: string) {
|
searchAppointments(day: Date, hour: string) {
|
||||||
return this.appointments.filter(appointment =>
|
const targetHour = Number(hour.substring(0, 2));
|
||||||
appointment.startHour === Number(hour.substring(0, 2)) &&
|
|
||||||
appointment.startDate.toString().startsWith(this.formatDateToISO(day))
|
return this.appointments.filter(appointment => {
|
||||||
|
const date = appointment.startDateTime instanceof Date
|
||||||
|
? appointment.startDateTime
|
||||||
|
: new Date(appointment.startDateTime); // fallback als het nog een string is
|
||||||
|
|
||||||
|
return (
|
||||||
|
date.getFullYear() === day.getFullYear() &&
|
||||||
|
date.getMonth() === day.getMonth() &&
|
||||||
|
date.getDate() === day.getDate() &&
|
||||||
|
date.getHours() === targetHour
|
||||||
);
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
formatDateToISO(date: Date): string {
|
formatDateToISO(date: Date): string {
|
||||||
const year = date.getFullYear();
|
const year = date.getFullYear();
|
||||||
const month = (date.getMonth() + 1).toString().padStart(2, '0'); // maand is 0-based
|
const month = (date.getMonth() + 1).toString().padStart(2, '0'); // maand is 0-based
|
||||||
@@ -103,4 +115,8 @@ export class WeekViewComponent implements OnInit {
|
|||||||
emitAppointment($event: AppointmentDto) {
|
emitAppointment($event: AppointmentDto) {
|
||||||
this.appointmentSelected.emit($event);
|
this.appointmentSelected.emit($event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getISODate(date: Date) {
|
||||||
|
return date.toISOString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,30 +2,23 @@ import {Customer} from './customer';
|
|||||||
import {CompanyDTO} from './app-user-dto';
|
import {CompanyDTO} from './app-user-dto';
|
||||||
|
|
||||||
export class AppointmentDto {
|
export class AppointmentDto {
|
||||||
id: number;
|
id: string;
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
startDate: string | Date;
|
startDateTime: Date;
|
||||||
startHour: number;
|
endDateTime: Date;
|
||||||
startMinute: number;
|
|
||||||
endHour: number;
|
|
||||||
endMinute: number;
|
|
||||||
durationInMinutes: number;
|
durationInMinutes: number;
|
||||||
customer: Customer;
|
customer: Customer;
|
||||||
company: CompanyDTO;
|
company: CompanyDTO;
|
||||||
|
|
||||||
|
constructor(title: string, description: string, startDateTime: Date, endDateTime: Date, customer: Customer) {
|
||||||
constructor(title: string, description: string, startHour: number, startMinute: number, endHour: number, endMinute: number, date: Date, customer: Customer) {
|
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.startHour = startHour;
|
this.startDateTime = startDateTime;
|
||||||
this.startMinute = startMinute;
|
this.endDateTime = endDateTime;
|
||||||
this.endHour = endHour;
|
|
||||||
this.endMinute = endMinute;
|
|
||||||
this.startDate = date;
|
|
||||||
this.customer = customer;
|
this.customer = customer;
|
||||||
|
|
||||||
// Bereken de totale duur in minuten
|
this.durationInMinutes = (startDateTime.getTime() - startDateTime.getTime()) / 1000;
|
||||||
this.durationInMinutes = (endHour * 60 + endMinute) - (startHour * 60 + startMinute);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,26 +4,20 @@ export class Appointment {
|
|||||||
id: string;
|
id: string;
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
startDate: Date;
|
startDateTime: Date;
|
||||||
startHour: number;
|
endDateTime: Date;
|
||||||
startMinute: number;
|
|
||||||
endHour: number;
|
|
||||||
endMinute: number;
|
|
||||||
durationInMinutes: number;
|
durationInMinutes: number;
|
||||||
customer: Customer;
|
customer: Customer;
|
||||||
|
|
||||||
constructor(title: string, description: string, startHour: number, startMinute: number, endHour: number, endMinute: number, date: Date, customer: Customer) {
|
constructor(id: string, title: string, description: string, startDateTime: Date, endDateTime: Date, customer: Customer) {
|
||||||
|
this.id = id;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.startHour = startHour;
|
this.startDateTime = startDateTime;
|
||||||
this.startMinute = startMinute;
|
this.endDateTime = endDateTime;
|
||||||
this.endHour = endHour;
|
|
||||||
this.endMinute = endMinute;
|
|
||||||
this.startDate = date;
|
|
||||||
this.customer = customer;
|
this.customer = customer;
|
||||||
|
|
||||||
// Bereken de totale duur in minuten
|
this.durationInMinutes = (startDateTime.getTime() - startDateTime.getTime()) / 1000;
|
||||||
this.durationInMinutes = (endHour * 60 + endMinute) - (startHour * 60 + startMinute);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,8 +127,8 @@
|
|||||||
{{ appointment.customer.firstName }} {{ appointment.customer.lastName }}</span>
|
{{ appointment.customer.firstName }} {{ appointment.customer.lastName }}</span>
|
||||||
<span class="appointment-time">
|
<span class="appointment-time">
|
||||||
<tui-icon icon="@tui.clock" [style.font-size.rem]="1"></tui-icon>
|
<tui-icon icon="@tui.clock" [style.font-size.rem]="1"></tui-icon>
|
||||||
{{ getFormattedTime(appointment.startHour, appointment.startMinute) }}
|
{{ getFormattedTime(appointment.startDateTime.getHours(), appointment.startDateTime.getMinutes()) }}
|
||||||
- {{ getFormattedTime(appointment.endHour, appointment.endMinute) }}
|
- {{ getFormattedTime(appointment.endDateTime.getHours(), appointment.endDateTime.getMinutes()) }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -81,9 +81,13 @@ export class AgendaComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getAppointmentsForHour(hour: number) {
|
getAppointmentsForHour(hour: number) {
|
||||||
return this.appointments.filter(appointment => appointment.startHour === hour);
|
return this.appointments.filter(appointment => {
|
||||||
|
const startDateTime = new Date(appointment.startDateTime);
|
||||||
|
return startDateTime.getHours() === hour;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getDate(): string {
|
getDate(): string {
|
||||||
const date = this.selectedDate
|
const date = this.selectedDate
|
||||||
|
|
||||||
@@ -182,8 +186,8 @@ export class AgendaComponent implements OnInit {
|
|||||||
getInlineStyles(appointment: AppointmentDto): { [key: string]: string } {
|
getInlineStyles(appointment: AppointmentDto): { [key: string]: string } {
|
||||||
return {
|
return {
|
||||||
'--duration': `${appointment.durationInMinutes}`,
|
'--duration': `${appointment.durationInMinutes}`,
|
||||||
'--start-minute': `${appointment.startMinute}`,
|
'--start-minute': `${appointment.startDateTime.getMinutes()}`,
|
||||||
'top': `${appointment.startMinute}px`, // Startpositie binnen het uur
|
'top': `${appointment.startDateTime.getMinutes()}px`, // Startpositie binnen het uur
|
||||||
'height': `${appointment.durationInMinutes}px`, // Hoogte over meerdere uren
|
'height': `${appointment.durationInMinutes}px`, // Hoogte over meerdere uren
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -193,8 +197,8 @@ export class AgendaComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getAppointmentHeight(appointment: AppointmentDto): number {
|
getAppointmentHeight(appointment: AppointmentDto): number {
|
||||||
const startInMinutes = (appointment.startHour * 60) + appointment.startMinute;
|
const startInMinutes = (appointment.startDateTime.getHours() * 60) + appointment.startDateTime.getMinutes();
|
||||||
const endInMinutes = (appointment.endHour * 60) + appointment.endMinute;
|
const endInMinutes = (appointment.endDateTime.getHours() * 60) + appointment.endDateTime.getMinutes();
|
||||||
return (endInMinutes - startInMinutes); // 50px per uur
|
return (endInMinutes - startInMinutes); // 50px per uur
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {HttpClient} from '@angular/common/http';
|
import {HttpClient} from '@angular/common/http';
|
||||||
import {Appointment} from '../models/appointment';
|
|
||||||
import {environment} from '../../environments/environment';
|
import {environment} from '../../environments/environment';
|
||||||
import {AuthService} from './auth.service';
|
|
||||||
import {AppointmentDto} from '../models/appointment-dto';
|
import {AppointmentDto} from '../models/appointment-dto';
|
||||||
|
import {map} from 'rxjs';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
@@ -22,7 +21,15 @@ export class AppointmentService {
|
|||||||
const day = date.getDate().toString().padStart(2, '0')
|
const day = date.getDate().toString().padStart(2, '0')
|
||||||
const month = (date.getMonth() + 1).toString().padStart(2, '0')
|
const month = (date.getMonth() + 1).toString().padStart(2, '0')
|
||||||
const year = date.getFullYear();
|
const year = date.getFullYear();
|
||||||
return this.http.get<AppointmentDto[]>(`${this.baseApi}/date?start=${year}-${month}-${day}`, {});
|
return this.http.get<AppointmentDto[]>(`${this.baseApi}/date?start=${year}-${month}-${day}`, {}).pipe(
|
||||||
|
map(appointments =>
|
||||||
|
appointments.map(dto => ({
|
||||||
|
...dto,
|
||||||
|
startDateTime: new Date(dto.startDateTime),
|
||||||
|
endDateTime: new Date(dto.endDateTime),
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
getAppointmentsByWeek(date: Date, endDate: Date) {
|
getAppointmentsByWeek(date: Date, endDate: Date) {
|
||||||
@@ -32,7 +39,15 @@ export class AppointmentService {
|
|||||||
const endDay = endDate.getDate().toString().padStart(2, '0')
|
const endDay = endDate.getDate().toString().padStart(2, '0')
|
||||||
const endMonth = (endDate.getMonth() + 1).toString().padStart(2, '0')
|
const endMonth = (endDate.getMonth() + 1).toString().padStart(2, '0')
|
||||||
const endYear = endDate.getFullYear();
|
const endYear = endDate.getFullYear();
|
||||||
return this.http.get<AppointmentDto[]>(`${this.baseApi}/date/week?start=${year}-${month}-${day}&end=${endYear}-${endMonth}-${endDay}`, {});
|
return this.http.get<AppointmentDto[]>(`${this.baseApi}/date/week?start=${year}-${month}-${day}&end=${endYear}-${endMonth}-${endDay}`, {}).pipe(
|
||||||
|
map(appointments =>
|
||||||
|
appointments.map(dto => ({
|
||||||
|
...dto,
|
||||||
|
startDateTime: new Date(dto.startDateTime),
|
||||||
|
endDateTime: new Date(dto.endDateTime),
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
addAppointment(appointment: AppointmentDto, companyId: number) {
|
addAppointment(appointment: AppointmentDto, companyId: number) {
|
||||||
|
|||||||
Reference in New Issue
Block a user