remove unused LangSelect
This commit is contained in:
@@ -1,14 +0,0 @@
|
|||||||
.lang-item {
|
|
||||||
margin: 8px 0px;
|
|
||||||
padding: 0px 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.lang-item .avatar {
|
|
||||||
width: 30px;
|
|
||||||
height: 30px;
|
|
||||||
border-radius: 35%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.lang-dropdown-container ul {
|
|
||||||
padding: 10px 0px !important;
|
|
||||||
}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
|
|
||||||
import type { MenuProps } from "antd";
|
|
||||||
import { Avatar, Dropdown } from "antd";
|
|
||||||
|
|
||||||
import { useMemo } from "react";
|
|
||||||
|
|
||||||
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
|
||||||
import "./LangSelect.css";
|
|
||||||
|
|
||||||
type Locale = {
|
|
||||||
id: string;
|
|
||||||
title: string;
|
|
||||||
iconPath: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const LOCALES: Locale[] = [
|
|
||||||
{ id: "ar", title: "العربية", iconPath: "/saudi-arabia.svg" },
|
|
||||||
{ id: "en", title: "English", iconPath: "/america.svg" },
|
|
||||||
];
|
|
||||||
|
|
||||||
export default function LangSelect() {
|
|
||||||
const router = useRouter();
|
|
||||||
const pathname = usePathname();
|
|
||||||
const searchParams = useSearchParams();
|
|
||||||
|
|
||||||
const items: MenuProps["items"] = useMemo(
|
|
||||||
() =>
|
|
||||||
LOCALES.map((_locale) => ({
|
|
||||||
className: "lang-item",
|
|
||||||
key: _locale.id,
|
|
||||||
icon: (
|
|
||||||
<span>
|
|
||||||
<Avatar className="avatar" src={_locale.iconPath} />
|
|
||||||
</span>
|
|
||||||
),
|
|
||||||
label: _locale.title,
|
|
||||||
})),
|
|
||||||
[]
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Dropdown
|
|
||||||
menu={{
|
|
||||||
items,
|
|
||||||
onClick: ({ key }) => {
|
|
||||||
router.push(
|
|
||||||
pathname
|
|
||||||
.split("/")
|
|
||||||
.map((item, index) => {
|
|
||||||
if (index === 1) {
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
return item;
|
|
||||||
})
|
|
||||||
.join("/") +
|
|
||||||
(searchParams.toString() ? `?${searchParams.toString()}` : "")
|
|
||||||
);
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
overlayClassName="lang-dropdown-container"
|
|
||||||
>
|
|
||||||
<Avatar
|
|
||||||
style={{
|
|
||||||
position: "relative",
|
|
||||||
top: 1,
|
|
||||||
borderRadius: "35%",
|
|
||||||
width: 30,
|
|
||||||
height: 30,
|
|
||||||
}}
|
|
||||||
src={LOCALES[0]?.iconPath}
|
|
||||||
/>
|
|
||||||
</Dropdown>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user