Skip to content

Commit

Permalink
fix(backend): fix subscribers
Browse files Browse the repository at this point in the history
  • Loading branch information
pYassine committed Nov 26, 2024
1 parent e1f93b3 commit baafd6d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@ export class StructureSubscriber
return StructureTable;
}
public lowerAndTrim(entity: StructureTable) {
entity.email = entity.email.toLowerCase().trim();
entity.adresse = entity.adresse.trim();
entity.nom = entity.nom.trim();
entity.ville = entity.ville.trim();
if (entity?.email) {
entity.email = entity?.email.toLowerCase().trim();
}
if (entity?.adresse) {
entity.adresse = entity?.adresse.trim();
}
if (entity?.nom) {
entity.nom = entity?.nom.trim();
}
if (entity?.ville) {
entity.ville = entity?.ville.trim();
}
}

beforeInsert(event: InsertEvent<StructureTable>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,19 @@ export class UsagerSubscriber
}

try {
entity.nom = entity.nom.trim();
entity.prenom = entity.prenom.trim();
if (entity?.nom && entity?.prenom) {
entity.nom = entity.nom.trim();
entity.prenom = entity.prenom.trim();

const parts = [
entity.nom,
entity.prenom,
entity.surnom,
entity?.customRef ?? entity?.ref,
].filter(Boolean);
const parts = [
entity.nom,
entity.prenom,
entity.surnom,
entity?.customRef ?? entity?.ref,
].filter(Boolean);

entity.nom_prenom_surnom_ref = normalizeString(parts.join(" "));
entity.nom_prenom_surnom_ref = normalizeString(parts.join(" "));
}
} catch (error) {
console.error("Erreur lors du traitement du nom:", error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ export class StructureSubscriber
return UserStructureTable;
}
public lowerAndTrim(entity: UserStructureTable) {
entity.email = entity.email.toLowerCase().trim();
entity.nom = entity.nom.trim();
entity.prenom = entity.prenom.trim();
if (entity?.email) {
entity.email = entity.email.toLowerCase().trim();
}
if (entity?.nom) {
entity.nom = entity.nom.trim();
}
if (entity?.prenom) {
entity.prenom = entity.prenom.trim();
}
}

beforeInsert(event: InsertEvent<UserStructureTable>) {
Expand Down

0 comments on commit baafd6d

Please sign in to comment.