Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src/donations: Remove unnecessary relations from query response #588

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/api/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export class AuthService {
emailVerified: true,
groups: [],
requiredActions: verifyEmail ? [RequiredActionAlias.VERIFY_EMAIL] : [],
attributes: { selfReg: true },
attributes: { selfReg: true, companyName: registerDto.companyName },
credentials: [
{
type: 'password',
Expand Down Expand Up @@ -433,7 +433,7 @@ export class AuthService {
const user = await this.personService.findOneByKeycloakId(keycloakId)

//Check and throw if user is a beneficiary, organizer or corporate profile
if (!!user && user.beneficiaries.length > 0 || user?.organizer || user?.companyId) {
if ((!!user && user.beneficiaries.length > 0) || user?.organizer || user?.companyId) {
throw new InternalServerErrorException(
'Cannot delete a beneficiary, organizer or corporate profile',
)
Expand Down
8 changes: 1 addition & 7 deletions apps/api/src/donations/donations.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,7 @@ export class DonationsController {
@Get('user/:id')
async userDonationById(@Param('id') id: string, @AuthenticatedUser() user: KeycloakTokenParsed) {
const donation = await this.donationsService.getUserDonationById(id, user.sub, user.email)
return {
...donation,
person: {
firstName: user.given_name,
lastName: user.family_name,
},
}
return donation
}

@Post('payment-intent')
Expand Down
13 changes: 1 addition & 12 deletions apps/api/src/donations/donations.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import { CreateBankPaymentDto } from './dto/create-bank-payment.dto'
import { CreateSessionDto } from './dto/create-session.dto'
import { UpdatePaymentDto } from './dto/update-payment.dto'
import { Person } from '../person/entities/person.entity'

Check warning on line 24 in apps/api/src/donations/donations.service.ts

View workflow job for this annotation

GitHub Actions / Run API tests

'Person' is defined but never used
import { DonationBaseDto, ListDonationsDto } from './dto/list-donations.dto'
import { donationWithPerson, DonationWithPerson } from './queries/donation.validator'
import { CreateStripePaymentDto } from './dto/create-stripe-payment.dto'
Expand Down Expand Up @@ -461,25 +461,14 @@
id: string,
keycloakId: string,
email?: string,
): Promise<(Donation & { person: Person | null }) | null> {
): Promise<Donation | null> {
return await this.prisma.donation.findFirst({
where: {
id,
status: DonationStatus.succeeded,
OR: [{ billingEmail: email }, { person: { keycloakId } }],
},
include: {
person: {
select: {
id: true,
firstName: true,
lastName: true,
company: { select: { companyName: true } },
},
},
affiliate: {
select: { company: { select: { companyName: true } } },
},
targetVault: {
select: {
id: true,
Expand Down
Loading