Skip to content

Commit

Permalink
Merge pull request #107 from ymaheshwari1/#101
Browse files Browse the repository at this point in the history
Fixed: logic to not remove associated calendar untill app level checks are not completed(#101)
  • Loading branch information
ravilodhi authored Dec 12, 2023
2 parents 6600cf1 + 4417c1e commit fd7798d
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions src/components/CustomScheduleModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,33 +161,9 @@ export default defineComponent({
this.isDailyTimingsChecked = !this.isDailyTimingsChecked
this.days = this.isDailyTimingsChecked ? ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'] : ['Daily']
},
async saveCustomSchedule() {
if(this.facilityCalendar?.calendarId) {
try {
const resp = await FacilityService.removeFacilityCalendar({
facilityId: this.facilityId,
calendarId: this.facilityCalendar.calendarId,
facilityCalendarTypeId: this.facilityCalendar.facilityCalendarTypeId,
fromDate: this.facilityCalendar.fromDate
})
if(!hasError(resp)) {
await this.addCustomSchedule()
} else {
throw resp.data;
}
} catch(err) {
logger.error(err)
}
} else {
await this.addCustomSchedule()
}
},
async addCustomSchedule() {
let resp;
let calendarId;
async saveCustomSchedule() {
let payload = {} as any
if(this.days.length === 1) {
const days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
const dailyStartTime = DateTime.fromISO(this.selectedTimesForWeek['DailyStartTime'], {setZone: true}).toFormat('HH:mm:ss')
Expand All @@ -214,6 +190,31 @@ export default defineComponent({
return;
}
if(this.facilityCalendar?.calendarId) {
try {
const resp = await FacilityService.removeFacilityCalendar({
facilityId: this.facilityId,
calendarId: this.facilityCalendar.calendarId,
facilityCalendarTypeId: this.facilityCalendar.facilityCalendarTypeId,
fromDate: this.facilityCalendar.fromDate
})
if(!hasError(resp)) {
await this.addCustomSchedule(payload)
} else {
throw resp.data;
}
} catch(err) {
logger.error(err)
}
} else {
await this.addCustomSchedule(payload)
}
},
async addCustomSchedule(payload: any) {
let resp;
let calendarId;
try {
resp = await FacilityService.createFacilityCalendar({ ...payload, description: this.selectedTimesForWeek.description})
if(!hasError(resp)) {
Expand Down

0 comments on commit fd7798d

Please sign in to comment.