diff --git a/web/client/src/components/ui/switch/LanguageSwitch.tsx b/web/client/src/components/ui/switch/LanguageSwitch.tsx new file mode 100644 index 00000000..671b7b2b --- /dev/null +++ b/web/client/src/components/ui/switch/LanguageSwitch.tsx @@ -0,0 +1,37 @@ +"use client"; + +import { Loader } from "lucide-react"; +import { FC } from "react"; + +import { Label } from "@/components/ui/label"; +import { Switch } from "@/components/ui/switch"; + +type LanguageSwitchProps = { + isEng: boolean; + isLoading: boolean; + label: string; + onCheckedChange: (checked: boolean) => void; +}; + +export const LanguageSwitch: FC = ({ + isEng, + isLoading, + label, + onCheckedChange, +}: LanguageSwitchProps) => { + return ( +
+ {isLoading ? ( + + ) : ( + + )} + + +
+ ); +}; diff --git a/web/client/src/components/ui/switch/index.tsx b/web/client/src/components/ui/switch/index.tsx new file mode 100644 index 00000000..fe347eb9 --- /dev/null +++ b/web/client/src/components/ui/switch/index.tsx @@ -0,0 +1,2 @@ +export * from "./switch"; +export * from "./LanguageSwitch"; diff --git a/web/client/src/components/ui/switch.tsx b/web/client/src/components/ui/switch/switch.tsx similarity index 100% rename from web/client/src/components/ui/switch.tsx rename to web/client/src/components/ui/switch/switch.tsx diff --git a/web/client/src/features/articles/components/ArticleListTemplate.tsx b/web/client/src/features/articles/components/ArticleListTemplate.tsx index 3ca67d3a..d5be2a72 100644 --- a/web/client/src/features/articles/components/ArticleListTemplate.tsx +++ b/web/client/src/features/articles/components/ArticleListTemplate.tsx @@ -10,8 +10,8 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { ArticleTabType } from "@/types/article"; import { LanguageStatus } from "@/types/language"; -import { ArticleLanguageSwitch } from "./ArticleLanguageSwitch"; import { ArticleList } from "./ArticleList"; +import { ArticleLanguageSwitch } from "./Switch"; import { fetchArticlesAPI } from "../actions/article"; type ArticleListTemplateProps = { diff --git a/web/client/src/features/articles/components/ArticleLanguageSwitch.tsx b/web/client/src/features/articles/components/Switch/ArticleLanguageSwitch.tsx similarity index 72% rename from web/client/src/features/articles/components/ArticleLanguageSwitch.tsx rename to web/client/src/features/articles/components/Switch/ArticleLanguageSwitch.tsx index 1329621d..6c02ae2f 100644 --- a/web/client/src/features/articles/components/ArticleLanguageSwitch.tsx +++ b/web/client/src/features/articles/components/Switch/ArticleLanguageSwitch.tsx @@ -1,11 +1,9 @@ "use client"; -import { Loader } from "lucide-react"; import { useRouter } from "next/navigation"; import { FC, useCallback, useState } from "react"; -import { Label } from "@/components/ui/label"; -import { Switch } from "@/components/ui/switch"; +import { LanguageSwitch } from "@/components/ui/switch"; import { ArticleTabType } from "@/types/article"; import { LanguageStatus } from "@/types/language"; @@ -42,14 +40,11 @@ export const ArticleLanguageSwitch: FC = ({ ); return ( -
- {isLoading ? ( - - ) : ( - - )} - - -
+ ); }; diff --git a/web/client/src/features/articles/components/Switch/index.tsx b/web/client/src/features/articles/components/Switch/index.tsx new file mode 100644 index 00000000..556c77b7 --- /dev/null +++ b/web/client/src/features/articles/components/Switch/index.tsx @@ -0,0 +1 @@ +export * from "./ArticleLanguageSwitch"; diff --git a/web/client/src/features/bookmarks/components/Switch/BookmarkLanguageSwitch.tsx b/web/client/src/features/bookmarks/components/Switch/BookmarkLanguageSwitch.tsx index d10e5caa..fed4b53b 100644 --- a/web/client/src/features/bookmarks/components/Switch/BookmarkLanguageSwitch.tsx +++ b/web/client/src/features/bookmarks/components/Switch/BookmarkLanguageSwitch.tsx @@ -1,11 +1,9 @@ "use client"; -import { Loader } from "lucide-react"; import { useRouter } from "next/navigation"; import { FC, useCallback, useState } from "react"; -import { Label } from "@/components/ui/label"; -import { Switch } from "@/components/ui/switch"; +import { LanguageSwitch } from "@/components/ui/switch"; import { LanguageStatus } from "@/types/language"; @@ -39,14 +37,11 @@ export const BookmarkLanguageSwitch: FC = ({ ); return ( -
- {isLoading ? ( - - ) : ( - - )} - - -
+ ); };