Skip to content

Commit

Permalink
fix: reimport d'utilisateurs supprimés (#2061)
Browse files Browse the repository at this point in the history
* fix: add suffix to deleted accounts

It will free the email and the username for later

* fix: add hours and minutes

* fix: review changes
  • Loading branch information
vjousse authored Dec 20, 2023
1 parent 9851e83 commit d18f85d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
12 changes: 11 additions & 1 deletion app/src/lib/ui/ProfessionalList/List.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,17 @@
const deleteAccount = mutation(deleteAccountMutation);
async function removeProfessional(professional: Professional) {
await deleteAccount({ accountId: professional.account.id });
const nowDate = new Date();
const suffix = '.deleted' + nowDate.toISOString();
const newEmail = professional.email + suffix;
const newUsername = professional.account.username + suffix;
await deleteAccount({
accountId: professional.account.id,
professionalId: professional.id,
newEmail: newEmail,
newUsername: newUsername,
});
}
</script>

Expand Down
15 changes: 13 additions & 2 deletions app/src/lib/ui/ProfessionalList/_deleteAccount.gql
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
mutation DeleteAccount($accountId: uuid!) {
update_account_by_pk(pk_columns: { id: $accountId }, _set: { deletedAt: now }) {
mutation DeleteAccount(
$accountId: uuid!
$professionalId: uuid!
$newEmail: citext!
$newUsername: String!
) {
update_account_by_pk(
pk_columns: { id: $accountId }
_set: { deletedAt: now, username: $newUsername }
) {
id
}
update_professional_by_pk(pk_columns: { id: $professionalId }, _set: { email: $newEmail }) {
id
}
update_notebook_member(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ query GetProfessionalsForStructure($structureId: uuid!) {
position
account {
id
username
onboardingDone
notebooksWhereMember_aggregate(
where: { active: { _eq: true }, memberType: { _eq: "referent" } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ update_permissions:
- cgu_validated_at
- deleted_at
- onboarding_done
- username
filter:
_or:
- id:
Expand Down

0 comments on commit d18f85d

Please sign in to comment.