Skip to content

Commit

Permalink
fix: updated employee other settings (#8511)
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul-rocket authored Oct 30, 2024
1 parent 4e2db81 commit bc0d6e3
Showing 1 changed file with 28 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,68 +74,63 @@ export class EditEmployeeOtherSettingsComponent implements OnInit, OnDestroy {
}

/**
* Patches the form with employee data or default values if data is unavailable.
*
* @param employee
* @returns
* @param {IEmployee} employee - The employee object containing user data.
* @returns {void}
*/
private _patchFormValue(employee: IEmployee) {
if (!employee) {
return;
}
const { user } = employee;
private _patchFormValue(employee: IEmployee): void {
if (!employee) return;

const { user, upworkId, linkedInId, allowManualTime, allowDeleteTime, allowModifyTime, allowScreenshotCapture } = employee;
this.form.patchValue({
timeZone: user.timeZone || moment.tz.guess(), // set current timezone, if employee don't have any timezone
timeFormat: user.timeFormat,
upworkId: employee.upworkId,
linkedInId: employee.linkedInId,
allowManualTime: employee.allowManualTime,
allowDeleteTime: employee.allowDeleteTime,
allowModifyTime: employee.allowModifyTime,
allowScreenshotCapture: employee.allowScreenshotCapture
timeZone: user?.timeZone ?? moment.tz.guess(),
timeFormat: user?.timeFormat,
upworkId,
linkedInId,
allowManualTime,
allowDeleteTime,
allowModifyTime,
allowScreenshotCapture
});
this.form.updateValueAndValidity();
}

/**
* Handles the form submission, updating employee and user settings if valid.
*
* @param form
* @returns
* @param {NgForm} form - The form reference for submission.
* @returns {void}
*/
onSubmit(form: NgForm) {
if (form.invalid) {
return;
}
onSubmit(form: NgForm): void {
if (form.invalid) return;

const { organizationId, tenantId } = this.selectedEmployee;
const {
timeZone,
timeFormat,
upworkId,
linkedInId,
allowScreenshotCapture,
allowManualTime,
allowDeleteTime,
allowModifyTime,
allowDeleteTime
allowScreenshotCapture
} = this.form.value;

/** Update user fields */
this.employeeStore.userForm = {
timeZone,
timeFormat
};

/** Update employee fields */
this.employeeStore.employeeForm = {
this.employeeStore.updateUserForm({ timeZone, timeFormat });
this.employeeStore.updateEmployeeForm({
upworkId,
linkedInId,
organizationId,
tenantId,
allowManualTime,
allowModifyTime,
allowDeleteTime,
allowModifyTime,
allowScreenshotCapture
};
});
}


/**
*
*/
Expand Down

0 comments on commit bc0d6e3

Please sign in to comment.