import { Group, Image, Select, Stack, Text } from '@mantine/core'; import { showNotification } from '@mantine/notifications'; import { IconLanguage } from '@tabler/icons'; import { forwardRef, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { convertCodeToName } from '../../translations/i18n'; export default function LanguageSwitch() { const { t, i18n } = useTranslation(); const { language, languages, changeLanguage } = i18n; const [selectedLanguage, setSelectedLanguage] = useState(language); const data = languages.map((language) => ({ image: `https://countryflagsapi.com/png/${language.split('-').pop()}`, label: convertCodeToName(language), value: language, })); const onChangeSelect = (value: string) => { setSelectedLanguage(value); const languageName = convertCodeToName(value); changeLanguage(value) .then(() => { showNotification({ title: 'Language changed', message: `You changed the language to '${languageName}'`, color: 'green', autoClose: 5000, }); }) .catch((err) => { showNotification({ title: 'Failed to change language', message: `Failed to change to '${languageName}', Error:'${err}`, color: 'red', autoClose: 5000, }); }); }; return (