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

fix(service-portal): Add locale to organ donation updates #16089

Merged
merged 4 commits into from
Sep 26, 2024
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
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
Loading