|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- import { Component, OnInit } from '@angular/core';
-
- type State = 'VIEW INITIAL DETAILS'|'ENTER MORE DETAILS'|'ASSIGN COMMITTEE'|'REVIEW NON COMPLIANCE'|'CONCUR COMPLIANCE REVIEW';
- type Role = 'Investigator'|'Hod'|'Panel';
-
- @Component({
- selector: 'app-investigate-business-entities-and-individuals',
- templateUrl: './investigate-business-entities-and-individuals.component.html',
- styleUrls: ['./investigate-business-entities-and-individuals.component.scss']
- })
- export class InvestigateBusinessEntitiesAndIndividualsComponent implements OnInit {
- hasEnoughData = false;
- isNonCompliant = false;
-
- isPanelConcurring = true;
- panelRemarks = '';
-
- state: State;
- stateHistory: Array<State> = [];
-
- loginRole: Role;
-
- canExecute: boolean;
- executingRole: Role;
-
-
- constructor() {
- const panelRemarks = localStorage.getItem('panelRemarks');
- if (panelRemarks) {
- this.panelRemarks = panelRemarks;
- }
-
- const loginEmail = localStorage.getItem('loginEmail');
-
- if (loginEmail && loginEmail.toLocaleLowerCase().startsWith('hod')) {
- this.loginRole = 'Hod';
- } else if (loginEmail && loginEmail.toLocaleLowerCase().startsWith('panel')) {
- this.loginRole = 'Panel';
- } else {
- this.loginRole = 'Investigator';
- }
-
- const savedState = localStorage.getItem('state');
-
- switch (savedState) {
- case 'ENTER MORE DETAILS':
- this.state = 'ENTER MORE DETAILS';
- this.executingRole = 'Investigator';
- break;
- case 'ASSIGN COMMITTEE':
- this.state = 'ASSIGN COMMITTEE';
- this.executingRole = 'Hod';
- break;
- case 'REVIEW NON COMPLIANCE':
- this.state = 'REVIEW NON COMPLIANCE';
- this.executingRole = 'Investigator';
- break;
- case 'CONCUR COMPLIANCE REVIEW':
- this.state = 'CONCUR COMPLIANCE REVIEW';
- this.executingRole = 'Panel';
- break;
- default:
- this.state = 'VIEW INITIAL DETAILS';
- this.executingRole = 'Investigator';
- }
-
- this.canExecute = this.loginRole === this.executingRole;
- }
-
- updatePanelRemarks(remarks: string) {
- this.panelRemarks = remarks;
- localStorage.setItem('panelRemarks', remarks);
- }
-
- proceed() {
- this.stateHistory.push(this.state);
-
- switch (this.state) {
- case 'VIEW INITIAL DETAILS':
- if (this.hasEnoughData) {
- this.state = 'ASSIGN COMMITTEE';
- this.executingRole = 'Hod';
- } else {
- this.state = 'ENTER MORE DETAILS';
- this.executingRole = 'Investigator';
- }
- break;
- case 'ENTER MORE DETAILS':
- this.state = 'ASSIGN COMMITTEE';
- this.executingRole = 'Hod';
- break;
- case 'ASSIGN COMMITTEE':
- this.state = 'REVIEW NON COMPLIANCE';
- this.executingRole = 'Investigator';
- break;
- case 'REVIEW NON COMPLIANCE':
- this.state = 'CONCUR COMPLIANCE REVIEW';
- this.executingRole = 'Panel';
- break;
- case 'CONCUR COMPLIANCE REVIEW':
- if (!this.isPanelConcurring) {
- this.state = 'REVIEW NON COMPLIANCE';
- this.executingRole = 'Investigator';
- }
- break;
- }
-
- localStorage.setItem('state', this.state);
-
- this.canExecute = this.loginRole === this.executingRole;
- }
-
- goBack() {
- const state = this.stateHistory.pop();
-
- if (state) {
- this.state = state;
- }
-
- switch (this.state) {
- case 'ASSIGN COMMITTEE':
- this.executingRole = 'Hod';
- break;
- case 'CONCUR COMPLIANCE REVIEW':
- this.executingRole = 'Panel';
- break;
- default:
- this.executingRole = 'Investigator';
- }
-
- localStorage.setItem('state', this.state);
-
- this.canExecute = this.loginRole === this.executingRole;
- }
-
- ngOnInit(): void {
- }
-
- }
|