end slot duration check added

This commit is contained in:
bitbucket 2023-05-15 10:01:17 +05:30
parent 54bd8010ce
commit 886fb9acd2
4 changed files with 99 additions and 2 deletions

View File

@ -78,7 +78,7 @@
</div>
<div class="innerdivs2" >
<ng-scrollbar class="scrollHV2" *ngIf="slots.length != 0">
<button type="button" *ngFor="let slot of slots;let i=index" mat-raised-button mat-button-sm class="mr-1 mt-1 hoverButton" [ngClass]="{'primary':slotIndex != i,'clickedSlot':slotIndex == i }" (click)="toggleActive($event,slot,i)">{{slot | date:'shortTime'}}</button>
<button type="button" *ngFor="let slot of slots;let i=index" mat-raised-button mat-button-sm class="mr-1 mt-1 hoverButton" [ngClass]="{'primary':slotIndex != i && checkSlotDur(slot,i)==1,'clickedSlot':slotIndex == i && checkSlotDur(slot,i)==1 }" (click)="toggleActive($event,slot,i)"><span *ngIf="checkSlotDur(slot,i)==1">{{slot | date:'shortTime'}}</span></button>
</ng-scrollbar>
<div *ngIf="slots.length == 0">
<div fxLayout="row" class="flexCard">

View File

@ -372,6 +372,53 @@ export class DialogBoxComponent implements OnInit {
}
})
}
checkSlotDur(param:any,i:any){
//console.log(param,i)
// this.slot_array =[];
// debugger;
// event.preventDefault();
// this.slotIndex = i
// this.slotTime = param
// console.log(this.date,param)
let thirtyMinutes = this.duration * 60 * 1000; // convert 30 minutes to milliseconds
let date1 = new Date(param);
let date2 = new Date(date1.getTime() + thirtyMinutes);
// console.log(date1);
// console.log(date2);
const currentTime = new Date(); // Get the current time
//const filteredTimes = this.slots.filter(time => new Date(time) > date1);
const rangeDate = new Date(date2);
const resultArray = this.slots.filter(slot => {
const date = new Date(slot);
return date >= rangeDate;
});
const firstSlt = new Date(date1);
const lastSlt = new Date( resultArray[0]);
const filteredTimes = this.slots.filter(time => new Date(time) >= firstSlt && new Date(time) <= lastSlt);
// console.log(resultArray,filteredTimes);
if(filteredTimes.length>0){
return 1
}else{
return 0
}
// let result = filteredTimes.pop();
// console.log(result);
// this.slots.forEach(element => {
// if(element <date2){
// console.log(element);
// }
// });
// this.slot_array.push({date:this.days[this.clicks],slots:filteredTimes})
}
submit(){
console.log(this.form.value,this.slotsResult,this.days[this.clicks]);

View File

@ -88,7 +88,8 @@
</div>
</div>
<ng-scrollbar class="scrollHV" >
<button *ngFor="let slot of slots;let i=index" mat-raised-button mat-button-sm class="mr-1 mt-1 hoverButton" [ngClass]="{'primary':slotIndex != i,'clickedSlot':slotIndex == i }" (click)="toggleActive($event,slot,i)" >{{slot | date:'shortTime'}}</button>
<button *ngFor="let slot of slots;let i=index" mat-raised-button mat-button-sm class="mr-1 mt-1 hoverButton" [ngClass]="{'primary':slotIndex != i && checkSlotDur(slot,i)==1,'clickedSlot':slotIndex == i && checkSlotDur(slot,i)==1 }" (click)="toggleActive($event,slot,i)" ><span *ngIf="checkSlotDur(slot,i)==1">{{slot | date:'shortTime'}}</span></button>
</ng-scrollbar>

View File

@ -284,6 +284,55 @@ if(this.getHours.length != 0){
this.slot_array.push({date:this.days[this.clicks],slots:filteredTimes})
}
checkSlotDur(param:any,i:any){
//console.log(param,i)
// this.slot_array =[];
// debugger;
// event.preventDefault();
// this.slotIndex = i
// this.slotTime = param
// console.log(this.date,param)
let thirtyMinutes = this.servicesName.duration * 60 * 1000; // convert 30 minutes to milliseconds
let date1 = new Date(param);
let date2 = new Date(date1.getTime() + thirtyMinutes);
// console.log(date1);
// console.log(date2);
const currentTime = new Date(); // Get the current time
//const filteredTimes = this.slots.filter(time => new Date(time) > date1);
const rangeDate = new Date(date2);
const resultArray = this.slots.filter(slot => {
const date = new Date(slot);
return date >= rangeDate;
});
const firstSlt = new Date(date1);
const lastSlt = new Date( resultArray[0]);
const filteredTimes = this.slots.filter(time => new Date(time) >= firstSlt && new Date(time) <= lastSlt);
// console.log(resultArray,filteredTimes);
if(filteredTimes.length>0){
return 1
}else{
return 0
}
// let result = filteredTimes.pop();
// console.log(result);
// this.slots.forEach(element => {
// if(element <date2){
// console.log(element);
// }
// });
// this.slot_array.push({date:this.days[this.clicks],slots:filteredTimes})
}
submit(){