From 2cfafce768f6563c48b37b82694e0012ac35548d Mon Sep 17 00:00:00 2001 From: Matchu Date: Sat, 12 Sep 2020 22:21:00 -0700 Subject: [PATCH] add own/want buttons to item page --- src/app/ItemPage.js | 132 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 130 insertions(+), 2 deletions(-) diff --git a/src/app/ItemPage.js b/src/app/ItemPage.js index 49b9954..487aa3f 100644 --- a/src/app/ItemPage.js +++ b/src/app/ItemPage.js @@ -2,12 +2,15 @@ import React from "react"; import { AspectRatio, Badge, + Button, Box, Skeleton, + VisuallyHidden, VStack, useColorModeValue, + useToast, } from "@chakra-ui/core"; -import { ExternalLinkIcon } from "@chakra-ui/icons"; +import { CheckIcon, ExternalLinkIcon, StarIcon } from "@chakra-ui/icons"; import gql from "graphql-tag"; import { useQuery } from "@apollo/client"; import { useParams } from "react-router-dom"; @@ -33,8 +36,9 @@ function ItemPage() { */ export function ItemPageContent({ itemId, isEmbedded }) { return ( - + + ); @@ -175,6 +179,130 @@ function LinkBadge({ children, href }) { ); } +function ItemPageOwnWantButtons({ itemId }) { + const [currentUserOwnsThis, setCurrentUserOwnsThis] = React.useState(false); + const [currentUserWantsThis, setCurrentUserWantsThis] = React.useState(false); + + const toast = useToast(); + + const { loading, error } = useQuery( + gql` + query ItemPageOwnWantButtons($itemId: ID!) { + item(id: $itemId) { + id + currentUserOwnsThis + currentUserWantsThis + } + } + `, + { + variables: { itemId }, + onCompleted: (data) => { + setCurrentUserOwnsThis(data.item.currentUserOwnsThis); + setCurrentUserWantsThis(data.item.currentUserWantsThis); + }, + } + ); + + if (error) { + return {error.message}; + } + + return ( + + + + { + setCurrentUserOwnsThis(e.target.checked); + toast({ + title: "Todo: This doesn't actually work yet!", + status: "info", + duration: 1500, + }); + }} + /> + + + + + + + { + setCurrentUserWantsThis(e.target.checked); + toast({ + title: "Todo: This doesn't actually work yet!", + status: "info", + duration: 1500, + }); + }} + /> + + + + + ); +} + +function IconCheckbox({ icon, isChecked, ...props }) { + return ( + + + + {icon} + + + ); +} + function ItemPageOutfitPreview({ itemId }) { const borderColor = useColorModeValue("green.700", "green.400");