|
|
@@ -1,14 +1,15 @@ |
|
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
|
import { OutletService } from '../services/outlet.service'; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
selector: 'app-schedules', |
|
|
|
templateUrl: './schedules.component.html', |
|
|
|
styleUrls: ['./schedules.component.scss'] |
|
|
|
selector: 'app-schedules', |
|
|
|
templateUrl: './schedules.component.html', |
|
|
|
styleUrls: ['./schedules.component.scss'] |
|
|
|
}) |
|
|
|
export class SchedulesComponent implements OnInit { |
|
|
|
currentDate: number; |
|
|
|
currentMonth: string; |
|
|
|
selectedDate: number; |
|
|
|
currentDate: number; |
|
|
|
currentMonth: string; |
|
|
|
selectedDate: number; |
|
|
|
selectedMonth: string; |
|
|
|
selectedYear: number; |
|
|
|
dayMap: Array<string> = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; |
|
|
@@ -16,35 +17,47 @@ export class SchedulesComponent implements OnInit { |
|
|
|
preceedingDays: Array<number> = []; |
|
|
|
succeedingDays: Array<number> = []; |
|
|
|
selectedMonthDays: Array<number> = []; |
|
|
|
selectedTab: string = 'holiday'; |
|
|
|
selectedDatePosition: any; |
|
|
|
selectedDatesForSchedule: Array<number> = []; |
|
|
|
showSchedulePopup: boolean = false; |
|
|
|
scheduleType: string = 'change time'; |
|
|
|
scheduleFromTime = { |
|
|
|
hour: '09', |
|
|
|
min: '30', |
|
|
|
isBeforeMidday: true |
|
|
|
}; |
|
|
|
scheduleToTime = { |
|
|
|
hour: '09', |
|
|
|
min: '00', |
|
|
|
isBeforeMidday: false |
|
|
|
}; |
|
|
|
selectedTab: string = 'holiday'; |
|
|
|
selectedDatePosition: any; |
|
|
|
selectedDatesForSchedule: Array<number> = []; |
|
|
|
showSchedulePopup: boolean = false; |
|
|
|
scheduleType: string = 'change time'; |
|
|
|
scheduleFromTime = { |
|
|
|
hour: '09', |
|
|
|
min: '30', |
|
|
|
isBeforeMidday: true |
|
|
|
}; |
|
|
|
scheduleToTime = { |
|
|
|
hour: '09', |
|
|
|
min: '00', |
|
|
|
isBeforeMidday: false |
|
|
|
}; |
|
|
|
outletTimings: any |
|
|
|
|
|
|
|
profile_type: string = ''; |
|
|
|
profile_info: any; |
|
|
|
|
|
|
|
constructor() { } |
|
|
|
outletHoliday: { |
|
|
|
holidays: string, |
|
|
|
} = { |
|
|
|
holidays: '' |
|
|
|
} |
|
|
|
|
|
|
|
selectedHolidays: Array<string> = [new Date('2021-10-21T00:00').toString(), new Date('2021-10-22T00:00').toString()]; |
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
this.selectedMonth = this.monthMap[(new Date()).getMonth()]; |
|
|
|
constructor( |
|
|
|
private outletService: OutletService |
|
|
|
) { } |
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
this.selectedMonth = this.monthMap[(new Date()).getMonth()]; |
|
|
|
this.selectedYear = (new Date()).getFullYear(); |
|
|
|
this.currentDate = new Date().getDate(); |
|
|
|
this.currentMonth = this.monthMap[(new Date()).getMonth()]; |
|
|
|
this.currentDate = new Date().getDate(); |
|
|
|
this.currentMonth = this.monthMap[(new Date()).getMonth()]; |
|
|
|
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); |
|
|
@@ -53,17 +66,19 @@ export class SchedulesComponent implements OnInit { |
|
|
|
} |
|
|
|
|
|
|
|
console.log(this.profile_info); |
|
|
|
} |
|
|
|
|
|
|
|
selectDates(dates: Array<number>) { |
|
|
|
this.selectedDatesForSchedule = dates; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
toggleDates(date: number) { |
|
|
|
this.selectedDatesForSchedule.includes(date)? this.selectedDatesForSchedule.splice(this.selectedDatesForSchedule.indexOf(date), 1): this.selectedDatesForSchedule.push(date); |
|
|
|
} |
|
|
|
selectDates(dates: Array<number>) { |
|
|
|
this.selectedDatesForSchedule = dates; |
|
|
|
console.log(this.profile_info) |
|
|
|
} |
|
|
|
|
|
|
|
toggleDates(date: number) { |
|
|
|
this.selectedDatesForSchedule.includes(date) ? this.selectedDatesForSchedule.splice(this.selectedDatesForSchedule.indexOf(date), 1) : this.selectedDatesForSchedule.push(date); |
|
|
|
} |
|
|
|
|
|
|
|
renderCalendar() { |
|
|
|
renderCalendar() { |
|
|
|
// Generate dates for the calendar |
|
|
|
let i = 1, |
|
|
|
no_of_preceeding_days, |
|
|
@@ -100,7 +115,7 @@ export class SchedulesComponent implements OnInit { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
selectNextMonth() { |
|
|
|
selectNextMonth() { |
|
|
|
let next_month_index = (this.monthMap.indexOf(this.selectedMonth) + 1) % this.monthMap.length; |
|
|
|
this.selectedMonth = this.monthMap[next_month_index]; |
|
|
|
if (next_month_index == 0) { |
|
|
@@ -110,7 +125,7 @@ export class SchedulesComponent implements OnInit { |
|
|
|
this.renderCalendar(); |
|
|
|
} |
|
|
|
|
|
|
|
selectPreviousMonth() { |
|
|
|
selectPreviousMonth() { |
|
|
|
let previous_month_index = (this.monthMap.indexOf(this.selectedMonth) + (this.monthMap.length - 1)) % this.monthMap.length; |
|
|
|
this.selectedMonth = this.monthMap[previous_month_index]; |
|
|
|
if (previous_month_index == (this.monthMap.length - 1)) { |
|
|
@@ -120,4 +135,20 @@ export class SchedulesComponent implements OnInit { |
|
|
|
this.renderCalendar(); |
|
|
|
} |
|
|
|
|
|
|
|
scheduleHolidays() { |
|
|
|
|
|
|
|
this.selectedHolidays = []; |
|
|
|
console.log(this.selectedHolidays) |
|
|
|
|
|
|
|
this.outletService.addOutletSchedules(this.outletHoliday).then((data) => { |
|
|
|
console.log(data) |
|
|
|
// this.profile_info.schedules.push(data) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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(); |
|
|
|
} |
|
|
|
} |