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

Fix minor warnings on the PopoverList component #97

Merged
merged 2 commits into from
Aug 4, 2024
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
7 changes: 4 additions & 3 deletions src/frontend/src/i18n/useLanguageLabels.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useTranslation } from 'react-i18next'

const langageLabels: Record<string, string> = {
const languageLabels: Record<string, string> = {
en: 'English',
fr: 'Français',
de: 'Deutsch',
Expand All @@ -13,14 +13,15 @@ export const useLanguageLabels = () => {
(lang) => lang !== 'cimode'
)
const languagesList = supportedLanguages.map((lang) => ({
key: lang,
value: lang,
label: langageLabels[lang],
label: languageLabels[lang],
}))
return {
languagesList,
currentLanguage: {
key: i18n.language,
label: langageLabels[i18n.language],
label: languageLabels[i18n.language],
},
}
}
2 changes: 1 addition & 1 deletion src/frontend/src/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const Header = () => {
{user.email}
</Button>
<PopoverList
items={[{ value: 'logout', label: t('logout') }]}
items={[{ key: 'logout', value: 'logout', label: t('logout') }]}
onAction={(value) => {
if (value === 'logout') {
window.location.href = logoutUrl()
Expand Down
5 changes: 3 additions & 2 deletions src/frontend/src/primitives/PopoverList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,17 @@ export const PopoverList = <T extends string | number = string>({
}: {
closeOnAction?: boolean
onAction: (key: T) => void
items: Array<string | { value: T; label: ReactNode }>
items: Array<string | { key: string, value: T; label: ReactNode }>
} & ButtonProps) => {
const popoverState = useContext(OverlayTriggerStateContext)!
return (
<ul>
{items.map((item) => {
const value = typeof item === 'string' ? item : item.value
const label = typeof item === 'string' ? item : item.label
const key = typeof item === 'string' ? item : item.key
return (
<li>
<li key={key}>
<ListItem
key={value}
onPress={() => {
Expand Down