import useTranslation from "next-translate/useTranslation" import { useEffect, useState } from "react" import InfiniteScroll from "react-infinite-scroll-component" import { useAuthentication } from "../../../tools/authentication" import type { GuildPublic as GuildPublicType } from "../../../models/Guild" import { Loader } from "../../design/Loader" import { GuildPublic } from "./GuildPublic" import { usePagination } from "../../../hooks/usePagination" import type { SocketData } from "../../../tools/handleSocketData" import { handleSocketData } from "../../../tools/handleSocketData" export const JoinGuildsPublic: React.FC = () => { const [search, setSearch] = useState("") const { authentication } = useAuthentication() const { t } = useTranslation() const { items, hasMore, nextPage, resetPagination, setItems } = usePagination({ api: authentication.api, url: "/guilds/public", }) useEffect(() => { authentication?.socket?.on( "guilds", (data: SocketData) => { handleSocketData({ data, setItems }) }, ) return () => { authentication?.socket?.off("guilds") } }, [authentication.socket, setItems]) useEffect(() => { resetPagination() nextPage({ search }) }, [resetPagination, nextPage, search]) const handleChange = (event: React.ChangeEvent): void => { setSearch(event.target.value) } return (
} > {items.map((guild) => { return })}
) }