Merge pull request 'feat(approvals): update overview and potentially employee details when modify event occurs' (#58) from dev/nicolas/staging-prep into main

Reviewed-on: Targo/targo_frontend#58
This commit is contained in:
Nicolas 2026-01-21 10:56:23 -05:00
commit 81711a9e40

View File

@ -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<string>) => {
console.log('event received: ');
pay_period_observer.value.onmessage = async (event: MessageEvent<string>) => {
// 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'),
})
}