From e44d790a21000fc9cba826edc38a484625dd40cf Mon Sep 17 00:00:00 2001 From: "Nic D." <91558719+Venti-Bear@users.noreply.github.com> Date: Mon, 26 Jan 2026 09:52:45 -0500 Subject: [PATCH] fix(timesheet-approval): fix oversight to modify employee timesheet from approval module Fixed an oversight in the logic in one of the steps to update and create shifts from the timesheet approval page, which led to update or create requests being sent with the users credentials instead of the employees --- src/i18n/en-ca/index.ts | 3 ++ src/i18n/fr-ca/index.ts | 3 ++ .../components/timesheet-wrapper.vue | 36 ++++++++++++++----- .../timesheets/composables/use-shift-api.ts | 6 ++-- src/stores/shift-store.ts | 3 +- 5 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/i18n/en-ca/index.ts b/src/i18n/en-ca/index.ts index e7514ce..f256e88 100644 --- a/src/i18n/en-ca/index.ts +++ b/src/i18n/en-ca/index.ts @@ -224,6 +224,7 @@ export default { error: { no_data_found: "no data found", no_search_results: "no results matching search", + generic_error: "An error occured", }, label: { search: "search", @@ -284,6 +285,7 @@ export default { apply_preset: "auto-fill", apply_preset_day: "Apply schedule to day", apply_preset_week: "Apply schedule to week", + save_successful: "timesheets saved", nav_button: { calendar_date_picker: "Calendar", current_week: "This week", @@ -359,6 +361,7 @@ export default { SHIFT_TYPE_REQUIRED: "Shift type required", TIMESHEET_NOT_FOUND: "No timesheet found with provided data", UPDATE_ERROR: "Error while updating data", + ERROR_SAVING_SHIFTS: "Timesheet changes were not saved", }, }, diff --git a/src/i18n/fr-ca/index.ts b/src/i18n/fr-ca/index.ts index 13c402c..8ab3e7c 100644 --- a/src/i18n/fr-ca/index.ts +++ b/src/i18n/fr-ca/index.ts @@ -224,6 +224,7 @@ export default { error: { no_data_found: 'aucune donnée à afficher', no_search_results: 'aucun résultat ne correspond à la recherche', + generic_error: "Une erreur est survenue", }, label: { search: 'recherche', @@ -284,6 +285,7 @@ export default { apply_preset: "auto-remplir", apply_preset_day: "Appliquer horaire pour la journée", apply_preset_week: "Appliquer horaire pour la semaine", + save_successful: "feuilles de temps enregistrées", nav_button: { calendar_date_picker: "Calendrier", current_week: "Semaine actuelle", @@ -359,6 +361,7 @@ export default { SHIFT_TYPE_REQUIRED: "Type requis", TIMESHEET_NOT_FOUND: "Aucune feuille de temps ne correspond au détails fournis", UPDATE_ERROR: "Une erreur est survenu lors de la mise à jour", + ERROR_SAVING_SHIFTS: "les changements aux feuilles de temps n'ont pas été enregistrés", }, }, diff --git a/src/modules/timesheets/components/timesheet-wrapper.vue b/src/modules/timesheets/components/timesheet-wrapper.vue index 00318ba..1acb3ba 100644 --- a/src/modules/timesheets/components/timesheet-wrapper.vue +++ b/src/modules/timesheets/components/timesheet-wrapper.vue @@ -2,7 +2,6 @@ setup lang="ts" > - /* eslint-disable */ import ShiftList from 'src/modules/timesheets/components/shift-list.vue'; import ShiftListScrollable from 'src/modules/timesheets/components/shift-list-scrollable.vue'; import LoadingOverlay from 'src/modules/shared/components/loading-overlay.vue'; @@ -13,14 +12,15 @@ import ShiftListWeeklyOverview from 'src/modules/timesheets/components/shift-list-weekly-overview.vue'; import ShiftListWeeklyOverviewMobile from 'src/modules/timesheets/components/mobile/shift-list-weekly-overview-mobile.vue'; + import { useI18n } from 'vue-i18n'; import { computed, onMounted } from 'vue'; import { useShiftApi } from 'src/modules/timesheets/composables/use-shift-api'; import { useTimesheetApi } from 'src/modules/timesheets/composables/use-timesheet-api'; import { useExpensesStore } from 'src/stores/expense-store'; import { useTimesheetStore } from 'src/stores/timesheet-store'; - import { date } from 'quasar'; - + import { date, Notify } from 'quasar'; + const { t } = useI18n(); const expenses_store = useExpensesStore(); const timesheet_store = useTimesheetStore(); const timesheet_api = useTimesheetApi(); @@ -41,13 +41,25 @@ sum + timesheet.weekly_expenses.expenses + timesheet.weekly_expenses.on_call + timesheet.weekly_expenses.per_diem, - 0) //initial value - ); + 0 //initial value + )); const { mode = 'normal' } = defineProps<{ mode?: 'approval' | 'normal'; }>(); + const onClickSaveTimesheets = async () => { + if (mode === 'normal') { + await shift_api.saveShiftChanges(); + Notify.create({ + message: t('timesheet.save_successful'), + color: 'accent', + }); + } else { + await shift_api.saveShiftChanges(timesheet_store.current_pay_period_overview?.email); + } + } + onMounted(async () => { if (mode === 'normal') await timesheet_api.getTimesheetsByDate(date.formatDate(new Date(), 'YYYY-MM-DD')); @@ -97,7 +109,10 @@ v-if="!$q.platform.is.mobile" class="col-xs-6 col-md-4 col-xl-3 q-pa-md" > - + @@ -116,7 +131,10 @@ /> -
+
@@ -204,7 +222,7 @@ :label="$t('shared.label.save')" class="col-auto absolute-bottom shadow-up-10" style="height: 50px;" - @click="shift_api.saveShiftChanges" + @click="onClickSaveTimesheets" /> { timesheet_store.is_loading = false; }; - const saveShiftChanges = async () => { + const saveShiftChanges = async (employee_email?: string) => { timesheet_store.is_loading = true; - const update_success = await shift_store.updateShifts(); - const create_success = await shift_store.createNewShifts(); + const update_success = await shift_store.updateShifts(employee_email); + const create_success = await shift_store.createNewShifts(employee_email); if (create_success || update_success){ await timesheet_store.getTimesheetsByOptionalEmployeeEmail(auth_store.user?.email ?? ''); diff --git a/src/stores/shift-store.ts b/src/stores/shift-store.ts index f2f62f9..db4ede5 100644 --- a/src/stores/shift-store.ts +++ b/src/stores/shift-store.ts @@ -53,8 +53,7 @@ export const useShiftStore = defineStore('shift_store', () => { return true; } } - - Notify.create('No shifts to update') + return false; } catch (error) { Notify.create('Error updating shifts');