diff --git a/src/app/schedules/schedules.component.html b/src/app/schedules/schedules.component.html
index b524b02..3bec2c1 100644
--- a/src/app/schedules/schedules.component.html
+++ b/src/app/schedules/schedules.component.html
@@ -135,14 +135,14 @@
-
-
+
-
-
+
-
-
+
diff --git a/src/app/schedules/schedules.component.ts b/src/app/schedules/schedules.component.ts
index a42be40..297b37e 100644
--- a/src/app/schedules/schedules.component.ts
+++ b/src/app/schedules/schedules.component.ts
@@ -22,6 +22,7 @@ export class SchedulesComponent implements OnInit {
selectedDatesForSchedule: Array = [];
showSchedulePopup: boolean = false;
scheduleType: string = 'change time';
+ selectedMonthIndex: number;
scheduleFromTime = {
hour: '09',
min: '30',
@@ -37,13 +38,23 @@ export class SchedulesComponent implements OnInit {
profile_type: string = '';
profile_info: any;
- outletHoliday: {
+ outletTiming: {
+ close_timing: string;
holidays: string,
+ open_timing: string,
+ schedules: {
+ outlet_id: number
+ }
} = {
- holidays: ''
+ close_timing: "2021-10-28T09:37:05.776Z",
+ holidays: '',
+ open_timing: "2021-10-28T09:37:05.776Z",
+ schedules: {
+ outlet_id: null
+ }
}
- selectedHolidays: Array = [new Date('2021-10-21T00:00').toString(), new Date('2021-10-22T00:00').toString()];
+ selectedHolidays: Array = [];
constructor(
private outletService: OutletService
@@ -57,7 +68,6 @@ export class SchedulesComponent implements OnInit {
this.renderCalendar();
this.profile_type = localStorage.current_login_type;
- // this.selectedHolidays = [3,5]
if (this.profile_type === 'VENDOR') {
this.profile_info = JSON.parse(localStorage.vendor_info);
@@ -71,7 +81,6 @@ export class SchedulesComponent implements OnInit {
selectDates(dates: Array) {
this.selectedDatesForSchedule = dates;
- console.log(this.profile_info)
}
toggleDates(date: number) {
@@ -136,17 +145,18 @@ export class SchedulesComponent implements OnInit {
}
scheduleHolidays() {
-
- this.selectedHolidays = [];
- console.log(this.selectedHolidays)
-
- this.outletService.addOutletSchedules(this.outletHoliday).then((data) => {
+ this.selectedHolidays = this.selectedDatesForSchedule.map(selectedDates => this.getTodayString(selectedDates.toString()))
+ this.outletTiming.holidays = JSON.stringify(this.selectedHolidays)
+ this.outletTiming.schedules.outlet_id = this.profile_info.outlet_id
+ console.log(this.outletTiming)
+
+ this.outletService.addOutletSchedules(this.outletTiming).then((data) => {
console.log(data)
- // this.profile_info.schedules.push(data)
+ }, err=>{
+ console.log("Unable to Update Holidays")
})
}
-
getTodayString(selectedMonthDay: string) {
let monthIndex = this.monthMap.findIndex((month) => this.selectedMonth.toLowerCase() === month.toLowerCase()) + 1;
return new Date(this.selectedYear + '-' + monthIndex.toString().padStart(2, '0') + '-' + selectedMonthDay.toString().padStart(2, '0') + 'T00:00').toString();
diff --git a/src/app/services/outlet.service.ts b/src/app/services/outlet.service.ts
index b227286..d47051d 100644
--- a/src/app/services/outlet.service.ts
+++ b/src/app/services/outlet.service.ts
@@ -1,5 +1,6 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
+import { URL } from '../data/url';
@Injectable({
providedIn: 'root'
@@ -19,6 +20,6 @@ export class OutletService {
})
};
- return this.http.post(URL + "/api/maioraservice/outlet/v1/create", httpOptions).toPromise()
+ return this.http.post(URL + "/api/maioraservice/schedule/v2/create", schedules, httpOptions).toPromise()
}
}