Add page titles to item list pages
This commit is contained in:
parent
96d7fb70ff
commit
96fdd395e1
2 changed files with 17 additions and 6 deletions
|
@ -10,7 +10,7 @@ import {
|
||||||
WrapItem,
|
WrapItem,
|
||||||
} from "@chakra-ui/react";
|
} from "@chakra-ui/react";
|
||||||
import { ArrowForwardIcon, ChevronRightIcon } from "@chakra-ui/icons";
|
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 { gql, useQuery } from "@apollo/client";
|
||||||
import { Link, useParams } from "react-router-dom";
|
import { Link, useParams } from "react-router-dom";
|
||||||
import { HashLink } from "react-router-hash-link";
|
import { HashLink } from "react-router-hash-link";
|
||||||
|
@ -51,6 +51,10 @@ function UserItemListPage() {
|
||||||
{ variables: { listId }, context: { sendAuth: true } }
|
{ variables: { listId }, context: { sendAuth: true } }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const closetList = data?.closetList;
|
||||||
|
|
||||||
|
usePageTitle(closetList?.name);
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return (
|
return (
|
||||||
<Center>
|
<Center>
|
||||||
|
@ -63,7 +67,6 @@ function UserItemListPage() {
|
||||||
return <MajorErrorMessage error={error} variant="network" />;
|
return <MajorErrorMessage error={error} variant="network" />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const closetList = data?.closetList;
|
|
||||||
if (!closetList) {
|
if (!closetList) {
|
||||||
return <MajorErrorMessage variant="not-found" />;
|
return <MajorErrorMessage variant="not-found" />;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ import { Link, useHistory, useParams } from "react-router-dom";
|
||||||
import { useQuery, useLazyQuery, useMutation } from "@apollo/client";
|
import { useQuery, useLazyQuery, useMutation } from "@apollo/client";
|
||||||
|
|
||||||
import HangerSpinner from "./components/HangerSpinner";
|
import HangerSpinner from "./components/HangerSpinner";
|
||||||
import { Heading1, Heading2, Heading3 } from "./util";
|
import { Heading1, Heading2, Heading3, usePageTitle } from "./util";
|
||||||
import MarkdownAndSafeHTML from "./components/MarkdownAndSafeHTML";
|
import MarkdownAndSafeHTML from "./components/MarkdownAndSafeHTML";
|
||||||
import SupportOnly from "./WardrobePage/support/SupportOnly";
|
import SupportOnly from "./WardrobePage/support/SupportOnly";
|
||||||
import useSupport from "./WardrobePage/support/useSupport";
|
import useSupport from "./WardrobePage/support/useSupport";
|
||||||
|
@ -86,6 +86,16 @@ function UserItemsPage() {
|
||||||
{ variables: { userId }, context: { sendAuth: true } }
|
{ 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) {
|
if (loading) {
|
||||||
return (
|
return (
|
||||||
<Center>
|
<Center>
|
||||||
|
@ -150,9 +160,7 @@ function UserItemsPage() {
|
||||||
<Box>
|
<Box>
|
||||||
<Flex align="center" wrap="wrap-reverse">
|
<Flex align="center" wrap="wrap-reverse">
|
||||||
<Box>
|
<Box>
|
||||||
<Heading1>
|
<Heading1>{pageTitleText}</Heading1>
|
||||||
{isCurrentUser ? "Your items" : `${data.user.username}'s items`}
|
|
||||||
</Heading1>
|
|
||||||
<Wrap spacing="2" opacity="0.7">
|
<Wrap spacing="2" opacity="0.7">
|
||||||
{data.user.contactNeopetsUsername && (
|
{data.user.contactNeopetsUsername && (
|
||||||
<WrapItem>
|
<WrapItem>
|
||||||
|
|
Loading…
Reference in a new issue