Skip to content

Commit

Permalink
attempting fixing update vacation
Browse files Browse the repository at this point in the history
  • Loading branch information
maayarosama committed Mar 26, 2024
1 parent 308fa0a commit 5bc1601
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
37 changes: 22 additions & 15 deletions client/src/components/CalenderComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -368,23 +368,30 @@ async function updateVacationStatus(data: string) {
}
async function updateVacation(vacation: Api.Vacation) {
console.log("Vacation: ", vacation);

vacations.value = vacations.value.filter((vacation) => vacation.id !== selectedEvent.value?.id)
if (cached_users.has(vacation.applying_user.id)) {
vacation.applying_user = cached_users.get(vacation.applying_user.id)
} else {
const user = await $api.users.getuser(vacation.applying_user.id, {
disableNotify: true
})
cached_users.set(vacation.applying_user.id, user)
vacation.applying_user = user
}

vacation.isUpdated = true
vacations.value.push(vacation)
closeDialog(CalendarEventSelection.Vacation)
const user = await $api.users.getuser(vacation.applying_user, { disableNotify: true })
// vacation.applying_user = user
// vacation.isUpdated = true
// vacations.value.push(vacation)
// closeDialog(CalendarEventSelection.Vacation)
// if (cached_users.has(vacation.applying_user)) {
// vacation.applying_user = cached_users.get(vacation.applying_user.id)
// console.log(vacation.applying_user)
// }
// else {
// const user = await $api.users.getuser(vacation.applying_user, {
// disableNotify: true
// })
// cached_users.set(vacation.applying_user.id, user)
// vacation.applying_user = user
// }
// vacation.isUpdated = true
// vacations.value.push(vacation)
// closeDialog(CalendarEventSelection.Vacation)
}
async function deleteVacation() {
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/cards/vacationCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<v-form ref="form" @submit.prevent="updateVacation()">

<v-row class="d-flex justify-center my-2" v-if="couldUpdate">
<v-btn color="primary" class="mx-1 my-2" :disabled="!form?.isValid || disabled">Update</v-btn>
<v-btn color="primary" class="mx-1 my-2" type="submit" :disabled="!form?.isValid || disabled">Update</v-btn>
<v-btn color="error" class="mx-1 my-2" @click="handleDelete">Delete</v-btn>
</v-row>
<v-divider class="my-2"></v-divider>
Expand Down

0 comments on commit 5bc1601

Please sign in to comment.