Skip to content

Commit 8d818c5

Browse files
committed
🧝🏻🦁 ↝ [ SGV2-10 SGV2-9 SGV2-2 FCDB-24 ] Updating components inside onboarding/index accordion
1 parent fc374a6 commit 8d818c5

File tree

3 files changed

+109
-45
lines changed

3 files changed

+109
-45
lines changed

components/Content/Inventory/UserOwnedItems.tsx

+71-1
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,80 @@ const OwnedItemsList: React.FC = () => {
8181
})}
8282
</div>
8383
);
84-
};
84+
};
8585

8686
export default OwnedItemsList;
8787

88+
interface InventoryItem {
89+
id: number;
90+
name: string;
91+
icon_url: string;
92+
quantity: number;
93+
}
94+
95+
export const ItemsVerticalList: React.FC = () => {
96+
const session = useSession();
97+
const [itemDetails, setItemDetails] = useState<InventoryItem[]>([]);
98+
const supabase = useSupabaseClient();
99+
100+
useEffect(() => {
101+
const fetchOwnedItems = async () => {
102+
try {
103+
if (!session) return;
104+
105+
const user = session.user.id;
106+
// Fetch owned items from the database
107+
const { data: ownedItemsData, error: ownedItemsError } = await supabase
108+
.from('inventoryUSERS')
109+
.select('*')
110+
.eq('owner', user)
111+
.gt('id', 20);
112+
113+
if (ownedItemsError) {
114+
throw ownedItemsError;
115+
}
116+
117+
if (ownedItemsData) {
118+
const itemIds = ownedItemsData.map(item => item.item);
119+
// Fetch details of owned items
120+
const { data: itemDetailsData, error: itemDetailsError } = await supabase
121+
.from('inventoryITEMS')
122+
.select('*')
123+
.in('id', itemIds);
124+
125+
if (itemDetailsError) {
126+
throw itemDetailsError;
127+
}
128+
129+
if (itemDetailsData) {
130+
setItemDetails(itemDetailsData);
131+
}
132+
}
133+
} catch (error) {
134+
console.error('Error fetching owned items:', error.message);
135+
}
136+
};
137+
138+
fetchOwnedItems();
139+
}, [session]);
140+
141+
return (
142+
<div className="w-full">
143+
{itemDetails.map(item => (
144+
<div key={item.id} className="flex items-center justify-between mb-2">
145+
<div className="flex items-center space-x-2">
146+
<div className="w-10 h-10 rounded-full overflow-hidden">
147+
<img src={item.icon_url} alt={item.name} className="w-full h-full object-cover" />
148+
</div>
149+
<p className="text-sm">{item.name}</p>
150+
</div>
151+
<p className="text-sm">x{item.quantity}</p>
152+
</div>
153+
))}
154+
</div>
155+
);
156+
};
157+
88158
export const SectorStructureOwned: React.FC<{ sectorid: string }> = ({ sectorid }) => {
89159
const supabase = useSupabaseClient();
90160
const session = useSession();

components/Gameplay/onboarding.tsx

+20-11
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ import { useState } from "react";
22
import { useSession } from "@supabase/auth-helpers-react";
33
import Link from "next/link";
44
import { InventoryBlock } from "../dashboard-logs";
5+
import { ItemsVerticalList } from "../Content/Inventory/UserOwnedItems";
6+
import { UserOwnedSectorGrid } from "../Content/Planets/Sectors/SectorSetup";
57

68
export function OnboardingWindows() {
79
const session = useSession();
810

911
return (
1012
<div className="w-full">
1113
<div className="container px-4 md:px-6">
12-
<div className="grid max-w-6xl grid-cols-3 md:grid-cols-2 lg:grid-cols-3 gap-4 items-start min-h-[calc(100vh-1px)] py-6 mx-auto">
14+
<div className="grid max-w-6xl grid-cols-3 md:grid-cols-2 lg:grid-cols-3 gap-4 items-start min-h-[calc(10vh-1px)] py-6 mx-auto">
1315
{Array.from({ length: 6 }, (_, index) => (
1416
<div key={index} className="collapse bg-base-200">
1517
<input type="radio" name="my-accordion-1" id={`accordion-${index}`} />
@@ -23,10 +25,15 @@ export function OnboardingWindows() {
2325
</div>
2426
))}
2527
</div>
28+
<style jsx>{`
29+
.grid-cols-3 > *:nth-child(n+4) {
30+
margin-top: calc(-1.5 * var(--accordion-collapsed-height));
31+
}
32+
`}</style>
2633
</div>
2734
</div>
28-
);
29-
}
35+
);
36+
};
3037

3138
function getAccordionIcon(index) {
3239
switch (index) {
@@ -50,17 +57,17 @@ function getAccordionIcon(index) {
5057
function getAccordionTitle(index) {
5158
switch (index) {
5259
case 0:
53-
return "Section 1 Title";
60+
return "Home";
5461
case 1:
55-
return "Section 2 Title";
62+
return "Missions";
5663
case 2:
5764
return "Inventory";
5865
case 3:
59-
return "Section 4 Title";
66+
return "Automations";
6067
case 4:
61-
return "Section 5 Title";
68+
return "Sectors";
6269
case 5:
63-
return "Section 6 Title";
70+
return "Structures";
6471
default:
6572
return null;
6673
}
@@ -74,14 +81,16 @@ function getAccordionContent(index) {
7481
return <p>Content for Section 2</p>;
7582
case 2:
7683
return (
77-
<InventoryBlock />
84+
<ItemsVerticalList />
7885
);
7986
case 3:
8087
return <p>Content for Section 4</p>;
8188
case 4:
82-
return <p>Content for Section 5</p>;
89+
return (
90+
<UserOwnedSectorGrid />
91+
);
8392
case 5:
84-
return <p>Content for Section 6</p>;
93+
return <p>A component that will show all the structures the user has created (along with a popup to use them)</p>;
8594
default:
8695
return null;
8796
}

pages/index.tsx

+18-33
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ export function PublicLanding() {
6868
const isDesktopOrLaptop = useMediaQuery({ query: '(min-width: 1224px)' });
6969
const isTabletOrMobile = useMediaQuery({ query: '(max-width: 1224px)' });
7070

71-
if (session && !profile?.location) {
72-
return (
73-
<p>Location</p>
74-
);
75-
};
71+
// if (session && !profile?.location) {
72+
// return (
73+
// <p>Location</p>
74+
// );
75+
// };
7676

7777
// if (session?.user?.id === 'cebdc7a2-d8af-45b3-b37f-80f328ff54d6' && isTabletOrMobile) {
7878
// return (
@@ -83,7 +83,8 @@ export function PublicLanding() {
8383
// );
8484
// };
8585

86-
if (session && profile?.location) {
86+
// if (session && profile?.location) {
87+
if (session) {
8788
return (
8889
<LayoutNoNav>
8990
<Navigation />
@@ -158,33 +159,17 @@ export function PublicLanding() {
158159
</div>
159160
{/* Menu Button */}
160161
{!showFeedOverlay && (
161-
<button
162-
onClick={handleOpenFeedOverlay}
163-
className="fixed bottom-2 left-1/2 transform -translate-x-1/2 mt-4 px-4 py-2 text-white rounded"
164-
>
165-
<a
166-
href="#_"
167-
className="inline-flex overflow-hidden text-white bg-gray-900 rounded group"
168-
>
169-
<span className="px-3.5 py-2 text-white bg-purple-500 group-hover:bg-purple-600 flex items-center justify-center">
170-
<svg
171-
className="w-5 h-5"
172-
fill="none"
173-
stroke="currentColor"
174-
viewBox="0 0 24 24"
175-
xmlns="http://www.w3.org/2000/svg"
176-
>
177-
<path
178-
strokeLinecap="round"
179-
strokeLinejoin="round"
180-
strokeWidth="2"
181-
d="M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z"
182-
></path>
183-
</svg>
184-
</span>
185-
<span className="pl-4 pr-5 py-2.5">Menu</span>
186-
</a>
187-
</button>
162+
<button
163+
onClick={handleOpenFeedOverlay}
164+
className="fixed bottom-2 left-1/2 transform -translate-x-1/2 mt-4 px-4 py-2 text-white rounded"
165+
>
166+
<a
167+
href="#_"
168+
className="inline-flex overflow-hidden text-white rounded group"
169+
>
170+
<img src='/Galaxy/Kepler-22.png' height='100' width='100' />
171+
</a>
172+
</button>
188173
)}
189174
</LayoutNoNav>
190175
);

0 commit comments

Comments
 (0)