import i18n from "~/i18next.server"; import { LoaderFunctionArgs, MetaFunction } from "@remix-run/node"; import { Link, useLoaderData, useRouteLoaderData } from "@remix-run/react"; import { Button, ListGroup } from "react-bootstrap"; import { loader as settingsLoader } from "~/routes/settings/route"; import { useTranslation } from "react-i18next"; import { AuthMethod, MeUser } from "~/lib/api/user"; import serverRequest from "~/lib/request.server"; import { AuthUrls } from "~/lib/api/auth"; export const meta: MetaFunction = ({ data }) => { return [{ title: `${data?.meta.title || "Authentication"} • pronouns.cc` }]; }; export const loader = async ({ request }: LoaderFunctionArgs) => { const t = await i18n.getFixedT(request); const urls = await serverRequest("POST", "/auth/urls", { isInternal: true }); return { urls, meta: { title: t("settings.auth.title") } }; }; export default function AuthSettings() { const { urls } = useLoaderData(); const { user } = useRouteLoaderData("routes/settings")!; return
{urls.email_enabled && }
; } function EmailSettings({ user }: { user: MeUser }) { const { t } = useTranslation(); const oneAuthMethod = user.auth_methods.length === 1; const emails = user.auth_methods.filter((m) => m.type === "EMAIL"); return ( <>

{t("settings.auth.email-addresses")}

{emails.length > 0 && ( <> {emails.map((e) => ( ))} )} {emails.length < 3 && (

{/* @ts-expect-error as=Link */}

)} ); } function EmailRow({ email, disabled }: { email: AuthMethod; disabled: boolean }) { const { t } = useTranslation(); return (
{email.remote_id}
{!disabled && (
{t("settings.auth.remove-auth-method")}
)}
); }