Skip to content

Commit 5207db1

Browse files
Merge branch 'dev' into IN-982-location-org-attribute
2 parents 6f19060 + ac37684 commit 5207db1

File tree

6 files changed

+128
-15
lines changed

6 files changed

+128
-15
lines changed

apps/app/public/locales/en/attribute.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@
9999
},
100100
"lang": {
101101
"CATEGORYNAME": "Languages",
102-
"all-languages-by-interpreter": "All languages via interpreter",
103-
"american-sign-language": "American Sign Language",
102+
"all-languages-by-interpreter": "Language assistance available. Contact for more information.",
103+
"american-sign-language": "American Sign Language (ASL)",
104104
"lang-offered": "Specific languages offered"
105105
},
106106
"orgleader": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { type MigrationJob } from '~db/prisma/dataMigrationRunner'
2+
import { type JobDef } from '~db/prisma/jobPreRun'
3+
4+
/** Define the job metadata here. */
5+
const jobDef: JobDef = {
6+
jobId: '2025-03-05_update-attribute-values-asl',
7+
title: 'change the name values for ASL',
8+
createdBy: 'Diana Garbarino',
9+
/** Optional: Longer description for the job */
10+
description: 'change the name values for ASL',
11+
}
12+
/**
13+
* Job export - this variable MUST be UNIQUE
14+
*/
15+
export const job20250305_update_attribute_values_asl = {
16+
title: `[${jobDef.jobId}] ${jobDef.title}`,
17+
task: async (ctx, task) => {
18+
const { createLogger, formatMessage, jobPostRunner, prisma } = ctx
19+
/** Create logging instance */
20+
createLogger(task, jobDef.jobId)
21+
const log = (...args: Parameters<typeof formatMessage>) => (task.output = formatMessage(...args))
22+
23+
// Variables for the update
24+
const key = 'lang.american-sign-language'
25+
const ns = 'attribute'
26+
const newTextValue = 'American Sign Language (ASL)'
27+
// Perform the update
28+
const update1 = await prisma.translationKey.update({
29+
where: { ns_key: { key, ns } },
30+
data: { text: newTextValue },
31+
})
32+
33+
log(`Updated translationKey: ${update1.key} with new text: "${update1.text}"`)
34+
35+
const update2 = await prisma.attribute.updateMany({
36+
where: { tsKey: key, tsNs: ns },
37+
data: { name: newTextValue },
38+
})
39+
40+
log(`Updated ${update2.count} attributes with new name: "${newTextValue}"`)
41+
42+
/**
43+
* DO NOT REMOVE BELOW
44+
*
45+
* This writes a record to the DB to register that this migration has run successfully.
46+
*/
47+
await jobPostRunner(jobDef)
48+
},
49+
def: jobDef,
50+
} satisfies MigrationJob
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { type MigrationJob } from '~db/prisma/dataMigrationRunner'
2+
import { type JobDef } from '~db/prisma/jobPreRun'
3+
4+
/** Define the job metadata here. */
5+
const jobDef: JobDef = {
6+
jobId: '2025-03-05_update-attribute-values-lang-inter',
7+
title: 'change the name values for All Languages',
8+
createdBy: 'Diana Garbarino',
9+
/** Optional: Longer description for the job */
10+
description: 'change the name values for All Languages',
11+
}
12+
/**
13+
* Job export - this variable MUST be UNIQUE
14+
*/
15+
export const job20250305_update_attribute_values_lang_inter = {
16+
title: `[${jobDef.jobId}] ${jobDef.title}`,
17+
task: async (ctx, task) => {
18+
const { createLogger, formatMessage, jobPostRunner, prisma } = ctx
19+
/** Create logging instance */
20+
createLogger(task, jobDef.jobId)
21+
const log = (...args: Parameters<typeof formatMessage>) => (task.output = formatMessage(...args))
22+
23+
// Variables for the update
24+
const key = 'lang.all-languages-by-interpreter'
25+
const ns = 'attribute'
26+
const newTextValue = 'Language assistance available. Contact for more information.'
27+
// Perform the update
28+
const update1 = await prisma.translationKey.update({
29+
where: { ns_key: { key, ns } },
30+
data: { text: newTextValue },
31+
})
32+
33+
log(`Updated translationKey: ${update1.key} with new text: "${update1.text}"`)
34+
35+
const update2 = await prisma.attribute.updateMany({
36+
where: { tsKey: key, tsNs: ns },
37+
data: { name: newTextValue },
38+
})
39+
40+
log(`Updated ${update2.count} attributes with new name: "${newTextValue}"`)
41+
42+
/**
43+
* DO NOT REMOVE BELOW
44+
*
45+
* This writes a record to the DB to register that this migration has run successfully.
46+
*/
47+
await jobPostRunner(jobDef)
48+
},
49+
def: jobDef,
50+
} satisfies MigrationJob

packages/db/prisma/data-migrations/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,7 @@ export * from './2025-02-17_new_mental-health-service-tag'
2626
export * from './2025-02-17_new-cost-attribute'
2727
export * from './2025-02-17_update-medical-tags'
2828
export * from './2025-03-01_update-locationbased-alert-string-add-emoji'
29+
export * from './2025-03-05_update-attribute-values-asl'
30+
export * from './2025-03-05_update-attribute-values-lang-inter'
2931
export * from './2025-03-05_update-nationwide-locationbased-alert'
3032
// codegen:end

packages/ui/modals/Service/processor.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export const processAttributes = ({
178178
}
179179

180180
case 'lang': {
181-
const langItem = processLangAttrib(attribute)
181+
const langItem = processLangAttrib(attribute, t, locale)
182182
if (langItem) {
183183
output.lang.push(langItem)
184184
}

packages/ui/modals/Service/processors/langAttrib.ts

+23-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
11
import { type AttributeRecord } from '../types'
22

3-
export const processLangAttrib = (record: AttributeRecord): LangAttribReturn => {
4-
const { language, supplementId: id, active } = record
5-
if (!language) {
6-
return null
3+
export const processLangAttrib = (
4+
record: AttributeRecord,
5+
t: (key: string, options?: { ns?: string; lng?: string }) => string,
6+
locale: string = 'en'
7+
): LangAttribReturn => {
8+
const { language, supplementId: id, active, tsKey } = record
9+
if (language) {
10+
return {
11+
id,
12+
active,
13+
childProps: {
14+
children: language.languageName,
15+
},
16+
}
717
}
8-
const { languageName } = language
9-
10-
return {
11-
id,
12-
active,
13-
childProps: {
14-
children: languageName,
15-
},
18+
if (tsKey) {
19+
return {
20+
id,
21+
active,
22+
childProps: {
23+
children: t(tsKey, { ns: 'attribute', lng: locale }),
24+
},
25+
}
1626
}
27+
return null
1728
}
1829

1930
export interface LangAttribOutput {

0 commit comments

Comments
 (0)