Skip to content

Commit

Permalink
add beforeUpdate to prevent update from ATS
Browse files Browse the repository at this point in the history
  • Loading branch information
c1495616js committed Jan 17, 2025
1 parent 0d78969 commit ace0d9d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions apps/api/src/applicant/entity/ienapplicant.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
BeforeInsert,
ManyToMany,
JoinTable,
BeforeUpdate,
} from 'typeorm';

import { IENApplicantAudit } from './ienapplicant-audit.entity';
Expand Down Expand Up @@ -165,6 +166,19 @@ export class IENApplicant {
this.applicant_status_audit = sortStatus(this.applicant_status_audit);
}
}

/**
* Check if the deleted_date is set before updating the entity, this is for syncronization with the ATS preventing updates to scrambled data
*/
@BeforeUpdate()
checkDeletedDateBeforeUpdate() {
if (this.deleted_date) {
this.name = this.name; // Keep existing value
this.email_address = this.email_address; // Keep existing value
this.phone_number = this.phone_number; // Keep existing value
}
}

toResponseObject(): ApplicantRO {
return {
id: this.id,
Expand Down

0 comments on commit ace0d9d

Please sign in to comment.