diff --git a/apps/storefront/src/pages/products/favourite.tsx b/apps/storefront/src/pages/products/favourite.tsx index 587968c..29059ff 100644 --- a/apps/storefront/src/pages/products/favourite.tsx +++ b/apps/storefront/src/pages/products/favourite.tsx @@ -1,10 +1,3 @@ -import Result from "@/components/shared/Result"; -import { - Favourite, - useFavouritesWithProductQuery, - useMeQuery, - useRemoveFromFavouriteMutation, -} from "@/generated/graphql"; import { AspectRatio, Box, @@ -19,9 +12,16 @@ import { VStack, useColorModeValue, } from "@chakra-ui/react"; +import Image from "next/image"; +import { + Favourite, + useFavouritesWithProductQuery, + useMeQuery, + useRemoveFromFavouriteMutation, +} from "@/generated/graphql"; +import Result from "@/components/shared/Result"; // import dayjs from "dayjs"; import ConfirmationModal from "@/components/helpers/ConfirmationModal"; -import Image from "next/image"; import HeadingGroup from "@/components/pages/account/HeadingGroup"; import Navbar from "@/components/shared/navbar"; import { PriceTag } from "@/components/shared/product/PriceTag"; diff --git a/apps/storefront/src/pages/test.tsx b/apps/storefront/src/pages/test.tsx index 089fbc4..9bd49f1 100644 --- a/apps/storefront/src/pages/test.tsx +++ b/apps/storefront/src/pages/test.tsx @@ -1,274 +1,3 @@ -import Result from "@/components/shared/Result"; -import { - Favourite, - useFavouritesWithProductQuery, - useMeQuery, - useRemoveFromFavouriteMutation, -} from "@/generated/graphql"; -import { - AspectRatio, - Box, - Button, - HStack, - Heading, - Link, - SimpleGrid, - Skeleton, - Stack, - Text, - VStack, - useColorModeValue, -} from "@chakra-ui/react"; -// import dayjs from "dayjs"; -import ConfirmationModal from "@/components/helpers/ConfirmationModal"; -import Image from "next/image"; -import HeadingGroup from "@/components/pages/account/HeadingGroup"; -import Navbar from "@/components/shared/navbar"; -import { PriceTag } from "@/components/shared/product/PriceTag"; -import services from "../../public/assets/services.svg"; +const TestPage = () =>
TestPage
; -const FavouritePage = () => { - const { data: user, loading: userLoading, error: userError } = useMeQuery(); - const { data, loading, error } = useFavouritesWithProductQuery({ - skip: !user?.me?.id, - }); - - if (error || userError) { - return ( - - ); - } - - return ( - <> - - - - - {/* eslint-disable-next-line no-nested-ternary */} - {loading || userLoading ? ( - Array(4) - .fill("favourite-skeleton") - .map((mock, index) => ( - - )) - ) : data?.favouritesWithProduct.length ? ( - data?.favouritesWithProduct?.map((favourite) => ( - - )) - ) : ( - - App screenshot - - - Nothing in Favourites - - - Save you favourite items here, so that you can buy it later. - - - - )} - - - - ); -}; - -export default FavouritePage; - -const FavouriteProductCard = ({ favourite }: { favourite: Favourite }) => { - const [removeFromFavouriteMutation, { loading }] = - useRemoveFromFavouriteMutation({ - refetchQueries: ["FavouritesWithProduct"], - }); - const { - name, - images: unsortedImages, - inventories, - identifier, - desc, - } = favourite.product; - - const images = [...unsortedImages]?.sort((a, b) => a.sequence - b.sequence); - - return ( - - - - - - {name} - - - {/* Starting from{" "} */} - - - - {/* - - - 12 Reviews - - */} - - - {desc} - - - - - - - { - removeFromFavouriteMutation({ - variables: { - productId: favourite.productId, - }, - }); - }} - colorScheme="red" - > - Remove - - - - - {" "} - - {name} - - - ); -}; - -const FavouriteProductCardSkeleton = () => ( - - - - - - - Hello Hello Hello Hello - - - - Hello Hello - - - - - - - Hello - - - - - - Hello - - - Hello - Hello - - - - {" "} - - Hello - - -); +export default TestPage;