Skip to content

Commit

Permalink
fix(service-portal): Add locale to organ donation updates (#16089)
Browse files Browse the repository at this point in the history
* refactor: add locale to update organ donations regs

* cleanup

* cleanup

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and thoreyjona committed Oct 2, 2024
1 parent 03e0385 commit 39b4101
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ export class HealthDirectorateResolver {
@Audit()
async updateDonorStatus(
@Args('input') input: DonorInput,
@Args('locale', { type: () => String, nullable: true })
locale: Locale = 'is',
@CurrentUser() user: User,
): Promise<void> {
return this.api.updateDonorStatus(user, input)
return this.api.updateDonorStatus(user, input, locale)
}

/* Vaccinations */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export class HealthDirectorateService {
const lang: organLocale = locale === 'is' ? organLocale.Is : organLocale.En
const data: OrganDonorDto | null =
await this.organDonationApi.getOrganDonation(auth, lang)
// Fetch organ list to get all names in correct language to sort out the names of the organs the user has limitations for

if (data === null) {
return null
}
Expand Down Expand Up @@ -58,11 +56,19 @@ export class HealthDirectorateService {
return limitations
}

async updateDonorStatus(auth: Auth, input: DonorInput): Promise<void> {
return await this.organDonationApi.updateOrganDonation(auth, {
isDonor: input.isDonor,
exceptions: input.organLimitations ?? [],
})
async updateDonorStatus(
auth: Auth,
input: DonorInput,
locale: Locale,
): Promise<void> {
return await this.organDonationApi.updateOrganDonation(
auth,
{
isDonor: input.isDonor,
exceptions: input.organLimitations ?? [],
},
locale === 'is' ? organLocale.Is : organLocale.En,
)
}

/* Vaccinations */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@
"in": "query",
"description": "The IP address of the user",
"schema": { "type": "string" }
},
{
"name": "locale",
"required": false,
"in": "query",
"description": "The locale to use for the response",
"schema": { "$ref": "#/components/schemas/Locale" }
}
],
"requestBody": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ export class HealthDirectorateOrganDonationService {
public async updateOrganDonation(
auth: Auth,
input: UpdateOrganDonorDto,
locale: Locale,
): Promise<void> {
await this.organDonationApiWithAuth(
auth,
).meDonorStatusControllerUpdateOrganDonorStatus({
updateOrganDonorDto: input,
locale: locale,
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ query getOrgansList($locale: String) {
}
}

mutation updateOrganDonationInfo($input: HealthDirectorateOrganDonorInput!) {
healthDirectorateOrganDonationUpdateDonorStatus(input: $input)
mutation updateOrganDonationInfo(
$input: HealthDirectorateOrganDonorInput!
$locale: String
) {
healthDirectorateOrganDonationUpdateDonorStatus(
input: $input
locale: $locale
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ const OrganDonation = () => {
: formatMessage(m.iAmOrganDonorText)
: formatMessage(m.iAmNotOrganDonorText)

const heading = donorStatus?.isDonor
? donorStatus.limitations?.hasLimitations
? formatMessage(m.iAmOrganDonorWithExceptions)
: formatMessage(m.iAmOrganDonor)
: formatMessage(m.iAmNotOrganDonor)

return (
<Box>
<IntroHeader
Expand Down Expand Up @@ -57,13 +63,7 @@ const OrganDonation = () => {
{formatMessage(m.takeOnOrganDonation)}
</Text>
<ActionCard
heading={
donorStatus?.isDonor
? donorStatus.limitations?.hasLimitations
? formatMessage(m.iAmOrganDonorWithExceptions)
: formatMessage(m.iAmOrganDonor)
: formatMessage(m.iAmNotOrganDonor)
}
heading={heading}
text={cardText}
cta={{
url: HealthPaths.HealthOrganDonationRegistration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const Form2 = () => {
isDonor: radioValue === OPT_IN || radioValue === OPT_IN_EXCEPTIONS,
organLimitations: radioValue === OPT_IN_EXCEPTIONS ? limitations : [],
},
locale: lang,
},
})
}
Expand Down

0 comments on commit 39b4101

Please sign in to comment.