Skip to content

Commit c00e966

Browse files
committed
improve types for wallet details
1 parent eab6a98 commit c00e966

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

src/api/wallet/wallet.controller.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import { Role } from 'src/core/auth/auth.constants';
1010
import { Roles, User } from 'src/core/auth/decorators';
1111
import { UserInfo } from 'src/dto/user.type';
1212
import { ResponseDto, ResponseStatusType } from 'src/dto/api-response.dto';
13-
import { WalletDetailDto, walletDetailResponseExample } from 'src/dto/wallet.dto';
13+
import {
14+
WalletDetailDto,
15+
walletDetailResponseExample,
16+
} from 'src/dto/wallet.dto';
1417

1518
import { WalletService } from './wallet.service';
1619

src/api/wallet/wallet.service.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ import { ResponseDto } from 'src/dto/api-response.dto';
77
import { WinningsType } from 'src/dto/winning.dto';
88
import { TaxFormRepository } from '../repository/taxForm.repo';
99
import { PaymentMethodRepository } from '../repository/paymentMethod.repo';
10-
import {
11-
RecipientTaxDetails,
12-
TrolleyService,
13-
} from 'src/shared/global/trolley.service';
10+
import { TrolleyService } from 'src/shared/global/trolley.service';
1411

1512
/**
1613
* The winning service.
@@ -36,10 +33,12 @@ export class WalletService {
3633
});
3734

3835
if (!recipient) {
39-
return {} as RecipientTaxDetails;
36+
return;
4037
}
4138

42-
return this.trolleyService.getRecipientTaxDetails(recipient.trolley_id);
39+
return await this.trolleyService.getRecipientTaxDetails(
40+
recipient.trolley_id,
41+
);
4342
}
4443

4544
/**
@@ -87,7 +86,7 @@ export class WalletService {
8786
taxForm: {
8887
isSetupComplete: hasActiveTaxForm,
8988
},
90-
...taxWithholdingDetails,
89+
...(taxWithholdingDetails ?? {}),
9190
};
9291
} catch (error) {
9392
this.logger.error('Getting winnings audit failed', error);

src/shared/global/trolley.service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export class TrolleyService {
177177

178178
async getRecipientTaxDetails(
179179
recipientId: string,
180-
): Promise<RecipientTaxDetails> {
180+
): Promise<RecipientTaxDetails | void> {
181181
try {
182182
const recipient = await this.client.recipient.find(recipientId);
183183
return pick(recipient, [
@@ -190,7 +190,6 @@ export class TrolleyService {
190190
'Failed to load recipient tax details from trolley!',
191191
error,
192192
);
193-
return {} as RecipientTaxDetails;
194193
}
195194
}
196195
}

0 commit comments

Comments
 (0)