mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-02-24 19:06:37 -05:00
Add language mapping based on locale for signup and filters
This commit is contained in:
@@ -178,6 +178,12 @@ export const LANGUAGE_CHOICES = {
|
||||
Zulu: 'zulu',
|
||||
}
|
||||
|
||||
export const LOCALE_TO_LANGUAGE: Record<string, string> = {
|
||||
en: 'english',
|
||||
fr: 'french',
|
||||
de: 'german',
|
||||
} as const
|
||||
|
||||
export const RACE_CHOICES = {
|
||||
'Black/African origin': 'african',
|
||||
'East Asian': 'asian',
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import {LOCALE_TO_LANGUAGE} from 'common/choices'
|
||||
import {MAX_INT, MIN_INT} from 'common/constants'
|
||||
import {FilterFields, initialFilters, OriginLocation} from 'common/filters'
|
||||
import {logger} from 'common/logging'
|
||||
@@ -11,19 +12,17 @@ import {debounce, isEqual} from 'lodash'
|
||||
import {useCallback, useEffect} from 'react'
|
||||
import {useIsLooking} from 'web/hooks/use-is-looking'
|
||||
import {usePersistentLocalState} from 'web/hooks/use-persistent-local-state'
|
||||
import {useLocale} from 'web/lib/locale'
|
||||
import {getLocale} from 'web/lib/locale-cookie'
|
||||
|
||||
export const useFilters = (you: Profile | undefined, fromSignup?: boolean) => {
|
||||
const isLooking = useIsLooking()
|
||||
const {locale} = useLocale()
|
||||
|
||||
// Set French as default language filter if from signup and locale is French
|
||||
const getInitialFilters = (): Partial<FilterFields> => {
|
||||
const baseFilters = isLooking
|
||||
? initialFilters
|
||||
: {...initialFilters, orderBy: 'created_time' as const}
|
||||
if (fromSignup && locale === 'fr') {
|
||||
return {...baseFilters, languages: ['french']}
|
||||
if (fromSignup) {
|
||||
baseFilters.languages = [LOCALE_TO_LANGUAGE[getLocale()]]
|
||||
}
|
||||
return baseFilters
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import {LOCALE_TO_LANGUAGE} from 'common/choices'
|
||||
import {ProfileWithoutUser} from 'common/profiles/profile'
|
||||
import {removeNullOrUndefinedProps} from 'common/util/object'
|
||||
import {useRouter} from 'next/router'
|
||||
@@ -54,7 +55,7 @@ export default function SignupPage() {
|
||||
}, [user, holdLoading])
|
||||
|
||||
const {locale} = useLocale()
|
||||
const language = {en: 'english', fr: 'french'}[locale]
|
||||
const language = LOCALE_TO_LANGUAGE[locale]
|
||||
|
||||
// Omit the id, created_time?
|
||||
const [profileForm, setProfileForm] = useState<ProfileWithoutUser>({
|
||||
|
||||
Reference in New Issue
Block a user