2023-09-21 10:35:53 +03:00
|
|
|
"use client";
|
|
|
|
|
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
|
|
|
|
import Field from "@/lib/components/ui/Field";
|
2023-10-30 16:52:47 +03:00
|
|
|
import Spinner from "@/lib/components/ui/Spinner";
|
2023-09-21 10:35:53 +03:00
|
|
|
|
2023-09-22 12:44:09 +03:00
|
|
|
import { PublicBrainItem } from "./components/PublicBrainItem/PublicBrainItem";
|
2023-09-21 10:35:53 +03:00
|
|
|
import { useBrainsLibrary } from "./hooks/useBrainsLibrary";
|
|
|
|
|
|
|
|
const BrainsLibrary = (): JSX.Element => {
|
2023-10-30 16:52:47 +03:00
|
|
|
const { displayingPublicBrains, searchBarText, setSearchBarText, isLoading } =
|
2023-09-21 10:35:53 +03:00
|
|
|
useBrainsLibrary();
|
|
|
|
const { t } = useTranslation("brain");
|
|
|
|
|
|
|
|
return (
|
2023-10-04 19:12:27 +03:00
|
|
|
<div className="flex flex-1 flex-col items-center">
|
2023-09-21 10:35:53 +03:00
|
|
|
<div className="flex">
|
|
|
|
<Field
|
|
|
|
value={searchBarText}
|
|
|
|
onChange={(e) => setSearchBarText(e.target.value)}
|
|
|
|
name="search"
|
2023-09-27 10:50:27 +03:00
|
|
|
inputClassName="w-max lg:min-w-[300px] md:min-w-[200px] min-w-[100px] mt-10 rounded-3xl bg-white lg:mb-5"
|
2023-09-21 10:35:53 +03:00
|
|
|
placeholder={t("public_brains_search_bar_placeholder")}
|
|
|
|
/>
|
|
|
|
</div>
|
2023-10-30 16:52:47 +03:00
|
|
|
{isLoading && (
|
|
|
|
<div className="flex justify-center items-center flex-1">
|
|
|
|
<Spinner className="text-4xl" />
|
|
|
|
</div>
|
|
|
|
)}
|
2023-09-21 10:35:53 +03:00
|
|
|
|
|
|
|
<div className="flex flex-wrap justify-stretch w-full">
|
|
|
|
{displayingPublicBrains.map((brain) => (
|
2023-09-27 10:50:27 +03:00
|
|
|
<div key={brain.id} className="lg:w-1/3 md:w-1/2 md:p-5 p-5 w-full">
|
2023-09-21 10:35:53 +03:00
|
|
|
<PublicBrainItem brain={brain} />
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default BrainsLibrary;
|