-
Notifications
You must be signed in to change notification settings - Fork 83
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: add form field list for translation #7778
base: feat/multi-lang-feature
Are you sure you want to change the base?
Changes from all commits
7a040ed
8a23dab
9479448
b86a73e
bfddd3f
cbe1239
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -1,5 +1,15 @@ | ||||||||
import { useParams } from 'react-router-dom' | ||||||||
|
||||||||
import { MultiLanguageSection } from './components/MultiLanguageSection/MultiLanguageSection' | ||||||||
import { TranslationListSection } from './components/MultiLanguageSection/TranslationListSection' | ||||||||
|
||||||||
export const SettingsMultiLangPage = (): JSX.Element => { | ||||||||
return <MultiLanguageSection /> | ||||||||
const { language } = useParams() | ||||||||
|
||||||||
return ( | ||||||||
<> | ||||||||
{!language ? <MultiLanguageSection /> : null} | ||||||||
{language ? <TranslationListSection language={language} /> : null} | ||||||||
Comment on lines
+11
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
</> | ||||||||
) | ||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { useCallback, useState } from 'react' | ||
import { BiEditAlt } from 'react-icons/bi' | ||
import { GoEye, GoEyeClosed } from 'react-icons/go' | ||
import { useNavigate, useParams } from 'react-router-dom' | ||
import { | ||
Box, | ||
Divider, | ||
|
@@ -14,6 +15,7 @@ import _ from 'lodash' | |
|
||
import { Language } from '~shared/types' | ||
|
||
import { ADMINFORM_ROUTE } from '~constants/routes' | ||
import { | ||
convertUnicodeLocaleToLanguage, | ||
getDefaultSupportedLanguages, | ||
|
@@ -40,7 +42,9 @@ const LanguageTranslationRow = ({ | |
isDefaultLanguage, | ||
isLast, | ||
}: LanguageTranslationRowProps): JSX.Element => { | ||
const { formId } = useParams() | ||
const { data: settings } = useAdminFormSettings() | ||
const navigate = useNavigate() | ||
|
||
const supportedLanguages = settings?.supportedLanguages ?? null | ||
|
||
|
@@ -74,6 +78,15 @@ const LanguageTranslationRow = ({ | |
[mutateFormSupportedLanguages, supportedLanguages], | ||
) | ||
|
||
const handleLanguageTranslationEditClick = useCallback( | ||
(language: Language) => { | ||
navigate( | ||
`${ADMINFORM_ROUTE}/${formId}/settings/multi-language/${language.toString()}`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
) | ||
}, | ||
[formId, navigate], | ||
) | ||
|
||
return ( | ||
<> | ||
<Flex alignItems="center" w="100%" py={2}> | ||
|
@@ -109,7 +122,9 @@ const LanguageTranslationRow = ({ | |
colorScheme="secondary" | ||
aria-label={`Add ${unicodeLocale} translations`} | ||
// TODO: Will add redirection to translation section in next PR | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose this comment can now be removed 😆 |
||
onClick={() => console.log('Edit translations')} | ||
onClick={() => | ||
handleLanguageTranslationEditClick(unicodeLocale) | ||
} | ||
/> | ||
</Tooltip> | ||
</HStack> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible to use
frontend/src/features/admin-form/settings/SettingsPage.tsx::tabConfig
to manage the deeplink for language? -- since language seemed to be a subpath of SettingsPage