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

feat(app): update language options for sign language options, fix language picker bug for sign language options #1472

Merged
merged 3 commits into from
Mar 8, 2025
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/app/public/locales/en/attribute.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@
},
"lang": {
"CATEGORYNAME": "Languages",
"all-languages-by-interpreter": "All languages via interpreter",
"american-sign-language": "American Sign Language",
"all-languages-by-interpreter": "Language assistance available. Contact for more information.",
"american-sign-language": "American Sign Language (ASL)",
"lang-offered": "Specific languages offered"
},
"orgleader": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { type MigrationJob } from '~db/prisma/dataMigrationRunner'
import { type JobDef } from '~db/prisma/jobPreRun'

/** Define the job metadata here. */
const jobDef: JobDef = {
jobId: '2025-03-05_update-attribute-values-asl',
title: 'change the name values for ASL',
createdBy: 'Diana Garbarino',
/** Optional: Longer description for the job */
description: 'change the name values for ASL',
}
/**
* Job export - this variable MUST be UNIQUE
*/
export const job20250305_update_attribute_values_asl = {
title: `[${jobDef.jobId}] ${jobDef.title}`,
task: async (ctx, task) => {
const { createLogger, formatMessage, jobPostRunner, prisma } = ctx
/** Create logging instance */
createLogger(task, jobDef.jobId)
const log = (...args: Parameters<typeof formatMessage>) => (task.output = formatMessage(...args))

// Variables for the update
const key = 'lang.american-sign-language'
const ns = 'attribute'
const newTextValue = 'American Sign Language (ASL)'
// Perform the update
const update1 = await prisma.translationKey.update({
where: { ns_key: { key, ns } },
data: { text: newTextValue },
})

log(`Updated translationKey: ${update1.key} with new text: "${update1.text}"`)

const update2 = await prisma.attribute.updateMany({
where: { tsKey: key, tsNs: ns },
data: { name: newTextValue },
})

log(`Updated ${update2.count} attributes with new name: "${newTextValue}"`)

/**
* DO NOT REMOVE BELOW
*
* This writes a record to the DB to register that this migration has run successfully.
*/
await jobPostRunner(jobDef)
},
def: jobDef,
} satisfies MigrationJob
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { type MigrationJob } from '~db/prisma/dataMigrationRunner'
import { type JobDef } from '~db/prisma/jobPreRun'

/** Define the job metadata here. */
const jobDef: JobDef = {
jobId: '2025-03-05_update-attribute-values-lang-inter',
title: 'change the name values for All Languages',
createdBy: 'Diana Garbarino',
/** Optional: Longer description for the job */
description: 'change the name values for All Languages',
}
/**
* Job export - this variable MUST be UNIQUE
*/
export const job20250305_update_attribute_values_lang_inter = {
title: `[${jobDef.jobId}] ${jobDef.title}`,
task: async (ctx, task) => {
const { createLogger, formatMessage, jobPostRunner, prisma } = ctx
/** Create logging instance */
createLogger(task, jobDef.jobId)
const log = (...args: Parameters<typeof formatMessage>) => (task.output = formatMessage(...args))

// Variables for the update
const key = 'lang.all-languages-by-interpreter'
const ns = 'attribute'
const newTextValue = 'Language assistance available. Contact for more information.'
// Perform the update
const update1 = await prisma.translationKey.update({
where: { ns_key: { key, ns } },
data: { text: newTextValue },
})

log(`Updated translationKey: ${update1.key} with new text: "${update1.text}"`)

const update2 = await prisma.attribute.updateMany({
where: { tsKey: key, tsNs: ns },
data: { name: newTextValue },
})

log(`Updated ${update2.count} attributes with new name: "${newTextValue}"`)

/**
* DO NOT REMOVE BELOW
*
* This writes a record to the DB to register that this migration has run successfully.
*/
await jobPostRunner(jobDef)
},
def: jobDef,
} satisfies MigrationJob
2 changes: 2 additions & 0 deletions packages/db/prisma/data-migrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ export * from './2025-02-17_new_mental-health-service-tag'
export * from './2025-02-17_new-cost-attribute'
export * from './2025-02-17_update-medical-tags'
export * from './2025-03-01_update-locationbased-alert-string-add-emoji'
export * from './2025-03-05_update-attribute-values-asl'
export * from './2025-03-05_update-attribute-values-lang-inter'
export * from './2025-03-05_update-nationwide-locationbased-alert'
// codegen:end
2 changes: 1 addition & 1 deletion packages/ui/modals/Service/processor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export const processAttributes = ({
}

case 'lang': {
const langItem = processLangAttrib(attribute)
const langItem = processLangAttrib(attribute, t, locale)
if (langItem) {
output.lang.push(langItem)
}
Expand Down
35 changes: 23 additions & 12 deletions packages/ui/modals/Service/processors/langAttrib.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
import { type AttributeRecord } from '../types'

export const processLangAttrib = (record: AttributeRecord): LangAttribReturn => {
const { language, supplementId: id, active } = record
if (!language) {
return null
export const processLangAttrib = (
record: AttributeRecord,
t: (key: string, options?: { ns?: string; lng?: string }) => string,
locale: string = 'en'
): LangAttribReturn => {
const { language, supplementId: id, active, tsKey } = record
if (language) {
return {
id,
active,
childProps: {
children: language.languageName,
},
}
}
const { languageName } = language

return {
id,
active,
childProps: {
children: languageName,
},
if (tsKey) {
return {
id,
active,
childProps: {
children: t(tsKey, { ns: 'attribute', lng: locale }),
},
}
}
return null
}

export interface LangAttribOutput {
Expand Down
Loading