diff --git a/components/PartyDetails/index.tsx b/components/PartyDetails/index.tsx index b432f127..d10d70c6 100644 --- a/components/PartyDetails/index.tsx +++ b/components/PartyDetails/index.tsx @@ -1,5 +1,4 @@ import React, { useState } from "react" -import Head from "next/head" import { useRouter } from "next/router" import { useSnapshot } from "valtio" import { useTranslation } from "next-i18next" @@ -300,45 +299,8 @@ const PartyDetails = (props: Props) => { ) - const generateTitle = () => { - let title = party.raid ? `[${party.raid?.name[locale]}] ` : "" - - const username = - party.user != null ? `@${party.user?.username}` : t("header.anonymous") - - if (party.name != null) - title += t("header.byline", { partyName: party.name, username: username }) - else if (party.name == null && party.editable && router.route === "/new") - title = t("header.new_team") - else - title += t("header.untitled_team", { - username: username, - }) - - return title - } - return (
- - {generateTitle()} - - - - - - - - - - - {editable && (party.name || party.description || party.raid) ? readOnly : emptyDetails} diff --git a/pages/p/[party].tsx b/pages/p/[party].tsx index 672c8084..8c5ed450 100644 --- a/pages/p/[party].tsx +++ b/pages/p/[party].tsx @@ -1,6 +1,9 @@ import React, { useEffect } from "react" +import Head from "next/head" import { getCookie } from "cookies-next" import { serverSideTranslations } from "next-i18next/serverSideTranslations" +import { useRouter } from "next/router" +import { useTranslation } from "next-i18next" import Party from "~components/Party" @@ -18,6 +21,10 @@ interface Props { } const PartyRoute: React.FC = (props: Props) => { + const { t } = useTranslation("common") + const router = useRouter() + const locale = router.locale || "en" + useEffect(() => { persistStaticData() }, [persistStaticData]) @@ -28,9 +35,51 @@ const PartyRoute: React.FC = (props: Props) => { appState.jobSkills = props.jobSkills } + const title = () => { + let title = props.party.raid ? `[${props.party.raid?.name[locale]}] ` : "" + + const username = + props.party.user != null + ? `@${props.party.user?.username}` + : t("header.anonymous") + + if (props.party.name != null) + title += t("header.byline", { + partyName: props.party.name, + username: username, + }) + else + title += t("header.untitled_team", { + username: username, + }) + + return title + } + return ( -
- +
+ + {title()} + + + + + + + + + + + +
+ +
) }