From 388e002dda800ff89ff1d82462bdaf91f1bd365f Mon Sep 17 00:00:00 2001 From: Nic D Date: Wed, 21 Jan 2026 10:55:55 -0500 Subject: [PATCH] feat(approvals): update overview and potentially employee details when modify event occurs --- src/stores/timesheet-store.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/stores/timesheet-store.ts b/src/stores/timesheet-store.ts index f1b5e47..985908b 100644 --- a/src/stores/timesheet-store.ts +++ b/src/stores/timesheet-store.ts @@ -187,19 +187,26 @@ export const useTimesheetStore = defineStore('timesheet', () => { const subscribeToPayPeriodObservable = () => { if (pay_period_observer.value === undefined) { - console.log('subscribing to observable'); pay_period_observer.value = timesheetApprovalService.subscribeToPayPeriodObservable(); - console.log('subscription success: ', pay_period_observer.value); - pay_period_observer.value.onmessage = (event: MessageEvent) => { - console.log('event received: '); + pay_period_observer.value.onmessage = async (event: MessageEvent) => { + // find employee that modified their timesheets const pay_period_event: PayPeriodEvent = JSON.parse(event.data); const overview = pay_period_overviews.value.find(overview => overview.email === pay_period_event.employee_email); const employee_name = overview?.employee_first_name + ' ' + overview?.employee_last_name; + // update overviews + await getTimesheetOverviews(); + + // if user is looking at details of employee that generated event, update + if (selected_employee_name.value === employee_name) + await getTimesheetsByOptionalEmployeeEmail(pay_period_event.employee_email); + + // create visual feedback of notification and update Notify.create({ message: `${employee_name} ${t('timesheet_approvals.event.' + pay_period_event.action)} ${t('timesheet_approvals.event.' + pay_period_event.event_type)}`, color: 'warning', - classes: 'text-weight-bolder text-primary', + textColor: 'primary', + classes: 'text-weight-bolder', caption: t('timesheet_approvals.event.update_notification'), }) }