diff --git a/src/app/app.module.ts b/src/app/app.module.ts index d960aeb65..f0cc282d2 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -91,10 +91,10 @@ import { EmployeeApprovalsComponent } from './components/hris/employees/employee import { TopNavComponent } from './components/hris/nav-bar/types/top-nav/top-nav.component'; import { SideNavComponent } from './components/hris/nav-bar/types/side-nav/side-nav.component'; import { CareerSummaryQualificationsComponent } from './components/hris/employees/employee-profile/accordions/accordion-career-summary/accordion-career-summary-qualifications/accordion-career-summary-qualifications.component'; -import { AccordionEmployeeDocumentsComponent } from './components/hris/employees/employee-profile/accordions/accordion-employee-documents/accordion-employee-documents.component'; +import { AccordionEmployeeDocumentsComponent } from './components/hris/employees/employee-profile/accordions/accordion-documents/accordion-employee-documents/accordion-employee-documents.component'; import { AccordionDocumentsCustomDocumentsComponent } from './components/hris/employees/employee-profile/accordions/accordion-documents/accordion-additional-documents/accordion-additional-documents.component'; import { AccordionCertificatesComponent } from './components/hris/employees/employee-profile/accordions/accordion-career-summary/accordion-certificates/accordion-certificates.component'; -import { AccordionAdministrativeDocumentsComponent } from './components/hris/employees/employee-profile/accordions/accordion-administrative-documents/accordion-administrative-documents.component'; +import { AccordionAdministrativeDocumentsComponent } from './components/hris/employees/employee-profile/accordions/accordion-documents/accordion-administrative-documents/accordion-administrative-documents.component'; import { AccordionCareerAdditionalInformationComponent } from './components/hris/employees/employee-profile/accordions/accordion-profile/accordion-career-additional-information/accordion-career-additional-information.component'; import { AccordionCareerWorkExperienceComponent } from './components/hris/employees/employee-profile/accordions/accordion-career-summary/accordion-career-work-experience/accordion-career-work-experience.component'; import { AccordionSalaryDetailsComponent } from './components/hris/employees/employee-profile/accordions/accordion-career-summary/accordion-salary-details/accordion-salary-details.component'; diff --git a/src/app/components/hris/charts/charts.component.ts b/src/app/components/hris/charts/charts.component.ts index 47b99610d..b9083d937 100644 --- a/src/app/components/hris/charts/charts.component.ts +++ b/src/app/components/hris/charts/charts.component.ts @@ -9,7 +9,7 @@ import { ChartType } from 'chart.js'; import ChartDataLabels from 'chartjs-plugin-datalabels' import { Renderer2, Inject } from '@angular/core'; import { DOCUMENT } from '@angular/common'; -import { EmployeeProfile } from 'src/app/models/hris/employee-profile.interface'; +import { EmployeeFilterView } from 'src/app/models/hris/employee-filter-view.interface'; import { EmployeeService } from 'src/app/services/hris/employee/employee.service'; import { EmployeeType } from 'src/app/models/hris/constants/employeeTypes.constants'; import { Chart } from 'chart.js'; @@ -207,7 +207,7 @@ export class ChartComponent implements OnInit { fetchPeopleChampionEmployees() { this.employeeService.filterEmployees(0, EmployeeType.PeopleChampion).subscribe({ - next: (employees: EmployeeProfile[]) => { + next: (employees: EmployeeFilterView[]) => { employees.forEach((employee) => { if (employee.id) { this.employeeNames[employee.id] = `${employee.name} ${employee.surname}`; diff --git a/src/app/components/hris/employees/employee-profile/accordions-documents/accordion-starter-kit-documents/accordion-documents.component.css b/src/app/components/hris/employees/employee-profile/accordions-documents/accordion-starter-kit-documents/accordion-documents.component.css deleted file mode 100644 index 343648132..000000000 --- a/src/app/components/hris/employees/employee-profile/accordions-documents/accordion-starter-kit-documents/accordion-documents.component.css +++ /dev/null @@ -1,132 +0,0 @@ -#actionCellDownload>button { - border: 1px solid #0029C6; - border-radius: 2rem; - background-color: white; - color: #0029C6; - padding: 0.5rem; - width: 8rem; -} - -#actionCellUpload>button { - background: #0029c6; - border: none; - border-radius: 4rem; - color: white; - padding: 0.5rem; - width: 8rem; -} - -#header-cell { - color: black; - font-size: 16px; - font-family: Roboto; - font-weight: 500; - line-height: 24px; - letter-spacing: 0.15px; - word-wrap: break-word; - padding-left: 2rem; -} - -#table { - background: #fdfdfe; -} - -#table-header { - background: #D7DFFF; - border-top-right-radius: 2rem; - border-top-left-radius: 2rem; -} - -#header-header>div { - color: black; - font-size: 16px; - font-family: Roboto; - font-weight: 500; - line-height: 24px; - letter-spacing: 0.15px; -} - -#document-row { - border-radius: 20px; - border: 1px solid var(--M3-sys-light-outline-variant, #CAC4D0); - background: var(--M3-white, #FFF); -} - -#fileName { - color: grey; -} - -#svg-icon-w #icon-w { - fill: white; -} - -#actionCellDownload>button.disabledDownload { - border: 1px solid #e3e3e4ff; - border-radius: 2rem; - background-color: #e3e3e4ff; - color: #ffffff; - padding: 0.5rem; - width: 8rem; -} - -:host .upload-download-button { - width: 100%!important; -} - -.spinner-container { - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; - background-color: rgba(0, 0, 0, 0.3); - z-index: 9999; - display: flex; - justify-content: center; - align-items: center; -} - -.mat-mdc-progress-spinner { - --mdc-circular-progress-active-indicator-color: #0029C6 !important; -} -.row { - margin-left: 20px; - margin-right: 20px; -} - -#status-0 { - background-color: #008000; - position: relative; - right: 5px; - margin-right: 15px; - float: right; - justify-content: flex-end; - align-items: flex-end; -} - -#status-1 { - background: #ff0000; - position: relative; - right: 5px; - margin-right: 15px; - float: right; - justify-content: flex-end; - align-items: flex-end; - padding-right: 40px; - width: 20%; -} - -#status-2 { - background: #808080; - position: relative; - right: 5px; - margin-right: 15px; - float: right; - justify-content: flex-end; - align-items: flex-end; -} - -#accordion { - margin-right: -2%; - margin-left: -2%; -} diff --git a/src/app/components/hris/employees/employee-profile/accordions-documents/accordion-starter-kit-documents/accordion-documents.component.html b/src/app/components/hris/employees/employee-profile/accordions-documents/accordion-starter-kit-documents/accordion-documents.component.html deleted file mode 100644 index 0fb8f4a18..000000000 --- a/src/app/components/hris/employees/employee-profile/accordions-documents/accordion-starter-kit-documents/accordion-documents.component.html +++ /dev/null @@ -1,117 +0,0 @@ -
- - - - - - Starter Kit Documents - - - errorMissing Information - - - -
-
-
-

Document

-
-
-

Action

-
-
-

Status

-
-
-
-
-
-

{{category}}

-
-

{{document.fileName}}

-
- -

Download & Upload Document Here

-
-
-
-
-
- - - - -
-
- -
- -
-
-
-
-
- {{ 'Approved' }} -
-
- {{ 'Rejected' }} -
-
- {{ 'Pending Approval' }} -
-
- {{ 'Action Required' }} -
-
- -
- {{ 'Awaiting Documents' }} -
-
-
-
-
{{document.reason}}
-
-
-
-
-
-
-
- -
-
\ No newline at end of file diff --git a/src/app/components/hris/employees/employee-profile/accordions-documents/accordion-starter-kit-documents/accordion-documents.component.spec.ts b/src/app/components/hris/employees/employee-profile/accordions-documents/accordion-starter-kit-documents/accordion-documents.component.spec.ts deleted file mode 100644 index 4d1a37c71..000000000 --- a/src/app/components/hris/employees/employee-profile/accordions-documents/accordion-starter-kit-documents/accordion-documents.component.spec.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { AccordionDocumentsComponent } from './accordion-documents.component'; - -describe('AccordionDocumentsComponent', () => { - let component: AccordionDocumentsComponent; - let fixture: ComponentFixture; - - beforeEach(() => { - TestBed.configureTestingModule({ - declarations: [AccordionDocumentsComponent] - }); - fixture = TestBed.createComponent(AccordionDocumentsComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/components/hris/employees/employee-profile/accordions-documents/accordion-starter-kit-documents/accordion-documents.component.ts b/src/app/components/hris/employees/employee-profile/accordions-documents/accordion-starter-kit-documents/accordion-documents.component.ts deleted file mode 100644 index 94a38bf20..000000000 --- a/src/app/components/hris/employees/employee-profile/accordions-documents/accordion-starter-kit-documents/accordion-documents.component.ts +++ /dev/null @@ -1,281 +0,0 @@ -import { Component, EventEmitter, HostListener, Input, Output } from '@angular/core'; -import { EmployeeDocument } from 'src/app/models/hris/employeeDocument.interface'; -import { EmployeeDocumentService } from 'src/app/services/hris/employee/employee-document.service'; -import { Document } from 'src/app/models/hris/constants/documents.contants'; -import { EmployeeProfile } from 'src/app/models/hris/employee-profile.interface'; -import { ActivatedRoute } from '@angular/router'; -import { SnackbarService } from 'src/app/services/shared-services/snackbar-service/snackbar.service'; -import { MatTableDataSource } from '@angular/material/table'; -import { CookieService } from 'ngx-cookie-service'; -import { AuthAccessService } from 'src/app/services/shared-services/auth-access/auth-access.service'; -import { NavService } from 'src/app/services/shared-services/nav-service/nav.service'; - -@Component({ - selector: 'app-accordion-documents-starterkit', - templateUrl: './accordion-documents.component.html', - styleUrls: ['./accordion-documents.component.css'] -}) -export class AccordionDocumentsComponent { - @Output() updateDocument = new EventEmitter(); - @Input() employeeProfile!: EmployeeProfile; - - screenWidth = window.innerWidth; - - @HostListener('window:resize', ['$event']) - onResize() { - this.screenWidth = window.innerWidth; - } - - selectedEmployee!: EmployeeProfile; - fileCategories = Document; - documentFormProgress: number = 0; - documentsProgress: number = 0; - employeeDocuments: EmployeeDocument[] = []; - documentsFileName: string = ""; - base64String: string = ""; - uploadButtonIndex: number = 0; - employeeId = this.route.snapshot.params['id']; - previousPage: string = ''; - PREVIOUS_PAGE = "previousPage"; - showBackButtons: boolean = true; - dataSource = new MatTableDataSource(); - selectedFile !: File; - roles: string[] = []; - isLoadingUpload: boolean = false; - - constructor( - private employeeDocumentService: EmployeeDocumentService, - private route: ActivatedRoute, - private snackBarService: SnackbarService, - private cookieService: CookieService, - private authAccessService: AuthAccessService, - public navService: NavService, - ) { } - - ngOnInit() { - this.getEmployeeDocuments(); - const types: string = this.cookieService.get('userType'); - this.roles = Object.keys(JSON.parse(types)); - } - - openFileInput() { - const fileInput = document.getElementById('fileUpload') as HTMLInputElement; - fileInput.click(); - } - - downloadFile(base64String: string, fileName: string) { - const commaIndex = base64String.indexOf(','); - if (commaIndex !== -1) { - base64String = base64String.slice(commaIndex + 1); - } - - const byteString = atob(base64String); - const arrayBuffer = new ArrayBuffer(byteString.length); - const intArray = new Uint8Array(arrayBuffer); - - for (let i = 0; i < byteString.length; i++) { - intArray[i] = byteString.charCodeAt(i); - } - - const blob = new Blob([arrayBuffer], { type: 'application/pdf' }); - const link = document.createElement('a'); - link.href = window.URL.createObjectURL(blob); - link.download = fileName; - link.click(); - } - - captureUploadIndex(event: any) { - this.uploadButtonIndex = event.srcElement.parentElement.id; - const inputField = document.getElementById(`${this.uploadButtonIndex}-document`) as HTMLInputElement; - inputField.click(); - } - - uploadDocument(event: any) { - this.isLoadingUpload = true; - this.selectedFile = event.target.files[0]; - this.documentsFileName = this.selectedFile.name; - this.uploadProfileDocument(); - } - - uploadProfileDocument() { - if (this.selectedFile) { - const reader = new FileReader(); - reader.onload = () => { - this.buildDocumentDto(); - }; - reader.readAsDataURL(this.selectedFile); - } - } - - getEmployeeDocuments() { - if (this.employeeId != undefined) { - this.employeeDocumentService.getAllEmployeeDocuments(this.employeeProfile.id as number, 0).subscribe({ - next: data => { - this.employeeDocuments = data; - this.dataSource.data = this.fileCategories; - this.calculateDocumentProgress(); - }, - error: error => { - this.snackBarService.showSnackbar("Unable to Retrieve Starter Kit Documents", "snack-error"); - } - }) - } else { - this.employeeId = this.navService.employeeProfile.id; - this.employeeDocumentService.getAllEmployeeDocuments(this.employeeId, 0).subscribe({ - next: data => { - this.employeeDocuments = data; - this.dataSource.data = this.fileCategories; - this.calculateDocumentProgress(); - }, - error: error => { - this.snackBarService.showSnackbar("Unable to Retrieve Starter Kit Documents", "snack-error"); - } - }) - } - - } - - uploadDocumentDto(document: any) { - const saveObj = { - id: document.id, - employeeId: document.employee.id, - fileName: document.fileName, - blob: this.base64String, - fileCategory: document.fileCategory, - uploadDate: document.uploadDate, - status: 1, - documentType: 0 - } - if (document.id == 0) { - this.employeeDocumentService.saveEmployeeDocument(saveObj, 0).subscribe({ - next: () => { - this.isLoadingUpload = false; - this.snackBarService.showSnackbar("Saved", "snack-success"); - this.getEmployeeDocuments(); - this.calculateDocumentProgress(); - }, - error: (error) => { - this.isLoadingUpload = false; - this.snackBarService.showSnackbar("Unable to Save Document", "snack-error"); - } - }); - } else { - const updatedDocument = { - id: document.id, - employeeId: document.employee.id, - reference: document.reference, - fileName: document.fileName, - fileCategory: document.fileCategory, - blob: document.blob, - uploadDate: document.uploadDate, - reason: document.reason, - status: 1, - counterSign: false, - documentType: 0, - lastUpdatedDate: document.lastUpdatedDate - } - this.employeeDocumentService.updateEmployeeDocument(updatedDocument).subscribe({ - next: () => { - this.isLoadingUpload = false; - this.snackBarService.showSnackbar("Updated", "snack-success"); - this.getEmployeeDocuments(); - this.calculateDocumentProgress(); - - }, - error: (error) => { - this.snackBarService.showSnackbar("Unable to Update Document", "snack-error"); - this.isLoadingUpload = false; - } - }); - } - } - - buildDocumentDto() { - const existingValue = this.filterDocumentsByCategory(); - if (this.selectedFile) { - const reader = new FileReader(); - reader.onload = () => { - this.base64String = reader.result as string; - var newDto: {} = { - id: existingValue != undefined ? existingValue?.id as number : 0, - employee: this.employeeProfile, - reference: "", - fileName: this.documentsFileName, - fileCategory: +this.uploadButtonIndex, - blob: this.base64String, - status: 1, - uploadDate: new Date(), - reason: '', - counterSign: false, - documentType: 0, - lastUpdatedDate: new Date() - }; - this.uploadDocumentDto(newDto); - - }; - reader.readAsDataURL(this.selectedFile); - } - } - - filterDocumentsByCategory(): EmployeeDocument | null { - var object = this.employeeDocuments.filter(document => document.fileCategory == this.uploadButtonIndex); - if (object == null) { - return null; - } - return object[0]; - } - - getFileName(index: number): EmployeeDocument { - var documentObject = this.employeeDocuments.find(document => document.fileCategory == index) as EmployeeDocument; - return documentObject; - } - - downloadDocument(event: any) { - const id = event.srcElement.parentElement.id; - const documentObject = this.employeeDocuments.find(document => document.fileCategory == id) as any; - if (documentObject === undefined) { - // TODO: download clean slate form - } - else { - if (documentObject.status == 2) { - // TODO: download clean slate form - } else { - this.downloadFile(documentObject?.blob as string, documentObject?.fileName as string); - } - } - } - - disableUploadButton(index: number): boolean { - const documentObject = this.employeeDocuments.find(document => document.fileCategory == index); - if (this.authAccessService.isEmployee()) { - return false; - } - else if (documentObject == null && (this.authAccessService.isAdmin() || this.authAccessService.isSuperAdmin())) { - return false; - } - else if (documentObject?.status as number > 1) { - if (this.authAccessService.isAdmin() || this.authAccessService.isSuperAdmin()) { - return false; - } - } - return true; - } - - calculateDocumentProgress() { - const total = this.fileCategories.length; - const fetchedDocuments = this.employeeDocuments.filter(document => document.status == 0).length; - this.documentFormProgress = fetchedDocuments / total * 100; - this.updateDocument.emit(this.documentFormProgress); - } - - disableDownload(index: number) { - const documentObject = this.employeeDocuments.find(document => document.fileCategory == index); - - if (documentObject == undefined) - return false; - - if (documentObject?.status == 0 || documentObject?.status == 1) - return false; - return true; - } -} diff --git a/src/app/components/hris/employees/employee-profile/accordions/accordion-career-summary/accordion-salary-details/accordion-salary-details.component.html b/src/app/components/hris/employees/employee-profile/accordions/accordion-career-summary/accordion-salary-details/accordion-salary-details.component.html index c81f59cf3..ed643ee4c 100644 --- a/src/app/components/hris/employees/employee-profile/accordions/accordion-career-summary/accordion-salary-details/accordion-salary-details.component.html +++ b/src/app/components/hris/employees/employee-profile/accordions/accordion-career-summary/accordion-salary-details/accordion-salary-details.component.html @@ -52,6 +52,9 @@

Tax Number is required + + Tax Number is incorrect + diff --git a/src/app/components/hris/employees/employee-profile/accordions/accordion-career-summary/accordion-salary-details/accordion-salary-details.component.ts b/src/app/components/hris/employees/employee-profile/accordions/accordion-career-summary/accordion-salary-details/accordion-salary-details.component.ts index efffcc9a5..5ede5065b 100644 --- a/src/app/components/hris/employees/employee-profile/accordions/accordion-career-summary/accordion-salary-details/accordion-salary-details.component.ts +++ b/src/app/components/hris/employees/employee-profile/accordions/accordion-career-summary/accordion-salary-details/accordion-salary-details.component.ts @@ -62,14 +62,14 @@ export class AccordionSalaryDetailsComponent { if (salaryDetails != null) { this.sharedAccordionFunctionality.salaryDetailsForm = this.fb.group({ remuneration: [salaryDetails.remuneration, [Validators.required, Validators.pattern(/^[0-9]*$/)]], - taxNumber: [this.employeeProfile!.taxNumber, [Validators.required]] + taxNumber: [this.employeeProfile!.taxNumber, [Validators.required, Validators.pattern(/^[01239]\d{9}$/)]] }); this.getSalaryDate(); } else { this.sharedAccordionFunctionality.salaryDetailsForm = this.fb.group({ remuneration: ["", [Validators.required, Validators.pattern(/^[0-9]*$/)]], - taxNumber: ["", [Validators.required]] + taxNumber: ["", [Validators.required, Validators.pattern(/^[01239]\d{9}$/)]] }); } this.sharedAccordionFunctionality.salaryDetailsForm.disable(); @@ -221,8 +221,11 @@ export class AccordionSalaryDetailsComponent { else if (salaryDetailsFormValue.remuneration < 0) { this.snackBarService.showSnackbar("Remuneration Cannot Be Less Than Zero", "snack-error"); } + else if (salaryDetailsFormValue.taxNumber < 0) { + this.snackBarService.showSnackbar("Tax Number Cannot Be Empty", "snack-error"); + } else { - this.snackBarService.showSnackbar("Please Enter the Correct Remuneration", "snack-error"); + this.snackBarService.showSnackbar("Please Enter the Correct Information", "snack-error"); } } diff --git a/src/app/components/hris/employees/employee-profile/accordions/accordion-administrative-documents/accordion-administrative-documents.component.css b/src/app/components/hris/employees/employee-profile/accordions/accordion-documents/accordion-administrative-documents/accordion-administrative-documents.component.css similarity index 100% rename from src/app/components/hris/employees/employee-profile/accordions/accordion-administrative-documents/accordion-administrative-documents.component.css rename to src/app/components/hris/employees/employee-profile/accordions/accordion-documents/accordion-administrative-documents/accordion-administrative-documents.component.css diff --git a/src/app/components/hris/employees/employee-profile/accordions/accordion-administrative-documents/accordion-administrative-documents.component.html b/src/app/components/hris/employees/employee-profile/accordions/accordion-documents/accordion-administrative-documents/accordion-administrative-documents.component.html similarity index 100% rename from src/app/components/hris/employees/employee-profile/accordions/accordion-administrative-documents/accordion-administrative-documents.component.html rename to src/app/components/hris/employees/employee-profile/accordions/accordion-documents/accordion-administrative-documents/accordion-administrative-documents.component.html diff --git a/src/app/components/hris/employees/employee-profile/accordions/accordion-administrative-documents/accordion-administrative-documents.component.ts b/src/app/components/hris/employees/employee-profile/accordions/accordion-documents/accordion-administrative-documents/accordion-administrative-documents.component.ts similarity index 100% rename from src/app/components/hris/employees/employee-profile/accordions/accordion-administrative-documents/accordion-administrative-documents.component.ts rename to src/app/components/hris/employees/employee-profile/accordions/accordion-documents/accordion-administrative-documents/accordion-administrative-documents.component.ts diff --git a/src/app/components/hris/employees/employee-profile/accordions/accordion-employee-documents/accordion-employee-documents.component.css b/src/app/components/hris/employees/employee-profile/accordions/accordion-documents/accordion-employee-documents/accordion-employee-documents.component.css similarity index 100% rename from src/app/components/hris/employees/employee-profile/accordions/accordion-employee-documents/accordion-employee-documents.component.css rename to src/app/components/hris/employees/employee-profile/accordions/accordion-documents/accordion-employee-documents/accordion-employee-documents.component.css diff --git a/src/app/components/hris/employees/employee-profile/accordions/accordion-employee-documents/accordion-employee-documents.component.html b/src/app/components/hris/employees/employee-profile/accordions/accordion-documents/accordion-employee-documents/accordion-employee-documents.component.html similarity index 100% rename from src/app/components/hris/employees/employee-profile/accordions/accordion-employee-documents/accordion-employee-documents.component.html rename to src/app/components/hris/employees/employee-profile/accordions/accordion-documents/accordion-employee-documents/accordion-employee-documents.component.html diff --git a/src/app/components/hris/employees/employee-profile/accordions/accordion-employee-documents/accordion-employee-documents.component.ts b/src/app/components/hris/employees/employee-profile/accordions/accordion-documents/accordion-employee-documents/accordion-employee-documents.component.ts similarity index 100% rename from src/app/components/hris/employees/employee-profile/accordions/accordion-employee-documents/accordion-employee-documents.component.ts rename to src/app/components/hris/employees/employee-profile/accordions/accordion-documents/accordion-employee-documents/accordion-employee-documents.component.ts diff --git a/src/app/components/hris/employees/employee-profile/accordions/accordion-profile/accordion-profile-personal-details/accordion-profile-personal-details.component.html b/src/app/components/hris/employees/employee-profile/accordions/accordion-profile/accordion-profile-personal-details/accordion-profile-personal-details.component.html index e53d6f56b..b420cad7c 100644 --- a/src/app/components/hris/employees/employee-profile/accordions/accordion-profile/accordion-profile-personal-details/accordion-profile-personal-details.component.html +++ b/src/app/components/hris/employees/employee-profile/accordions/accordion-profile/accordion-profile-personal-details/accordion-profile-personal-details.component.html @@ -41,13 +41,19 @@

Country of Birth - - + + {{ country }} + +
Nationality - + + {{ country }} +
diff --git a/src/app/components/hris/employees/employee-profile/accordions/accordion-profile/accordion-profile-personal-details/accordion-profile-personal-details.component.ts b/src/app/components/hris/employees/employee-profile/accordions/accordion-profile/accordion-profile-personal-details/accordion-profile-personal-details.component.ts index 5562754d7..ad59a3d1f 100644 --- a/src/app/components/hris/employees/employee-profile/accordions/accordion-profile/accordion-profile-personal-details/accordion-profile-personal-details.component.ts +++ b/src/app/components/hris/employees/employee-profile/accordions/accordion-profile/accordion-profile-personal-details/accordion-profile-personal-details.component.ts @@ -8,6 +8,7 @@ import { AuthAccessService } from 'src/app/services/shared-services/auth-access/ import { SnackbarService } from 'src/app/services/shared-services/snackbar-service/snackbar.service'; import { SharedAccordionFunctionality } from '../../../shared-accordion-functionality'; import { PropertyAccessLevel } from 'src/app/models/hris/constants/enums/property-access-levels.enum'; +import { LocationApiService } from 'src/app/services/hris/location-api.service'; @Component({ selector: 'app-accordion-profile-personal-details', @@ -17,6 +18,7 @@ import { PropertyAccessLevel } from 'src/app/models/hris/constants/enums/propert export class AccordionProfilePersonalDetailsComponent { screenWidth = window.innerWidth; + countries: string[] = []; @HostListener('window:resize', ['$event']) usingProfile: boolean = true; @@ -27,6 +29,7 @@ export class AccordionProfilePersonalDetailsComponent { ngOnInit() { this.usingProfile = this.employeeProfile!.simpleEmployee == undefined; this.initializeForm(); + this.loadCountries(); } @Input() employeeProfile!: { employeeDetails: EmployeeProfile, simpleEmployee: SimpleEmployee } @@ -36,8 +39,8 @@ export class AccordionProfilePersonalDetailsComponent { gender: [this.employeeProfile!.employeeDetails.gender, Validators.required], race: [this.employeeProfile!.employeeDetails.race, Validators.required], disability: [this.employeeProfile!.employeeDetails.disability, Validators.required], - nationality: [this.employeeProfile!.employeeDetails.nationality], - countryOfBirth: [this.employeeProfile!.employeeDetails.countryOfBirth], + nationality: [this.employeeProfile!.employeeDetails.nationality, Validators.required], + countryOfBirth: [this.employeeProfile!.employeeDetails.countryOfBirth, Validators.required], disabilityList: "", disabilityNotes: [this.employeeProfile!.employeeDetails.disabilityNotes] @@ -55,8 +58,8 @@ export class AccordionProfilePersonalDetailsComponent { private snackBarService: SnackbarService, public authAccessService: AuthAccessService, public sharedPropertyAccessService: SharedPropertyAccessService, - public sharedAccordionFunctionality: SharedAccordionFunctionality) { - } + public sharedAccordionFunctionality: SharedAccordionFunctionality, + public locationApiService: LocationApiService) { } checkEmployeeDetails() { if (this.usingProfile) @@ -154,6 +157,12 @@ export class AccordionProfilePersonalDetailsComponent { this.sharedAccordionFunctionality.personalDetailsForm.disable(); } + loadCountries(): void { + this.locationApiService.getCountries().subscribe({ + next: (data) => this.countries = data + }); + } + checkPropertyPermissions(fieldNames: string[], table: string, initialLoad: boolean): void { if (!this.sharedPropertyAccessService.accessProperties) { return; diff --git a/src/app/components/hris/employees/employee-profile/employee-profile.component.ts b/src/app/components/hris/employees/employee-profile/employee-profile.component.ts index 13f2be243..8e18ebaf9 100644 --- a/src/app/components/hris/employees/employee-profile/employee-profile.component.ts +++ b/src/app/components/hris/employees/employee-profile/employee-profile.component.ts @@ -26,8 +26,8 @@ import { Clipboard } from '@angular/cdk/clipboard'; import { SharedAccordionFunctionality } from './shared-accordion-functionality'; import { EmployeeDataService } from 'src/app/services/hris/employee/employee-data.service'; import { AccordionDocumentsAdditionalComponent } from './accordions/accordion-documents/accordion-my-documents/accordion-my-documents.component'; -import { AccordionAdministrativeDocumentsComponent } from './accordions/accordion-administrative-documents/accordion-administrative-documents.component'; -import { AccordionEmployeeDocumentsComponent } from './accordions/accordion-employee-documents/accordion-employee-documents.component'; +import { AccordionAdministrativeDocumentsComponent } from './accordions/accordion-documents/accordion-administrative-documents/accordion-administrative-documents.component'; +import { AccordionEmployeeDocumentsComponent } from './accordions/accordion-documents/accordion-employee-documents/accordion-employee-documents.component'; import { CustomField } from 'src/app/models/hris/custom-field.interface'; import { AppModule } from 'src/app/app.module'; import { EmployeeTerminationService } from 'src/app/services/hris/employee/employee-termination.service'; diff --git a/src/app/components/hris/employees/employee-termination/employee-termination.component.css b/src/app/components/hris/employees/employee-termination/employee-termination.component.css index 64351bd78..d56abd645 100644 --- a/src/app/components/hris/employees/employee-termination/employee-termination.component.css +++ b/src/app/components/hris/employees/employee-termination/employee-termination.component.css @@ -185,4 +185,8 @@ p { .warning-message { color: #B3261E; font-weight: bold; +} + +.custom-validate-error { + color: #f44336; } \ No newline at end of file diff --git a/src/app/components/hris/employees/employee-termination/employee-termination.component.html b/src/app/components/hris/employees/employee-termination/employee-termination.component.html index eddfd1138..c521dd8a8 100644 --- a/src/app/components/hris/employees/employee-termination/employee-termination.component.html +++ b/src/app/components/hris/employees/employee-termination/employee-termination.component.html @@ -15,51 +15,53 @@

End Employment

(onSelectionChange)="setTerminationOption(i)">{{termination}} - Please select terminationOption + Please select a termination option + Date of Notice - Start date is required + Please select a day of notice + Last Day of Employment + formControlName="lastDayOfEmployment" [matDatepickerFilter]="endDateFilter"> - Please select Last day of employment + Please select the last day of employment +
+ *The last day of employment cannot be before the day of notice +
+
-

Is this person eligible for reemployment?

+

Is This Person Eligible for Re-Employment?

Yes
No
- Please enter a valid Cellphone number + Please select an option
-

Off-boarding tasks

+ +

Off-Boarding Tasks

Handed Back Company Equipment
Transferred Company Accounts - -
You need to select both of the above
-
- error -
-
+
@@ -94,7 +96,7 @@

Exit interview document*

- Additional comments + Additional Comments diff --git a/src/app/components/hris/employees/employee-termination/employee-termination.component.ts b/src/app/components/hris/employees/employee-termination/employee-termination.component.ts index ba68b6c9e..8c6204081 100644 --- a/src/app/components/hris/employees/employee-termination/employee-termination.component.ts +++ b/src/app/components/hris/employees/employee-termination/employee-termination.component.ts @@ -1,5 +1,5 @@ import { Component, HostListener, Input, OnInit } from '@angular/core'; -import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; +import { FormBuilder, FormControl, FormGroup, ValidationErrors, ValidatorFn, Validators } from '@angular/forms'; import { terminationOptions } from 'src/app/models/hris/constants/terminationOptions.constants'; import { NavService } from 'src/app/services/shared-services/nav-service/nav.service'; import { ActivatedRoute, Router } from '@angular/router'; @@ -7,6 +7,7 @@ import { SnackbarService } from 'src/app/services/shared-services/snackbar-servi import { EmployeeService } from 'src/app/services/hris/employee/employee.service'; import { EmployeeProfile } from 'src/app/models/hris/employee-profile.interface'; import { EmployeeTerminationService } from 'src/app/services/hris/employee/employee-termination.service'; +import { endDateAfterStartDateValidator } from 'src/app/components/shared-components/form-validators/dateValidator'; @Component({ selector: 'app-employee-termination', @@ -54,8 +55,8 @@ export class EmployeeTerminationComponent implements OnInit { dayOfNotice: new FormControl(new Date(Date.now()), Validators.required), lastDayOfEmployment: new FormControl(new Date(Date.now()), Validators.required), reEmploymentStatus: new FormControl(true, Validators.required), - equipmentStatus: new FormControl(false, Validators.required), - accountsStatus: new FormControl(false, Validators.required), + equipmentStatus: new FormControl(false), + accountsStatus: new FormControl(false), terminationDocument: new FormControl('', Validators.required), terminationComments: new FormControl(''), }); @@ -72,51 +73,57 @@ export class EmployeeTerminationComponent implements OnInit { initializeForm() { this.newterminationform = this.fb.group({ - terminationOption: new FormControl('', Validators.required), - dayOfNotice: new FormControl('', Validators.required), - lastDayOfEmployment: new FormControl('', Validators.required), - reEmploymentStatus: new FormControl(true, Validators.required), - equipmentStatus: new FormControl(false, Validators.required), - accountsStatus: new FormControl(false, Validators.required), - terminationDocument: new FormControl('', Validators.required), - terminationComments: new FormControl(''), - }); - this.newterminationform.valueChanges.subscribe(() => { - this.checkCheckboxesValid(); - }); - this.checkCheckboxesValid(); + terminationOption: new FormControl('', Validators.required), + dayOfNotice: new FormControl('', Validators.required), + lastDayOfEmployment: new FormControl('', Validators.required), + reEmploymentStatus: new FormControl(true, Validators.required), + equipmentStatus: new FormControl(false), + accountsStatus: new FormControl(false), + terminationDocument: new FormControl('', Validators.required), + terminationComments: new FormControl(''), + }, { validator: endDateAfterStartDateValidator('dayOfNotice', 'lastDayOfEmployment')}); } SaveEmployeeTermination(nextPage: string) { this.formSubmitted = true; - this.checkCheckboxesValid(); - if (!this.checkboxesValid) { - return; + + this.newterminationform.updateValueAndValidity(); + + if (!this.checkboxesValid || !this.newterminationform.valid) { + return; } const newterminationform = this.newterminationform.value; const employeeTerminationDto = { - id: 0, - employeeId: +this.employeeId, - terminationOption: this.terminationOptionValue, - dayOfNotice: newterminationform.dayOfNotice, - lastDayOfEmployment: newterminationform.lastDayOfEmployment, - reemploymentStatus: newterminationform.reEmploymentStatus, - equipmentStatus: newterminationform.equipmentStatus, - accountsStatus: newterminationform.accountsStatus, - terminationDocument: this.base64String, - documentName: newterminationform.terminationDocument, - terminationComments: newterminationform.terminationComments + id: 0, + employeeId: +this.employeeId, + terminationOption: this.terminationOptionValue, + dayOfNotice: newterminationform.dayOfNotice, + lastDayOfEmployment: newterminationform.lastDayOfEmployment, + reemploymentStatus: newterminationform.reEmploymentStatus, + equipmentStatus: newterminationform.equipmentStatus, + accountsStatus: newterminationform.accountsStatus, + terminationDocument: this.base64String, + documentName: newterminationform.terminationDocument, + terminationComments: newterminationform.terminationComments }; this.employeeTerminationService.saveEmployeeTermination(employeeTerminationDto).subscribe({ - next: () => this.snackBarService.showSnackbar("Saved", "snack-success"), - error: () => this.snackBarService.showSnackbar("Unable to Save Termination", 'snack-error'), - complete: () => { - this.router.navigateByUrl(nextPage); - } + next: () => this.snackBarService.showSnackbar("Employee Terminated", "snack-success"), + error: () => this.snackBarService.showSnackbar("Unable to Save Termination", 'snack-error'), + complete: () => { + this.router.navigateByUrl(nextPage); + } }); } + endDateFilter = (date: Date | null): boolean => { + const startDate = this.newterminationform.get('dayOfNotice')?.value; + if (!date || !startDate) { + return true; + } + return date.getTime() >= new Date(startDate).getTime(); + } + removeDocument() { this.interviewDocFilename = ''; const uploadedDoc = document.getElementById('uploadCVFile') as HTMLInputElement; @@ -171,11 +178,4 @@ export class EmployeeTerminationComponent implements OnInit { this.newterminationform.controls['terminationOption'].setValue(option); this.terminationOptionValue = option; } - - checkCheckboxesValid() { - const equipmentStatusChecked = this.newterminationform.get('equipmentStatus')?.value; - const accountsStatusChecked = this.newterminationform.get('accountsStatus')?.value; - - this.checkboxesValid = equipmentStatusChecked && accountsStatusChecked; - } } diff --git a/src/app/components/hris/employees/view-employee/view-employee.component.html b/src/app/components/hris/employees/view-employee/view-employee.component.html index 68784cc38..0da8a8d2d 100644 --- a/src/app/components/hris/employees/view-employee/view-employee.component.html +++ b/src/app/components/hris/employees/view-employee/view-employee.component.html @@ -32,7 +32,7 @@ People Champion Filter - + {{ champion.name }} @@ -121,7 +121,7 @@ {{ splitAndCapitalizeCamelCase(employee.Roles.length > 0 ? employee.Roles[0] : "N/A") }} - {{ splitAndCapitalizeCamelCase(role) }} diff --git a/src/app/components/hris/employees/view-employee/view-employee.component.ts b/src/app/components/hris/employees/view-employee/view-employee.component.ts index 67851b5c4..299992dbc 100644 --- a/src/app/components/hris/employees/view-employee/view-employee.component.ts +++ b/src/app/components/hris/employees/view-employee/view-employee.component.ts @@ -1,4 +1,4 @@ -import { EmployeeProfile } from 'src/app/models/hris/employee-profile.interface'; +import { EmployeeFilterView } from 'src/app/models/hris/employee-filter-view.interface'; import { EmployeeService } from 'src/app/services/hris/employee/employee.service'; import { CookieService } from 'ngx-cookie-service'; import { MatTableDataSource } from '@angular/material/table'; @@ -7,35 +7,15 @@ import { MatSort, Sort } from '@angular/material/sort'; import { Router } from '@angular/router'; import { EmployeeRoleService } from 'src/app/services/hris/employee/employee-role.service'; import { SnackbarService } from 'src/app/services/shared-services/snackbar-service/snackbar.service'; -import { ClientService } from 'src/app/services/hris/client.service'; -import { Client } from 'src/app/models/hris/client.interface'; import { EmployeeData } from 'src/app/models/hris/employeedata.interface'; -import { - Component, - Output, - EventEmitter, - ViewChild, - HostListener, - NgZone, - Input, - ViewEncapsulation, -} from '@angular/core'; -import { - Observable, - catchError, - first, - forkJoin, - map, - of, - switchMap, - tap, -} from 'rxjs'; -import { NavService } from 'src/app/services/shared-services/nav-service/nav.service'; +import { Component, Output, EventEmitter, ViewChild, HostListener, NgZone, Input, ViewEncapsulation } from '@angular/core'; +import { Observable, catchError, first, forkJoin, map, of, switchMap, tap } from 'rxjs'; import { AuthAccessService } from 'src/app/services/shared-services/auth-access/auth-access.service'; import { EmployeeType } from 'src/app/models/hris/constants/employeeTypes.constants'; import { EmployeeTypeService } from 'src/app/services/hris/employee/employee-type.service'; import { GenericDropDownObject } from 'src/app/models/hris/generic-drop-down-object.interface' import { EmployeeStatus } from 'src/app/models/hris/constants/employee-status.constants'; +import { EmployeeProfile } from 'src/app/models/hris/employee-profile.interface'; @Component({ selector: 'app-view-employee', @@ -45,6 +25,18 @@ import { EmployeeStatus } from 'src/app/models/hris/constants/employee-status.co }) export class ViewEmployeeComponent { + + constructor( + private employeeService: EmployeeService, + private employeeRoleService: EmployeeRoleService, + private cookieService: CookieService, + private ngZone: NgZone, + private router: Router, + private snackBarService: SnackbarService, + public authAccessService: AuthAccessService, + private employeeTypeService: EmployeeTypeService + ) { } + @Output() selectedEmployee = new EventEmitter(); @Output() addEmployeeEvent = new EventEmitter(); @Output() managePermissionsEvent = new EventEmitter(); @@ -53,16 +45,21 @@ export class ViewEmployeeComponent { @ViewChild(MatPaginator) paginator!: MatPaginator; _searchQuery: string = ''; - filteredEmployees: EmployeeProfile[] = []; + filteredEmployees: EmployeeFilterView[] = []; employeeStatus: string[] = EmployeeStatus; getActiveEmployees: boolean = true; isLoading: boolean = true; defaultPageSize: number = 10 - - displayedColumns: string[] = ['Name', 'Position', 'Level', 'Client', 'Roles']; + selectedChampion?: GenericDropDownObject = { id: 0, name: 'All' } as GenericDropDownObject; + displayedColumns: string[] = ['Name', 'Position', 'Level', 'Client']; displayedTerminatedColumns: string[] = ['terminatedNames', 'terminatedPosition', 'Tenure', 'Last Day', 'Reason']; - - dataSource: MatTableDataSource = new MatTableDataSource(); + dataSource: MatTableDataSource = new MatTableDataSource(); + PREVIOUS_PAGE = 'previousPage'; + roles: string[] = []; + peopleChampions: Observable = new Observable; + usertypes: Observable = new Observable; + currentChampionFilter: GenericDropDownObject = new GenericDropDownObject; + currentUserTypeFilter: GenericDropDownObject = new GenericDropDownObject; @Input() set searchQuery(text: string) { @@ -78,117 +75,66 @@ export class ViewEmployeeComponent { return this.authAccessService.isSuperAdmin() || this.authAccessService.isAdmin(); } - PREVIOUS_PAGE = 'previousPage'; - - roles: Observable = this.employeeRoleService.getAllRoles().pipe( - map((roles: string[]) => - roles.filter((role) => !role.includes('SuperAdmin')) - ), - first() - ); - - peopleChampions: Observable = this.getPeopleChampionsForFilter(); - usertypes: Observable = this.getUserTypesForFilter(); - currentChampionFilter: GenericDropDownObject = new GenericDropDownObject; - currentUserTypeFilter: GenericDropDownObject = new GenericDropDownObject; - - onAddEmployeeClick(): void { - this.addEmployeeEvent.emit(); - this.cookieService.set(this.PREVIOUS_PAGE, '/employees'); - this.router.navigateByUrl('/create-employee'); - } - - constructor( - private employeeService: EmployeeService, - private employeeRoleService: EmployeeRoleService, - private clientService: ClientService, - private cookieService: CookieService, - private ngZone: NgZone, - private router: Router, - private snackBarService: SnackbarService, - public authAccessService: AuthAccessService, - private employeeTypeService: EmployeeTypeService - ) { + get isJourney() { + return this.authAccessService.isJourney(); } ngOnInit() { this.dataSource.paginator = this.paginator; + this.usertypes = this.getUserTypesForFilter(); + this.peopleChampions = this.getPeopleChampionsForFilter(); + this.employeeRoleService.getAllRoles().subscribe((data: string[]) => { + this.roles = data.filter((role) => !role.includes('SuperAdmin')); + }); this.onResize(); + if (this.cookieService.get(this.PREVIOUS_PAGE) == '/dashboard') { this._searchQuery = this.cookieService.get('searchString'); } - if (!this.isAdminOrSuperAdmin) { - this.displayedColumns = ['Name', 'Position', 'Level', 'Client']; + if (this.isAdminOrSuperAdmin) { + this.displayedColumns = ['Name', 'Position', 'Level', 'Client', 'Roles']; } + + this.peopleChampions.subscribe({ + next: data => + this.selectedChampion = this.isJourney + ? data.find(x => x.id == this.authAccessService.getUserId() ?? 0) + : data.find(x => x.id == 0) + }) } ngAfterViewInit() { - this.getEmployees(); + this.filterEmployeeTable(); this.cookieService.set(this.PREVIOUS_PAGE, '/employees'); } - getEmployees(): void { - this.isLoading = true; - const clients$: Observable = this.clientService - .getAllClients() - .pipe(catchError(() => of([] as Client[]))); - - this.employeeService - .getEmployeeProfiles() - .pipe( - switchMap((employees: EmployeeProfile[]) => - this.combineEmployeesWithRolesAndClients(employees, clients$) - ), - catchError((error) => { - this.snackBarService.showSnackbar('Unable to Retrieve Employees', 'snack-error'); - return of([]); - }), - first() - ) - .subscribe((data) => { - this.setupDataSource(data); - this.isLoading = false; - this.applySearchFilter(); - }); + onAddEmployeeClick(): void { + this.addEmployeeEvent.emit(); + this.cookieService.set(this.PREVIOUS_PAGE, '/employees'); + this.router.navigateByUrl('/create-employee'); } private combineEmployeesWithRolesAndClients( - employees: EmployeeProfile[], - clients$: Observable + employees: EmployeeFilterView[] ): Observable { - const rolesRequests$ = employees.map((employee) => - this.employeeRoleService - .getRoles(employee.email!) - .pipe(catchError(() => of([] as string[]))) - ); - - return forkJoin([of(employees), clients$, ...rolesRequests$]).pipe( - map(([employees, clients, ...rolesList]) => - this.constructEmployeeData(employees, clients, rolesList) - ) + return forkJoin([of(employees)]).pipe( + map(([employees]) => this.constructEmployeeData(employees)) ); } private constructEmployeeData( - employees: EmployeeProfile[], - clients: Client[], - rolesList: string[][] + employees: EmployeeFilterView[] ): EmployeeData[] { const employeeDataList: EmployeeData[] = employees.map( - (employee, index) => { - const client = clients.find( - (client) => - employee.clientAllocated && client.id === +employee.clientAllocated - ); - const sortedRoles = this.sortRoles(rolesList[index]); + (employee) => { return { Name: `${employee.name} ${employee.surname}`, - Position: employee.employeeType!.name, + Position: employee.position, Level: employee.level, - Client: client ? client.name : 'None', - Roles: sortedRoles, + Client: employee.clientAllocated ?? 'None', + Roles: [employee.roleDescription], Email: employee.email, engagementDate: employee.engagementDate, terminationDate: employee.terminationDate, @@ -267,33 +213,14 @@ export class ViewEmployeeComponent { this.cookieService.set('selectedUser', email); } - employeeClickEvent(employee: { - Name: string; - Position: string | undefined; - Level: number | undefined; - Client: string; - Roles: string[]; - Email: string | undefined; - }): void { - this.employeeService - .getEmployeeProfiles() - .pipe( - map( - (employees: EmployeeProfile[]) => - employees.filter( - (emp: EmployeeProfile) => - `${emp.name} ${emp.surname}` === `${employee.Name}` - )[0] - ), - tap((data) => { - this.selectedEmployee.emit(data); - this._searchQuery = ''; - this.router.navigateByUrl('/profile/' + data.id) - this.cookieService.set(this.PREVIOUS_PAGE, '/employees'); - }), - first() - ) - .subscribe(); + employeeClickEvent(employee: any): void { + this.employeeService.get(employee.Email). + subscribe((data) => { + this.selectedEmployee.emit(data); + this._searchQuery = ''; + this.router.navigateByUrl('/profile/' + data.id) + this.cookieService.set(this.PREVIOUS_PAGE, '/employees'); + }) } screenWidth: number = 992; @@ -337,16 +264,16 @@ export class ViewEmployeeComponent { return pages; } - changeRole(email: string, role: string): void { + changeRole(email: string, newRole: string): void { this.employeeRoleService - .updateRole(email, role) + .updateRole(email, newRole) .pipe( tap(() => { this.snackBarService.showSnackbar("Updated", "snack-success"); - this.getEmployees(); }), - catchError((error) => { - this.snackBarService.showSnackbar('Unable to Change Role', 'snack-error'); + catchError((er) => { + this.snackBarService.showSnackbar(er.error, 'snack-error'); + this.filterEmployeeTable(); return of(null); }) ) @@ -401,16 +328,11 @@ export class ViewEmployeeComponent { filterEmployeeTable() { this.isLoading = true; - const clients$: Observable = this.clientService - .getAllClients() - .pipe(catchError(() => of([] as Client[]))); this.employeeService .filterEmployees(this.currentChampionFilter.id || 0, this.currentUserTypeFilter.id || 0, this.getActiveEmployees) .pipe( - switchMap((employees: EmployeeProfile[]) => - this.combineEmployeesWithRolesAndClients(employees, clients$) - ), + switchMap((employees: EmployeeFilterView[]) => this.combineEmployeesWithRolesAndClients(employees)), catchError((error) => { this.snackBarService.showSnackbar('Unable to Retrieve Employees', 'snack-error'); return of([]); @@ -473,4 +395,4 @@ export class ViewEmployeeComponent { sortTerminatedNames(EmployeeName1: string, EmployeeName2: string, isAsc: boolean) { return (EmployeeName1 < EmployeeName2 ? -1 : 1) * (isAsc ? 1 : -1); } -} +} \ No newline at end of file diff --git a/src/app/components/shared-components/form-validators/dateValidator.ts b/src/app/components/shared-components/form-validators/dateValidator.ts new file mode 100644 index 000000000..fda0bda4a --- /dev/null +++ b/src/app/components/shared-components/form-validators/dateValidator.ts @@ -0,0 +1,27 @@ +import { AbstractControl, ValidationErrors, ValidatorFn } from '@angular/forms'; + +export function endDateAfterStartDateValidator(startDateKey: string, endDateKey: string): ValidatorFn { + return (control: AbstractControl): ValidationErrors | null => { + const startDate = control.get(startDateKey)?.value; + const endDate = control.get(endDateKey)?.value; + + if (!startDate || !endDate) { + return null; + } + + const start = new Date(startDate); + const end = new Date(endDate); + + if (end >= start) { + control.get(startDateKey)?.setErrors(null); + control.get(endDateKey)?.setErrors(null); + return null; + } + else { + control.get(startDateKey)?.setErrors({'incorrect': true}); + control.get(endDateKey)?.setErrors({'incorrect': true}); + return { endDateAfterStartDate: true } + } + }; +} + diff --git a/src/app/models/hris/constants/documents.contants.ts b/src/app/models/hris/constants/documents.contants.ts index 805d6c00b..498832e3d 100644 --- a/src/app/models/hris/constants/documents.contants.ts +++ b/src/app/models/hris/constants/documents.contants.ts @@ -17,6 +17,4 @@ export const MyDocumentTypes = [ "New Qualification Documentation", "Records of Performance Reviews", "Other" -] - - +] \ No newline at end of file diff --git a/src/app/models/hris/employee-filter-view.interface.ts b/src/app/models/hris/employee-filter-view.interface.ts new file mode 100644 index 000000000..6e37a75a1 --- /dev/null +++ b/src/app/models/hris/employee-filter-view.interface.ts @@ -0,0 +1,17 @@ +export class EmployeeFilterView { + + EmployeeFilterView() {} + + id!: number; + name!: string; + surname!: string; + level?: number; + clientAllocated?: string; + roleId!: string; + roleDescription!: string; + engagementDate?: Date; + terminationDate?: Date; + email?: string; + inactiveReason?: string; + position?: string; +} \ No newline at end of file diff --git a/src/app/services/hris/employee/employee.service.ts b/src/app/services/hris/employee/employee.service.ts index 132bd8fa5..40177ea27 100644 --- a/src/app/services/hris/employee/employee.service.ts +++ b/src/app/services/hris/employee/employee.service.ts @@ -7,6 +7,7 @@ import { environment } from '../../../../environments/environment'; import { AuthAccessService } from '../../shared-services/auth-access/auth-access.service'; import { ChurnRateDataCard } from 'src/app/models/hris/churn-rate-data-card.interface'; import { EmployeeCountDataCard } from 'src/app/models/hris/employee-count-data-card.interface'; +import { EmployeeFilterView } from 'src/app/models/hris/employee-filter-view.interface'; @Injectable({ @@ -102,11 +103,11 @@ export class EmployeeService { * * @returns List of EmployeeDto objects. */ -filterEmployees(championID: number, employeeType: number, activeStatus: boolean = true): Observable { +filterEmployees(championID: number, employeeType: number, activeStatus: boolean = true): Observable { const queryParams = `?PeopleChampId=${encodeURIComponent(championID)} &employeeType=${encodeURIComponent(employeeType)} &activeStatus=${activeStatus}`; - return this.httpClient.get(`${this.baseUrl}/filter-employees${queryParams}`); + return this.httpClient.get(`${this.baseUrl}/filter-employees${queryParams}`); } } diff --git a/src/app/services/shared-services/auth-access/auth-access.service.ts b/src/app/services/shared-services/auth-access/auth-access.service.ts index 1ba15fa33..ef1c59fab 100644 --- a/src/app/services/shared-services/auth-access/auth-access.service.ts +++ b/src/app/services/shared-services/auth-access/auth-access.service.ts @@ -66,4 +66,4 @@ export class AuthAccessService { this.employeeEmail = ""; this.cookieService.deleteAll(); } -} +} \ No newline at end of file