feat(approvals): update overview and potentially employee details when modify event occurs
This commit is contained in:
parent
121b09bbe0
commit
388e002dda
|
|
@ -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'),
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user