Skip to content

Commit 75feedd

Browse files
committed
⚾️⚓️ ↝ working on inventory design for [ GP-10 ] structures
1 parent d1e79b2 commit 75feedd

File tree

4 files changed

+215
-26
lines changed

4 files changed

+215
-26
lines changed

components/Content/Planets/Activities/StructureCreate.tsx

+19-26
Original file line numberDiff line numberDiff line change
@@ -73,39 +73,32 @@ const StructureSelection: React.FC<StructureSelectionProps> = ({ onStructureSele
7373

7474
const handleStructureClick = async (structure: Structure) => {
7575
try {
76-
if (!session) {
77-
console.error("User session not available!");
78-
return;
79-
};
80-
81-
const payload = {
76+
const payload = JSON.stringify({
8277
user_id: session?.user?.id,
8378
structure_id: structure.id,
84-
};
85-
86-
console.log(payload);
87-
88-
const response = await fetch("http://127.0.0.1:5000/craft_structure", {
89-
method: "POST",
79+
});
80+
81+
const response = await fetch('http://127.0.0.1:5000/craft_structure', {
82+
method: 'POST',
9083
headers: {
91-
"Content-Type": "application/json",
84+
'Content-Type': 'application/json'
9285
},
93-
body: JSON.stringify(payload),
86+
body: payload
9487
});
95-
96-
if (!response.ok) {
97-
throw new Error(`HTTP Error! Status: ${response.status}`)
98-
};
99-
88+
10089
const data = await response.json();
101-
console.log(data);
102-
} catch (error) {
103-
console.error(error.message);
104-
};
90+
console.log('Response from Flask:', data);
10591

106-
onStructureSelected(structure);
107-
// createInventoryUserEntry(structure);
108-
setIsCalloutOpen(false);
92+
if (data.status === 'proceed') { // If the status is 'proceed', call createInventoryUserEntry
93+
createInventoryUserEntry(structure);
94+
}
95+
} catch (error) {
96+
console.error('Error:', error.message);
97+
}
98+
99+
onStructureSelected(structure);
100+
// createInventoryUserEntry(structure)
101+
setIsCalloutOpen(false);
109102
};
110103

111104
return (

components/Content/Planets/Base/BasePlanetSector.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import RoverImageGallery, { RoverImage, RoverImageNoHandle } from "../PlanetData
66
import axios from "axios";
77
import { RoverContentPostForm } from "../../CreatePostForm";
88
import StructureComponent, { PlacedStructures } from "../Activities/StructureCreate";
9+
import SectorStructures from "../Sectors/SectorStructures";
910

1011
const AddResourceToInventory = ({ resource }) => {
1112
const supabase = useSupabaseClient();
@@ -261,6 +262,7 @@ export default function BasePlanetSector({ sectorid }: { sectorid: string }) {
261262
<Card noPadding={false}>
262263
<AddResourceToInventory resource={deposit} />
263264
<p>{deposit}</p>
265+
<SectorStructures />
264266
<RoverImageNoHandle date='853' rover='opportunity' sectorNo={id} />
265267
<StructureComponent sectorId={sectorid} />
266268
<PlacedStructures sectorId={Number(sectorid)} />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
import Link from "next/link"
2+
3+
export default function SectorStructures() {
4+
return (
5+
<div className="flex flex-col min-h-screen items-center justify-center p-4 space-y-4 md:space-y-0 md:flex-row md:space-x-4">
6+
<div className="grid gap-4 w-full max-w-sm md:max-w-none md:grid-cols-3">
7+
<div className="flex flex-col items-center justify-center space-y-2">
8+
<div className="flex items-center justify-center w-20 h-20 rounded-full border-2 border-gray-100 border-dashed dark:border-gray-800">
9+
<SwordIcon className="w-8 h-8 text-gray-200 dark:text-gray-800 translate-y-1" />
10+
</div>
11+
<span className="text-sm font-medium">Sword</span>
12+
<Link className="text-sm underline" href="#">
13+
View More
14+
</Link>
15+
</div>
16+
<div className="flex flex-col items-center justify-center space-y-2">
17+
<div className="flex items-center justify-center w-20 h-20 rounded-full border-2 border-gray-100 border-dashed dark:border-gray-800">
18+
<PillIcon className="w-8 h-8 text-gray-200 dark:text-gray-800 translate-y-1" />
19+
</div>
20+
<span className="text-sm font-medium">Potion</span>
21+
<Link className="text-sm underline" href="#">
22+
View More
23+
</Link>
24+
</div>
25+
<div className="flex flex-col items-center justify-center space-y-2">
26+
<div className="flex items-center justify-center w-20 h-20 rounded-full border-2 border-gray-100 border-dashed dark:border-gray-800">
27+
<ShieldIcon className="w-8 h-8 text-gray-200 dark:text-gray-800 translate-y-1" />
28+
</div>
29+
<span className="text-sm font-medium">Shield</span>
30+
<Link className="text-sm underline" href="#">
31+
View More
32+
</Link>
33+
</div>
34+
<div className="flex flex-col items-center justify-center space-y-2">
35+
<div className="flex items-center justify-center w-20 h-20 rounded-full border-2 border-gray-100 border-dashed dark:border-gray-800">
36+
<ScrollIcon className="w-8 h-8 text-gray-200 dark:text-gray-800 translate-y-1" />
37+
</div>
38+
<span className="text-sm font-medium">Scroll</span>
39+
<Link className="text-sm underline" href="#">
40+
View More
41+
</Link>
42+
</div>
43+
<div className="flex flex-col items-center justify-center space-y-2">
44+
<div className="flex items-center justify-center w-20 h-20 rounded-full border-2 border-gray-100 border-dashed dark:border-gray-800">
45+
<AxeIcon className="w-8 h-8 text-gray-200 dark:text-gray-800 translate-y-1" />
46+
</div>
47+
<span className="text-sm font-medium">Axe</span>
48+
<Link className="text-sm underline" href="#">
49+
View More
50+
</Link>
51+
</div>
52+
<div className="flex flex-col items-center justify-center space-y-2">
53+
<div className="flex items-center justify-center w-20 h-20 rounded-full border-2 border-gray-100 border-dashed dark:border-gray-800">
54+
<BellRingIcon className="w-8 h-8 text-gray-200 dark:text-gray-800 translate-y-1" />
55+
</div>
56+
<span className="text-sm font-medium">Ring</span>
57+
<Link className="text-sm underline" href="#">
58+
View More
59+
</Link>
60+
</div>
61+
</div>
62+
</div>
63+
)
64+
}
65+
66+
function AxeIcon(props) {
67+
return (
68+
<svg
69+
{...props}
70+
xmlns="http://www.w3.org/2000/svg"
71+
width="24"
72+
height="24"
73+
viewBox="0 0 24 24"
74+
fill="none"
75+
stroke="currentColor"
76+
strokeWidth="2"
77+
strokeLinecap="round"
78+
strokeLinejoin="round"
79+
>
80+
<path d="m14 12-8.5 8.5a2.12 2.12 0 1 1-3-3L11 9" />
81+
<path d="M15 13 9 7l4-4 6 6h3a8 8 0 0 1-7 7z" />
82+
</svg>
83+
)
84+
}
85+
86+
87+
function BellRingIcon(props) {
88+
return (
89+
<svg
90+
{...props}
91+
xmlns="http://www.w3.org/2000/svg"
92+
width="24"
93+
height="24"
94+
viewBox="0 0 24 24"
95+
fill="none"
96+
stroke="currentColor"
97+
strokeWidth="2"
98+
strokeLinecap="round"
99+
strokeLinejoin="round"
100+
>
101+
<path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9" />
102+
<path d="M10.3 21a1.94 1.94 0 0 0 3.4 0" />
103+
<path d="M4 2C2.8 3.7 2 5.7 2 8" />
104+
<path d="M22 8c0-2.3-.8-4.3-2-6" />
105+
</svg>
106+
)
107+
}
108+
109+
110+
function PillIcon(props) {
111+
return (
112+
<svg
113+
{...props}
114+
xmlns="http://www.w3.org/2000/svg"
115+
width="24"
116+
height="24"
117+
viewBox="0 0 24 24"
118+
fill="none"
119+
stroke="currentColor"
120+
strokeWidth="2"
121+
strokeLinecap="round"
122+
strokeLinejoin="round"
123+
>
124+
<path d="m10.5 20.5 10-10a4.95 4.95 0 1 0-7-7l-10 10a4.95 4.95 0 1 0 7 7Z" />
125+
<path d="m8.5 8.5 7 7" />
126+
</svg>
127+
)
128+
}
129+
130+
131+
function ScrollIcon(props) {
132+
return (
133+
<svg
134+
{...props}
135+
xmlns="http://www.w3.org/2000/svg"
136+
width="24"
137+
height="24"
138+
viewBox="0 0 24 24"
139+
fill="none"
140+
stroke="currentColor"
141+
strokeWidth="2"
142+
strokeLinecap="round"
143+
strokeLinejoin="round"
144+
>
145+
<path d="M8 21h12a2 2 0 0 0 2-2v-2H10v2a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v3h4" />
146+
<path d="M19 17V5a2 2 0 0 0-2-2H4" />
147+
</svg>
148+
)
149+
}
150+
151+
152+
function ShieldIcon(props) {
153+
return (
154+
<svg
155+
{...props}
156+
xmlns="http://www.w3.org/2000/svg"
157+
width="24"
158+
height="24"
159+
viewBox="0 0 24 24"
160+
fill="none"
161+
stroke="currentColor"
162+
strokeWidth="2"
163+
strokeLinecap="round"
164+
strokeLinejoin="round"
165+
>
166+
<path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10" />
167+
</svg>
168+
)
169+
}
170+
171+
172+
function SwordIcon(props) {
173+
return (
174+
<svg
175+
{...props}
176+
xmlns="http://www.w3.org/2000/svg"
177+
width="24"
178+
height="24"
179+
viewBox="0 0 24 24"
180+
fill="none"
181+
stroke="currentColor"
182+
strokeWidth="2"
183+
strokeLinecap="round"
184+
strokeLinejoin="round"
185+
>
186+
<polyline points="14.5 17.5 3 6 3 3 6 3 17.5 14.5" />
187+
<line x1="13" x2="19" y1="19" y2="13" />
188+
<line x1="16" x2="20" y1="16" y2="20" />
189+
<line x1="19" x2="21" y1="21" y2="19" />
190+
</svg>
191+
)
192+
};

components/Section/Layout.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ const Layout: React.FC<DashboardLayoutProps> = ({ children }) => {
4949

5050
export default Layout;
5151

52+
53+
5254
export const InventoryLayout: React.FC<DashboardLayoutProps> = ({ children }) => {
5355
const [isMobile, setIsMobile] = useState(false);
5456
const [activeTab, setActiveTab] = useState('consumables')

0 commit comments

Comments
 (0)