From 96fdd395e1d5e12faad3e0d80c2cb3d6135dacb5 Mon Sep 17 00:00:00 2001 From: Matchu Date: Fri, 18 Jun 2021 18:30:02 -0700 Subject: [PATCH] Add page titles to item list pages --- src/app/UserItemListPage.js | 7 +++++-- src/app/UserItemsPage.js | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/app/UserItemListPage.js b/src/app/UserItemListPage.js index 8e5a8f6..dbae28f 100644 --- a/src/app/UserItemListPage.js +++ b/src/app/UserItemListPage.js @@ -10,7 +10,7 @@ import { WrapItem, } from "@chakra-ui/react"; import { ArrowForwardIcon, ChevronRightIcon } from "@chakra-ui/icons"; -import { Heading1, MajorErrorMessage } from "./util"; +import { Heading1, MajorErrorMessage, usePageTitle } from "./util"; import { gql, useQuery } from "@apollo/client"; import { Link, useParams } from "react-router-dom"; import { HashLink } from "react-router-hash-link"; @@ -51,6 +51,10 @@ function UserItemListPage() { { variables: { listId }, context: { sendAuth: true } } ); + const closetList = data?.closetList; + + usePageTitle(closetList?.name); + if (loading) { return (
@@ -63,7 +67,6 @@ function UserItemListPage() { return ; } - const closetList = data?.closetList; if (!closetList) { return ; } diff --git a/src/app/UserItemsPage.js b/src/app/UserItemsPage.js index 7bb6973..282a8b4 100644 --- a/src/app/UserItemsPage.js +++ b/src/app/UserItemsPage.js @@ -36,7 +36,7 @@ import { Link, useHistory, useParams } from "react-router-dom"; import { useQuery, useLazyQuery, useMutation } from "@apollo/client"; import HangerSpinner from "./components/HangerSpinner"; -import { Heading1, Heading2, Heading3 } from "./util"; +import { Heading1, Heading2, Heading3, usePageTitle } from "./util"; import MarkdownAndSafeHTML from "./components/MarkdownAndSafeHTML"; import SupportOnly from "./WardrobePage/support/SupportOnly"; import useSupport from "./WardrobePage/support/useSupport"; @@ -86,6 +86,16 @@ function UserItemsPage() { { variables: { userId }, context: { sendAuth: true } } ); + let pageTitleText; + if (isCurrentUser) { + pageTitleText = "Your lists"; + } else if (data?.user) { + pageTitleText = `${data?.user?.username}'s lists`; + } else { + pageTitleText = null; + } + usePageTitle(pageTitleText); + if (loading) { return (
@@ -150,9 +160,7 @@ function UserItemsPage() { - - {isCurrentUser ? "Your items" : `${data.user.username}'s items`} - + {pageTitleText} {data.user.contactNeopetsUsername && (