diff --git a/Foxnouns.Frontend/app/routes/$username/route.tsx b/Foxnouns.Frontend/app/routes/$username/route.tsx index 77f0f58..c558ac5 100644 --- a/Foxnouns.Frontend/app/routes/$username/route.tsx +++ b/Foxnouns.Frontend/app/routes/$username/route.tsx @@ -93,7 +93,7 @@ export default function UserPage() { {user.member_title || t("user.heading.members")}{" "} {isMeUser && ( // @ts-expect-error using as=Link causes an error here, even though it runs completely fine - )} diff --git a/Foxnouns.Frontend/app/routes/$username_.$member/route.tsx b/Foxnouns.Frontend/app/routes/$username_.$member/route.tsx index 2cb2a41..da72aed 100644 --- a/Foxnouns.Frontend/app/routes/$username_.$member/route.tsx +++ b/Foxnouns.Frontend/app/routes/$username_.$member/route.tsx @@ -41,7 +41,7 @@ export default function MemberPage() { You are currently viewing the public profile of {{ memberName }}.
- Edit profile + Edit profile
)} diff --git a/Foxnouns.Frontend/app/routes/auth.callback.discord/route.tsx b/Foxnouns.Frontend/app/routes/auth.callback.discord/route.tsx index d27d7d5..f1e8fb7 100644 --- a/Foxnouns.Frontend/app/routes/auth.callback.discord/route.tsx +++ b/Foxnouns.Frontend/app/routes/auth.callback.discord/route.tsx @@ -14,12 +14,15 @@ import { useActionData, useLoaderData, ShouldRevalidateFunction, + useNavigate, + Navigate, } from "@remix-run/react"; import { Trans, useTranslation } from "react-i18next"; import { Form, Button, Alert } from "react-bootstrap"; import ErrorAlert from "~/components/ErrorAlert"; import i18n from "~/i18next.server"; import { tokenCookieName } from "~/lib/utils"; +import { useEffect } from "react"; export const meta: MetaFunction = ({ data }) => { return [{ title: `${data?.meta.title || "Log in"} • pronouns.cc` }]; @@ -106,6 +109,16 @@ export default function DiscordCallbackPage() { const { t } = useTranslation(); const data = useLoaderData(); const actionData = useActionData(); + const navigate = useNavigate(); + + useEffect(() => { + setTimeout(() => { + if (data.hasAccount) { + navigate(`/@${data.user!.username}`); + } + }, 2000); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); if (data.hasAccount) { const username = data.user!.username; diff --git a/Foxnouns.Frontend/app/routes/settings._index/route.tsx b/Foxnouns.Frontend/app/routes/settings._index/route.tsx new file mode 100644 index 0000000..38ccd19 --- /dev/null +++ b/Foxnouns.Frontend/app/routes/settings._index/route.tsx @@ -0,0 +1,18 @@ +import { Table } from "react-bootstrap"; +import { useTranslation } from "react-i18next"; +import { useRouteLoaderData } from "@remix-run/react"; +import { loader as settingsLoader } from "../settings/route"; + +export default function SettingsIndex() { + const { user } = useRouteLoaderData("routes/settings")!; + const { t } = useTranslation(); + + return <> + + + + + +
{t("settings.general.id")}{user.id}
+ +} diff --git a/Foxnouns.Frontend/app/routes/settings/route.tsx b/Foxnouns.Frontend/app/routes/settings/route.tsx new file mode 100644 index 0000000..74123e9 --- /dev/null +++ b/Foxnouns.Frontend/app/routes/settings/route.tsx @@ -0,0 +1,65 @@ +import { LoaderFunctionArgs, json, redirect, MetaFunction } from "@remix-run/node"; +import i18n from "~/i18next.server"; +import serverRequest, { getToken } from "~/lib/request.server"; +import { User } from "~/lib/api/user"; +import { Link, Outlet, useLocation } from "@remix-run/react"; +import { Nav } from "react-bootstrap"; +import { useTranslation } from "react-i18next"; + +export const meta: MetaFunction = ({ data }) => { + return [{ title: `${data?.meta.title || "Settings"} • pronouns.cc` }]; +}; + +export const loader = async ({ request }: LoaderFunctionArgs) => { + const t = await i18n.getFixedT(request); + const token = getToken(request); + + if (token) { + try { + const user = await serverRequest("GET", "/users/@me", { token }); + return json({ user, meta: { title: t("settings.title") } }); + } catch (e) { + return redirect("/auth/log-in"); + } + } + + return redirect("/auth/log-in"); +}; + +export default function SettingsLayout() { + const { t } = useTranslation(); + const { pathname } = useLocation(); + + return ( + <> + +
+ +
+ + ); +} diff --git a/Foxnouns.Frontend/public/locales/en.json b/Foxnouns.Frontend/public/locales/en.json index bf974b6..da882a8 100644 --- a/Foxnouns.Frontend/public/locales/en.json +++ b/Foxnouns.Frontend/public/locales/en.json @@ -1,93 +1,106 @@ { - "error": { - "heading": "An error occurred", - "validation": { - "too-long": "Value is too long, maximum length is {{maxLength}}, current length is {{actualLength}}.", - "too-short": "Value is too short, minimum length is {{minLength}}, current length is {{actualLength}}.", - "disallowed-value": "The value <1>{{actualValue}} is not allowed here. Allowed values are: <4>{{allowedValues}}", - "generic": "The value <1>{{actualValue}} is not allowed here. Reason: {{reason}}", - "generic-no-value": "The value you entered is not allowed here. Reason: {{reason}}" - }, - "errors": { - "authentication-error": "There was an error validating your credentials.", - "authentication-required": "You need to log in.", - "bad-request": "Server rejected your input, please check anything for errors.", - "forbidden": "You are not allowed to perform that action.", - "generic-error": "An unknown error occurred.", - "internal-server-error": "Server experienced an internal error, please try again later.", - "member-not-found": "Member not found, please check your spelling and try again.", - "user-not-found": "User not found, please check your spelling and try again." - }, - "title": "An error occurred", - "more-info": "Click here for a more detailed error" - }, - "navbar": { - "view-profile": "View profile", - "settings": "Settings", - "log-out": "Log out", - "log-in": "Log in or sign up" - }, - "user": { - "avatar-alt": "Avatar for @{{username}}", - "heading": { - "names": "Names", - "pronouns": "Pronouns", - "members": "Members" - }, - "member-avatar-alt": "Avatar for {{name}}", - "member-hidden": "This member is unlisted, and not shown in your public member list.", - "own-profile-alert": "You are currently viewing your <1>public profile.<3><4>Edit your profile", - "create-member-button": "Create member", - "no-members-blurb": "You don't have any members yet.<1>Members are sub-profiles that can have their own avatar, names, pronouns, and preferred terms.<3>You can create a new member with the \"Create member\" button above. <6>(only you can see this)" - }, - "member": { - "avatar-alt": "Avatar for {{name}}", - "own-profile-alert": "You are currently viewing the <1>public profile of {{memberName}}.<5><6>Edit profile", - "back": "Back to {{name}}" - }, - "log-in": { - "callback": { - "title": { - "discord-success": "Log in with Discord", - "discord-register": "Register with Discord" - }, - "success": "Successfully logged in!", - "success-link": "Welcome back, <1>@{{username}}!", - "redirect-hint": "If you're not redirected to your profile in a few seconds, press the link above.", - "remote-username": { - "discord": "Your discord username" - }, - "username": "Username", - "sign-up-button": "Sign up", - "invalid-ticket": "Invalid ticket (it might have been too long since you logged in with Discord), please <2>try again.", - "invalid-username": "Invalid username", - "username-taken": "That username is already taken, please try something else." - }, - "title": "Log in", - "form-title": "Log in with email", - "email": "Email address", - "password": "Password", - "log-in-button": "Log in", - "register-with-email": "Register with email", - "3rd-party": { - "title": "Log in with another service", - "desc": "If you prefer, you can also log in with one of these services:", - "discord": "Log in with Discord", - "google": "Log in with Google", - "tumblr": "Log in with Tumblr" - }, - "invalid-credentials": "Invalid email address or password, please check your spelling and try again." - }, - "welcome": { - "title": "Welcome", - "header": "Welcome to pronouns.cc!", - "blurb": "{welcome.blurb}", - "customize-profile": "Customize your profile", - "customize-profile-blurb": "{welcome.customize-profile-blurb}", - "create-members": "Create members", - "create-members-blurb": "{welcome.create-members-blurb}", - "custom-preferences": "Customize your preferences", - "custom-preferences-blurb": "{welcome.custom-preferences-blurb}", - "profile-button": "Go to your profile" - } + "error": { + "heading": "An error occurred", + "validation": { + "too-long": "Value is too long, maximum length is {{maxLength}}, current length is {{actualLength}}.", + "too-short": "Value is too short, minimum length is {{minLength}}, current length is {{actualLength}}.", + "disallowed-value": "The value <1>{{actualValue}} is not allowed here. Allowed values are: <4>{{allowedValues}}", + "generic": "The value <1>{{actualValue}} is not allowed here. Reason: {{reason}}", + "generic-no-value": "The value you entered is not allowed here. Reason: {{reason}}" + }, + "errors": { + "authentication-error": "There was an error validating your credentials.", + "authentication-required": "You need to log in.", + "bad-request": "Server rejected your input, please check anything for errors.", + "forbidden": "You are not allowed to perform that action.", + "generic-error": "An unknown error occurred.", + "internal-server-error": "Server experienced an internal error, please try again later.", + "member-not-found": "Member not found, please check your spelling and try again.", + "user-not-found": "User not found, please check your spelling and try again." + }, + "title": "An error occurred", + "more-info": "Click here for a more detailed error" + }, + "navbar": { + "view-profile": "View profile", + "settings": "Settings", + "log-out": "Log out", + "log-in": "Log in or sign up" + }, + "user": { + "avatar-alt": "Avatar for @{{username}}", + "heading": { + "names": "Names", + "pronouns": "Pronouns", + "members": "Members" + }, + "member-avatar-alt": "Avatar for {{name}}", + "member-hidden": "This member is unlisted, and not shown in your public member list.", + "own-profile-alert": "You are currently viewing your <1>public profile.<3><4>Edit your profile", + "create-member-button": "Create member", + "no-members-blurb": "You don't have any members yet.<1>Members are sub-profiles that can have their own avatar, names, pronouns, and preferred terms.<3>You can create a new member with the \"Create member\" button above. <6>(only you can see this)" + }, + "member": { + "avatar-alt": "Avatar for {{name}}", + "own-profile-alert": "You are currently viewing the <1>public profile of {{memberName}}.<5><6>Edit profile", + "back": "Back to {{name}}" + }, + "log-in": { + "callback": { + "title": { + "discord-success": "Log in with Discord", + "discord-register": "Register with Discord" + }, + "success": "Successfully logged in!", + "success-link": "Welcome back, <1>@{{username}}!", + "redirect-hint": "If you're not redirected to your profile in a few seconds, press the link above.", + "remote-username": { + "discord": "Your discord username" + }, + "username": "Username", + "sign-up-button": "Sign up", + "invalid-ticket": "Invalid ticket (it might have been too long since you logged in with Discord), please <2>try again.", + "invalid-username": "Invalid username", + "username-taken": "That username is already taken, please try something else." + }, + "title": "Log in", + "form-title": "Log in with email", + "email": "Email address", + "password": "Password", + "log-in-button": "Log in", + "register-with-email": "Register with email", + "3rd-party": { + "title": "Log in with another service", + "desc": "If you prefer, you can also log in with one of these services:", + "discord": "Log in with Discord", + "google": "Log in with Google", + "tumblr": "Log in with Tumblr" + }, + "invalid-credentials": "Invalid email address or password, please check your spelling and try again." + }, + "welcome": { + "title": "Welcome", + "header": "Welcome to pronouns.cc!", + "blurb": "{welcome.blurb}", + "customize-profile": "Customize your profile", + "customize-profile-blurb": "{welcome.customize-profile-blurb}", + "create-members": "Create members", + "create-members-blurb": "{welcome.create-members-blurb}", + "custom-preferences": "Customize your preferences", + "custom-preferences-blurb": "{welcome.custom-preferences-blurb}", + "profile-button": "Go to your profile" + }, + "settings": { + "general": { + "id": "Your user ID" + }, + "title": "Settings", + "nav": { + "general-information": "General information", + "profile": "Base profile", + "members": "Members", + "authentication": "Authentication", + "export": "Export your data" + } + } }