Skip to content

Commit b27a1ab

Browse files
committed
feat(copilot): add pre-anesthesia questionnaire as default form for fr locale
1 parent 34ce30d commit b27a1ab

3 files changed

Lines changed: 29 additions & 8 deletions

File tree

copilot/src/lib/demo/forms.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export type FormId =
88
| 'state_scanned'
99
| 'cerfa_12485'
1010
| 'cerfa_14598'
11+
| 'pre_anesthesia'
1112
| 'custom'
1213

1314
export type FormConfig = {
@@ -85,6 +86,12 @@ const ALL_FORMS: Record<FormId, FormConfig> = {
8586
labelKey: 'forms.labels.cerfa14598',
8687
pdfUrl: `${CDN_BASE}/form-copilot/cerfa-14598.pdf`,
8788
},
89+
pre_anesthesia: {
90+
id: 'pre_anesthesia',
91+
useCaseKey: 'forms.useCases.healthcare',
92+
labelKey: 'forms.labels.preAnesthesia',
93+
pdfUrl: `${CDN_BASE}/form-copilot/pre-anesthesia.pdf`,
94+
},
8895
custom: {
8996
id: 'custom',
9097
useCaseKey: 'forms.useCases.custom',
@@ -95,11 +102,20 @@ const ALL_FORMS: Record<FormId, FormConfig> = {
95102

96103
const EN_ORDER: FormId[] = ['custom', 'w9', 'w4', 'i9', 'healthcare', 'hr']
97104
const NL_ORDER: FormId[] = ['custom', 'state', 'state_scanned']
98-
const FR_ORDER: FormId[] = ['custom', 'cerfa_12485', 'cerfa_14598']
105+
const FR_ORDER: FormId[] = ['custom', 'pre_anesthesia', 'cerfa_12485', 'cerfa_14598']
99106
const FALLBACK_ORDER: FormId[] = ['custom', 'w9']
100107

101108
export const DEFAULT_FORM_ID: FormId = 'w9'
102109

110+
// Per-locale landing default. The picker order's first non-custom entry is
111+
// the form a visitor sees on their first paint when no `?form=` is set.
112+
export const getDefaultFormIdForLocale = (locale: string): FormId => {
113+
if (locale === 'fr') {
114+
return 'pre_anesthesia'
115+
}
116+
return DEFAULT_FORM_ID
117+
}
118+
103119
// Locale-specific form catalogues. Non-EN locales default to a single
104120
// language-appropriate form (plus the "pick your own" slot). The use-case
105121
// modal remains anchored on US English forms regardless of UI locale —
@@ -131,4 +147,5 @@ export const isFormId = (value: unknown): value is FormId =>
131147
value === 'state_scanned' ||
132148
value === 'cerfa_12485' ||
133149
value === 'cerfa_14598' ||
150+
value === 'pre_anesthesia' ||
134151
value === 'custom'

copilot/src/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@
241241
"loonheffingenScanned": "Loonheffingen scanned",
242242
"cerfa12485": "CERFA 12485 (médecin traitant)",
243243
"cerfa14598": "CERFA 14598 (rupture conventionnelle)",
244+
"preAnesthesia": "Questionnaire pré-anesthésique",
244245
"custom": "Pick your own PDF"
245246
},
246247
"subtitles": {

copilot/src/routes/index.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { ChatPane } from '../components/chat/chat_pane'
77
import { WelcomeModal } from '../components/demo/welcome_modal'
88
import { EditorPane } from '../components/editor_pane'
99
import { Layout } from '../components/layout'
10-
import { DEFAULT_FORM_ID, type FormId, getFormsForLocale, isFormId } from '../lib/demo/forms'
10+
import { DEFAULT_FORM_ID, type FormId, getDefaultFormIdForLocale, getFormsForLocale, isFormId } from '../lib/demo/forms'
1111
import { useIframeBridge } from '../lib/embed-bridge-adapters/react'
1212
import { i18n, i18nReady, matchLocaleFromAcceptLanguage } from '../lib/i18n'
1313
import { DEFAULT_LANGUAGE_CODE, isLanguageCode } from '../lib/languages'
@@ -64,12 +64,15 @@ type HomeLoaderData = {
6464

6565
export const Route = createFileRoute('/')({
6666
component: Home,
67-
validateSearch: (raw: Record<string, unknown>): HomeSearch => ({
68-
form: isFormId(raw.form) ? raw.form : DEFAULT_FORM_ID,
69-
lang: isLanguageCode(raw.lang) ? raw.lang : DEFAULT_LANGUAGE_CODE,
70-
...(isShowParam(raw.show) ? { show: raw.show } : {}),
71-
...(typeof raw.share === 'string' && raw.share !== '' ? { share: raw.share } : {}),
72-
}),
67+
validateSearch: (raw: Record<string, unknown>): HomeSearch => {
68+
const lang = isLanguageCode(raw.lang) ? raw.lang : DEFAULT_LANGUAGE_CODE
69+
return {
70+
form: isFormId(raw.form) ? raw.form : getDefaultFormIdForLocale(lang),
71+
lang,
72+
...(isShowParam(raw.show) ? { show: raw.show } : {}),
73+
...(typeof raw.share === 'string' && raw.share !== '' ? { share: raw.share } : {}),
74+
}
75+
},
7376
beforeLoad: async ({ search }) => {
7477
// Wait for i18next's init() Promise to resolve before the route renders.
7578
// Without this, the very first render (SSR pass + first client paint)

0 commit comments

Comments
 (0)