From c870b6827f8b47e6c01a5403188092b6bcb9770b Mon Sep 17 00:00:00 2001 From: Liam Arbuckle Date: Tue, 26 Mar 2024 14:13:11 +0800 Subject: [PATCH] =?UTF-8?q?=EF=B8=8F=F0=9F=92=84=F0=9F=91=A9=E2=80=8D?= =?UTF-8?q?=F0=9F=91=A7=E2=80=8D=F0=9F=91=A6=20=E2=86=9D=20[SGV2-16]:=20Ge?= =?UTF-8?q?tting=20an=20idea=20of=20the=20full=20scope?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Content/Inventory/UserOwnedItems.tsx | 40 +++++---- components/_Core/Section/BentoBox.tsx | 81 +++++++++++++++++++ components/_Skeleton/InventoryBlocks.tsx | 13 +++ pages/tests/blocks.tsx | 11 +++ pages/tests/planetRing.tsx | 4 +- 5 files changed, 131 insertions(+), 18 deletions(-) create mode 100644 components/_Core/Section/BentoBox.tsx create mode 100644 components/_Skeleton/InventoryBlocks.tsx create mode 100644 pages/tests/blocks.tsx diff --git a/components/Content/Inventory/UserOwnedItems.tsx b/components/Content/Inventory/UserOwnedItems.tsx index 1c8d8447..4f7d958b 100644 --- a/components/Content/Inventory/UserOwnedItems.tsx +++ b/components/Content/Inventory/UserOwnedItems.tsx @@ -97,22 +97,26 @@ export const ItemsVerticalList: React.FC = () => { const supabase = useSupabaseClient(); const [ownedItems, setOwnedItems] = useState([]); const [itemDetails, setItemDetails] = useState([]); + const [isLoading, setIsLoading] = useState(true); // Loading state useEffect(() => { - const fetchOwnedItemsAndDetails = async () => { - if (!session) return; + if (!session || !supabase) { + return; + } + const fetchOwnedItemsAndDetails = async () => { try { + setIsLoading(true); const userId = session.user.id; // Fetch owned items from the database const { data: ownedItemsData, error: ownedItemsError } = await supabase - .from('inventoryUSERS') - .select('*') - .eq('owner', userId) - .gt('id', 20) + .from("inventoryUSERS") + .select("*") + .eq("owner", userId) + .gt("id", 20) .limit(6) - .order('id', { ascending: false}); + .order("id", { ascending: false }); if (ownedItemsError) { throw ownedItemsError; @@ -126,20 +130,20 @@ export const ItemsVerticalList: React.FC = () => { // Fetch details of owned items based on item IDs const { data: itemDetailsData, error: itemDetailsError } = await supabase - .from('inventoryITEMS') - .select('*') - .in('id', itemIds); + .from("inventoryITEMS") + .select("*") + .in("id", itemIds); if (itemDetailsError) { throw itemDetailsError; } - if (itemDetailsData) { - setItemDetails(itemDetailsData); - } + setItemDetails(itemDetailsData); } } catch (error) { - console.error('Error fetching owned items and details:', error); + console.error("Error fetching owned items and details:", error); + } finally { + setIsLoading(false); } }; @@ -148,15 +152,19 @@ export const ItemsVerticalList: React.FC = () => { // Combine owned items with their details const combinedItems = ownedItems.map(ownedItem => { - // Find the matching item detail based on item ID const itemDetail = itemDetails.find(detail => detail.id === ownedItem.item); - return { ...ownedItem, ...itemDetail, }; }); + // If the component is loading, you can display a loading indicator or message + if (isLoading) { + return
Loading...
; + } + + // Render the list of items return (
{combinedItems.map(item => ( diff --git a/components/_Core/Section/BentoBox.tsx b/components/_Core/Section/BentoBox.tsx new file mode 100644 index 00000000..85494750 --- /dev/null +++ b/components/_Core/Section/BentoBox.tsx @@ -0,0 +1,81 @@ +import React from "react"; +import { cn } from "../../../lib/uitls"; +import { RocketIcon } from "lucide-react"; +import { BentoGrid } from "../ui/bento-grid"; +import { InventoryOneList, InventoryTwoList } from "../../_Skeleton/InventoryBlocks"; + +export default function BlockGrid() { + return ( + + {items.map((item, i) => ( + p:text-lg]", item.className)} + /> + ))} + + ); +}; + +// Boxes +export const BentoBoxItem = ({ + title, + description, + className, + header, +}: { + title?: string | React.ReactNode; + description?: string | React.ReactNode; + className?: string | React.ReactNode; + header?: React.ReactNode; +}) => { + return ( +
+ {header} + + {/*
+ +
+ {title} +
+
+ {description} +
+
*/} +
+ ); +}; + +// Items +const items = [ + { + title: "Inventory list", // Rover Temperature Control Panel" + description: ( + + + + ), + icon: RocketIcon, + header: , + className: "md:col-span-1", + }, + { + title: "Inventory list 2", // Rover Temperature Control Panel" + description: ( + + + + ), + icon: RocketIcon, + header: , + className: "md:col-span-1", + }, +]; \ No newline at end of file diff --git a/components/_Skeleton/InventoryBlocks.tsx b/components/_Skeleton/InventoryBlocks.tsx new file mode 100644 index 00000000..cbb102f0 --- /dev/null +++ b/components/_Skeleton/InventoryBlocks.tsx @@ -0,0 +1,13 @@ +import OwnedItemsList, { ItemsVerticalList } from "../Content/Inventory/UserOwnedItems"; + +export const InventoryOneList = () => { + return ( + + ); +}; + +export const InventoryTwoList = () => { + return ( + + ); +}; \ No newline at end of file diff --git a/pages/tests/blocks.tsx b/pages/tests/blocks.tsx new file mode 100644 index 00000000..40ae54d9 --- /dev/null +++ b/pages/tests/blocks.tsx @@ -0,0 +1,11 @@ +import React from "react"; +import { LayoutNoNav } from "../../components/_Core/Section/Layout"; +import BlockGrid from "../../components/_Core/Section/BentoBox"; + +export default function AllBlocksTestPage() { + return ( + + + + ); +}; \ No newline at end of file diff --git a/pages/tests/planetRing.tsx b/pages/tests/planetRing.tsx index 8d0c3928..23ba5445 100644 --- a/pages/tests/planetRing.tsx +++ b/pages/tests/planetRing.tsx @@ -1,5 +1,5 @@ export default function PlanetRingTestPage() { return ( <>p - ) -} \ No newline at end of file + ); +}; \ No newline at end of file