Skip to content

Commit

Permalink
Update add schedule to disable saturday for those service centers tha…
Browse files Browse the repository at this point in the history
…t don't work on saturday
  • Loading branch information
deep-mm committed Nov 8, 2022
1 parent 2e02a79 commit 1c9b50f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions service-center-app/src/app/add-schedule/add-schedule.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import { Invoice } from '../models/Invoice';
import { MaintenanceService } from '../models/MaintenanceService';
import { RepairService } from '../models/RepairService';
import { Service } from '../models/Service';
import { ServiceCenter } from '../models/ServiceCenter';
import { ServiceCenterProvidesService } from '../models/ServiceCenterProvidesService';
import { ServiceEvent } from '../models/ServiceEvent';
import { ServicesCar } from '../models/ServicesCar';
import { ServiceCenterProvidesServiceService } from '../services/service-center-provides-service/service-center-provides-service.service';
import { ServiceCenterService } from '../services/service-center/service-center.service';
import { ServiceService } from '../services/service/service.service';

@Component({
Expand Down Expand Up @@ -41,8 +43,9 @@ export class AddScheduleComponent implements OnInit {
preferredTime: number = 0;
remainingTime: number = 11;
mechanicId: number = 0;
serviceCenter: any = null;

constructor(public router: Router, public _apiService: ServiceService, private _snackBar: MatSnackBar, public scpsApi: ServiceCenterProvidesServiceService) { }
constructor(public router: Router, public _apiService: ServiceService, private _snackBar: MatSnackBar, public scpsApi: ServiceCenterProvidesServiceService, public serviceCenterApi: ServiceCenterService) { }

ngOnInit(): void {
this.loading = true;
Expand All @@ -67,7 +70,16 @@ export class AddScheduleComponent implements OnInit {
this._apiService.getServiceCars(this.customerCar.car_ID).subscribe(
(res: any) => {
this.serviceCars = res;
this.loading = false;
this.serviceCenterApi.getServiceCenterById(this.customer.service_CENTER_ID).subscribe(
(res: any) => {
this.serviceCenter = res;
this.loading = false;
},
(err: any) => {
console.log(err);
this.loading = false;
}
);
},
(err: any) => {
this.loading = false;
Expand Down Expand Up @@ -262,6 +274,11 @@ export class AddScheduleComponent implements OnInit {
myFilter = (d: Date | null): boolean => {
const day = (d || new Date()).getDay();
// Prevent Sunday from being selected.
if (this.serviceCenter!=null){
if (this.serviceCenter.weekend_WORKING == 0){
return day !== 0 && day !== 6;
}
}
return day !== 0;
};

Expand Down

0 comments on commit 1c9b50f

Please sign in to comment.