Procházet zdrojové kódy

Interated Holidays with Api --Partial Commit

master
prahalad před 4 roky
rodič
revize
c9fd02b70d
3 změnil soubory, kde provedl 27 přidání a 16 odebrání
  1. +3
    -3
      src/app/schedules/schedules.component.html
  2. +22
    -12
      src/app/schedules/schedules.component.ts
  3. +2
    -1
      src/app/services/outlet.service.ts

+ 3
- 3
src/app/schedules/schedules.component.html Zobrazit soubor

@@ -135,14 +135,14 @@
<input type="text" placeholder="Schedule Title">
<ul>
<li (click)="scheduleType = 'holiday'">
<button class="radio" [ngClass]="{'active' : scheduleType === 'holiday'}"></button>
<button id="holiday" class="radio" [ngClass]="{'active' : scheduleType === 'holiday'}"></button>
<label> Holiday </label>
</li>
<li (click)="scheduleType = 'event'">
<button class="radio" [ngClass]="{'active' : scheduleType === 'event'}"></button> <label> Event </label>
<button id="event" class="radio" [ngClass]="{'active' : scheduleType === 'event'}"></button> <label> Event </label>
</li>
<li (click)="scheduleType = 'change time'">
<button class="radio" [ngClass]="{'active' : scheduleType === 'change time'}"></button> <label> Change Timings </label>
<button id="changeTime" class="radio" [ngClass]="{'active' : scheduleType === 'change time'}"></button> <label> Change Timings </label>
</li>
</ul>
<div class="time-selector" *ngIf="scheduleType === 'change time'">


+ 22
- 12
src/app/schedules/schedules.component.ts Zobrazit soubor

@@ -22,6 +22,7 @@ export class SchedulesComponent implements OnInit {
selectedDatesForSchedule: Array<number> = [];
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<string> = [new Date('2021-10-21T00:00').toString(), new Date('2021-10-22T00:00').toString()];
selectedHolidays: Array<string> = [];

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<number>) {
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();


+ 2
- 1
src/app/services/outlet.service.ts Zobrazit soubor

@@ -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()
}
}

Načítá se…
Zrušit
Uložit