730e2d8ca8
- Implemented CertificateGallery component to display certification images in a gallery format. - Created CertificationsSection component to showcase certifications with titles and descriptions. - Enhanced Gallery component to support animations and keyboard navigation. - Introduced Select component for dropdown selection with images. - Added utility functions for API responses and pagination handling. - Implemented localization functions for text and content. - Created a custom hook for detecting clicks outside of a component.
36 lines
940 B
TypeScript
36 lines
940 B
TypeScript
'use client';
|
|
|
|
import images from '@/assets/images/images';
|
|
import { TLocales } from '@/models/layout';
|
|
import Select from '@/components/uikit/select';
|
|
import { usePathname } from 'next/navigation';
|
|
|
|
const languages = [
|
|
{ value: 'en', label: 'English', image: images.en },
|
|
{ value: 'fa', label: 'فارسی', image: images.fa },
|
|
];
|
|
|
|
export default function LanguageSwitch() {
|
|
const pathname = usePathname();
|
|
const currentLocale = pathname.split('/')[1] as TLocales;
|
|
|
|
const changeLocale = (locale: string) => {
|
|
if (currentLocale === locale) return;
|
|
|
|
document.cookie = `locale=${locale}; path=/; max-age=31536000; samesite=lax`;
|
|
let newPath = pathname.replace(/^\/(en|fa)/, '');
|
|
if (newPath === '/') newPath = '';
|
|
|
|
window.location.pathname = `/${locale}${newPath}`;
|
|
};
|
|
|
|
return (
|
|
<Select
|
|
options={languages}
|
|
value={currentLocale}
|
|
onChange={changeLocale}
|
|
size="small"
|
|
/>
|
|
);
|
|
}
|