Skip to content

Commit

Permalink
fix(service-portal-health): small refactor (#14939)
Browse files Browse the repository at this point in the history
Co-authored-by: Þorkell Máni Þorkelsson <mani@hugsmidjan.is>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored May 30, 2024
1 parent c4f12fb commit ffda333
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ export class InsuranceOverview {
explanation?: string

@Field(() => Date, { nullable: true })
from?: Date | null
from?: Date

@Field(() => InsuranceStatus)
status!: InsuranceStatus
@Field(() => InsuranceStatus, { nullable: true })
status?: InsuranceStatus

@Field(() => Int, { nullable: true })
maximumPayment?: number | null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ export class OverviewService {
}

if (!data.fileName || !data.contentType || !data.data) {
this.logger.warn(
'Missing data for getInsuranceConfirmation from external service',
{
category: LOG_CATEGORY,
},
)
this.logger.warn('Missing data from external service', {
category: LOG_CATEGORY,
})
return null
}

Expand All @@ -45,14 +42,16 @@ export class OverviewService {
}
}

async getInsuranceOverview(user: User): Promise<InsuranceOverview | null> {
async getInsuranceOverview(user: User): Promise<InsuranceOverview> {
const data = await this.api
.withMiddleware(new AuthMiddleware(user as Auth))
.getInsuranceOverview()
.catch(handle404)

if (!data) {
return null
return {
isInsured: false,
}
}

const codeEnum: InsuranceStatusType | undefined =
Expand All @@ -65,7 +64,7 @@ export class OverviewService {
return {
isInsured: !!data.isInsured,
explanation: data.explanation ?? '',
from: data.from,
from: data.from ?? undefined,
maximumPayment: data.maximumPayment,
ehicCardExpiryDate: data.ehicCardExpiryDate ?? undefined,
status: {
Expand Down
4 changes: 4 additions & 0 deletions libs/service-portal/health/src/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ export const messages = defineMessages({
id: 'sp.health:no-health-insurance',
defaultMessage: 'Þú ert ekki með sjúkratryggingu',
},
noHealthInsuranceMessage: {
id: 'sp.health:no-health-insurance-message',
defaultMessage: 'Síðasta trygging: {arg}',
},
paymentTarget: {
id: 'sp.health:payment-target',
defaultMessage: 'Greiðslumark',
Expand Down

0 comments on commit ffda333

Please sign in to comment.