From 0ae26a6633591cdaf94f3341dea3e7f79c7da72b Mon Sep 17 00:00:00 2001 From: Matchu Date: Mon, 22 Feb 2021 19:11:03 -0800 Subject: [PATCH] [WIP] UI for isManuallyNc support tool --- src/app/ItemPage.js | 4 ++ src/app/ItemPageLayout.js | 75 +++++++++++++++++++++++++++++- src/app/components/ItemCard.js | 83 ++++++++++++++++++++++++---------- src/server/types/Item.js | 9 ++++ 4 files changed, 145 insertions(+), 26 deletions(-) diff --git a/src/app/ItemPage.js b/src/app/ItemPage.js index 8184285..6b4c165 100644 --- a/src/app/ItemPage.js +++ b/src/app/ItemPage.js @@ -74,6 +74,10 @@ export function ItemPageContent({ itemId, isEmbedded }) { thumbnailUrl description createdAt + + # For Support users. + rarityIndex + isManuallyNc } } `, diff --git a/src/app/ItemPageLayout.js b/src/app/ItemPageLayout.js index aaba706..67c48de 100644 --- a/src/app/ItemPageLayout.js +++ b/src/app/ItemPageLayout.js @@ -1,5 +1,18 @@ import React from "react"; -import { Badge, Box, Skeleton, Tooltip } from "@chakra-ui/react"; +import { + Badge, + Box, + Flex, + Popover, + PopoverArrow, + PopoverContent, + PopoverTrigger, + Portal, + Select, + Skeleton, + Tooltip, + VStack, +} from "@chakra-ui/react"; import { ExternalLinkIcon, ChevronRightIcon } from "@chakra-ui/icons"; import { @@ -9,6 +22,8 @@ import { } from "./components/ItemCard"; import { Heading1 } from "./util"; +import useSupport from "./WardrobePage/support/useSupport"; + function ItemPageLayout({ children, item, isEmbedded }) { return ( @@ -91,7 +106,7 @@ function ItemPageBadges({ item, isEmbedded }) { return ( - + { // If the createdAt date is null (loaded and empty), hide the badge. @@ -188,6 +203,62 @@ function ItemPageBadges({ item, isEmbedded }) { ); } +function ItemKindBadgeWithSupportTools({ item }) { + const { isSupportUser } = useSupport(); + + const ncRef = React.useRef(null); + + const isNcAutoDetectedFromRarity = + item.rarityIndex === 500 || item.rarityIndex === 0; + + if (isSupportUser && item.rarityIndex != null && item.isManuallyNc != null) { + // TODO: Could code-split this into a SupportOnly file... + return ( + + + + + + + + + Support + + + + + Rarity: + + + {item.rarityIndex} ( + {isNcAutoDetectedFromRarity ? "NC" : "not NC"}) + + + + + NC: + + + + + + + + ); + } + + return ; +} + function LinkBadge({ children, href, isEmbedded }) { return ( { return ( - + NC + {isEditButton && } ); -} +}); -export function NpBadge() { +export const NpBadge = React.forwardRef(({ isEditButton, ...props }, ref) => { return ( - NP - - ); -} - -export function PbBadge() { - return ( - - - PB + + NP + {isEditButton && } ); -} +}); -export function ItemKindBadge({ isNc, isPb }) { - if (isNc) { - return ; - } else if (isPb) { - return ; - } else { - return ; +export const PbBadge = React.forwardRef(({ isEditButton, ...props }, ref) => { + return ( + + + PB + {isEditButton && } + + + ); +}); + +export const ItemKindBadge = React.forwardRef( + ({ isNc, isPb, isEditButton, ...props }, ref) => { + if (isNc) { + return ; + } else if (isPb) { + return ; + } else { + return ; + } } -} +); export function YouOwnThisBadge({ variant = "long" }) { let badge = ( diff --git a/src/server/types/Item.js b/src/server/types/Item.js index 2205858..d653bc7 100644 --- a/src/server/types/Item.js +++ b/src/server/types/Item.js @@ -54,6 +54,11 @@ const typeDefs = gql` # layer data from this API should be interpreted! explicitlyBodySpecific: Boolean! @cacheControl(maxAge: 0) + # This is set manually by Support users, when the item is from the NC Mall + # but isn't correctly labeled as r500 on Neopets.com. When this is true, + # it sets isNc to be true as well, regardless of rarityIndex. + isManuallyNc: Boolean! + # Get the species that we need modeled for this item for the given color. # # NOTE: Most color IDs won't be accepted here. Either pass the ID of a @@ -328,6 +333,10 @@ const resolvers = { const item = await itemLoader.load(id); return item.explicitlyBodySpecific; }, + isManuallyNc: async ({ id }, _, { itemLoader }) => { + const item = await itemLoader.load(id); + return item.isManuallyNc; + }, speciesThatNeedModels: async ( { id }, { colorId = "8" }, // Blue