-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
253 additions
and
648 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/backend/src/database/entities/structure/StructureSubscriber.typeorm.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { | ||
EventSubscriber, | ||
EntitySubscriberInterface, | ||
InsertEvent, | ||
UpdateEvent, | ||
} from "typeorm"; | ||
import { StructureTable } from "./StructureTable.typeorm"; | ||
|
||
@EventSubscriber() | ||
export class StructureSubscriber | ||
implements EntitySubscriberInterface<StructureTable> | ||
{ | ||
listenTo() { | ||
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(); | ||
} | ||
|
||
beforeInsert(event: InsertEvent<StructureTable>) { | ||
this.lowerAndTrim(event.entity); | ||
} | ||
|
||
beforeUpdate(event: UpdateEvent<StructureTable>) { | ||
if (event.entity) { | ||
this.lowerAndTrim(event.entity as StructureTable); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
packages/backend/src/database/entities/usager/UsagerSubscriber.typeorm.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { | ||
EventSubscriber, | ||
EntitySubscriberInterface, | ||
InsertEvent, | ||
UpdateEvent, | ||
} from "typeorm"; | ||
import { normalizeString } from "../../../util"; | ||
import { UsagerTable } from "./UsagerTable.typeorm"; | ||
|
||
@EventSubscriber() | ||
export class UsagerSubscriber | ||
implements EntitySubscriberInterface<UsagerTable> | ||
{ | ||
listenTo() { | ||
return UsagerTable; | ||
} | ||
|
||
private processName(entity: UsagerTable) { | ||
if (!entity?.nom || !entity?.prenom) { | ||
return; | ||
} | ||
|
||
try { | ||
entity.nom = entity.nom.trim(); | ||
entity.prenom = entity.prenom.trim(); | ||
|
||
const parts = [ | ||
entity.nom, | ||
entity.prenom, | ||
entity.surnom, | ||
entity?.customRef ?? entity?.ref, | ||
].filter(Boolean); | ||
|
||
entity.nom_prenom_surnom_ref = normalizeString(parts.join(" ")); | ||
} catch (error) { | ||
console.error("Erreur lors du traitement du nom:", error); | ||
} | ||
} | ||
|
||
beforeInsert(event: InsertEvent<UsagerTable>) { | ||
this.processName(event.entity); | ||
} | ||
|
||
beforeUpdate(event: UpdateEvent<UsagerTable>) { | ||
if (event.entity) { | ||
this.processName(event.entity as UsagerTable); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
packages/backend/src/database/entities/user-structure/UserStructureSubscriber.typeorm.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { | ||
EventSubscriber, | ||
EntitySubscriberInterface, | ||
InsertEvent, | ||
UpdateEvent, | ||
} from "typeorm"; | ||
import { UserStructureTable } from "./UserStructureTable.typeorm"; | ||
|
||
@EventSubscriber() | ||
export class StructureSubscriber | ||
implements EntitySubscriberInterface<UserStructureTable> | ||
{ | ||
listenTo() { | ||
return UserStructureTable; | ||
} | ||
public lowerAndTrim(entity: UserStructureTable) { | ||
entity.email = entity.email.toLowerCase().trim(); | ||
entity.nom = entity.nom.trim(); | ||
entity.prenom = entity.prenom.trim(); | ||
} | ||
|
||
beforeInsert(event: InsertEvent<UserStructureTable>) { | ||
this.lowerAndTrim(event.entity); | ||
} | ||
|
||
beforeUpdate(event: UpdateEvent<UserStructureTable>) { | ||
if (event.entity) { | ||
this.lowerAndTrim(event.entity as UserStructureTable); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.