-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'lebihae/betterlydia' into 'main'
feat(lydia): improve bank accounts management page, allow deleting lydia accounts Closes #115 and #1136 See merge request churros/churros!258
- Loading branch information
Showing
11 changed files
with
349 additions
and
130 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@churros/api': major | ||
'@churros/app': minor | ||
--- | ||
|
||
improve groups' Lydia accounts management and fix bugs |
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
34 changes: 34 additions & 0 deletions
34
packages/api/src/modules/payments/resolvers/mutation.delete-lydia-account.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,34 @@ | ||
import { builder, ensureGlobalId, log, prisma } from '#lib'; | ||
import { LocalID } from '#modules/global'; | ||
import { canEditLydiaAccounts } from '#modules/groups'; | ||
import { LydiaAccountType } from '#modules/payments/types'; | ||
import { GraphQLError } from 'graphql'; | ||
|
||
builder.mutationField('deleteLydiaAccount', (t) => | ||
t.prismaField({ | ||
type: LydiaAccountType, | ||
errors: {}, | ||
description: | ||
"Supprimer l'enregistrement d'uncompte Lydia sur un groupe (ne supprime pas le compte Lydia Pro sur Lydia)", | ||
args: { | ||
id: t.arg({ type: LocalID }), | ||
}, | ||
async authScopes(_, { id }, { user }) { | ||
const group = await prisma.lydiaAccount | ||
.findUniqueOrThrow({ where: { id: ensureGlobalId(id, 'LydiaAccount') } }) | ||
.group({ include: canEditLydiaAccounts.prismaIncludes }); | ||
|
||
if (!group) throw new GraphQLError("Ce compte Lydia n'est relié à aucun groupe"); | ||
|
||
return canEditLydiaAccounts(user, group); | ||
}, | ||
async resolve(query, _, { id }, { user }) { | ||
const result = await prisma.lydiaAccount.delete({ | ||
...query, | ||
where: { id: ensureGlobalId(id, 'LydiaAccount') }, | ||
}); | ||
await log('lydia-accounts', 'deleted', { account: result }, result.id, user); | ||
return result; | ||
}, | ||
}), | ||
); |
15 changes: 9 additions & 6 deletions
15
packages/api/src/modules/payments/resolvers/mutation.upsert-lydia-account.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
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
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.