import { Table } from "react-bootstrap"; import { useTranslation } from "react-i18next"; import { useLoaderData, useRouteLoaderData } from "@remix-run/react"; import { loader as settingsLoader } from "../settings/route"; import { LoaderFunctionArgs, json } from "@remix-run/node"; import serverRequest, { getToken } from "~/lib/request.server"; import { PartialMember } from "~/lib/api/user"; import { limits } from "~/env.server"; import { DateTime } from "luxon"; import { idTimestamp } from "~/lib/utils"; export const loader = async ({ request }: LoaderFunctionArgs) => { const token = getToken(request); const members = await serverRequest("GET", "/users/@me/members", { token }); return json({ members, maxMemberCount: limits.member_count }); }; export default function SettingsIndex() { const { members, maxMemberCount } = useLoaderData(); const { user } = useRouteLoaderData("routes/settings")!; const { t } = useTranslation(); const createdAt = idTimestamp(user.id); return ( <>
{t("settings.general.id")} {user.id}
{t("settings.general.created")} {createdAt.toLocaleString(DateTime.DATETIME_MED)}
{t("settings.general.member-count")} {members.length}/{maxMemberCount}
); }