Skip to content

Commit 745d710

Browse files
committed
βš½οΈŽπŸ‘¨πŸ»β€βœˆοΈ ↝ Attempting to create sectors with more than just iron/coal
1 parent 5b2959a commit 745d710

File tree

1 file changed

+39
-7
lines changed

1 file changed

+39
-7
lines changed

β€Žcomponents/Content/Planets/Activities/SectorSetup.tsx

+39-7
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,55 @@ export default function CreateBasePlanetSector() {
3838
const createSector = async () => {
3939
if (session) {
4040
fetchUserPlanet();
41+
42+
// Array of available resources
43+
const resources = ["Silicates", "Alloy", "Iron", "Fuel", "Water", "Coal"];
44+
45+
// Randomly choose a resource
46+
const chosenResource = resources[Math.floor(Math.random() * resources.length)];
47+
48+
// Get the corresponding row from inventoryITEMS
49+
let depositRowId;
50+
if (chosenResource === "Coal") {
51+
depositRowId = 11; // Row ID for Coal
52+
} else if (chosenResource === "Silicates") {
53+
depositRowId = 13; // Row ID for Silicates
54+
} else {
55+
// You can add similar conditions for other resources if needed
56+
// depositRowId = 1; // Default to a row ID (you may want to adjust this)
57+
depositRowId = 13;
58+
}
59+
60+
// Fetch the corresponding row from inventoryITEMS
61+
const { data: depositData, error: depositError } = await supabase
62+
.from('inventoryITEMS')
63+
.select('name, icon_url')
64+
.eq('id', depositRowId)
65+
.single();
66+
67+
if (depositError) {
68+
console.error(depositError);
69+
return;
70+
}
71+
72+
// Set the deposit and coverUrl based on the chosen resource
4173
const response = await supabase.from('basePlanetSectors').upsert([
4274
{
4375
anomaly: userPlanet,
4476
owner: session?.user?.id,
45-
deposit: "Iron", // Start off with Iron as a default resource
46-
coverUrl: "https://mars.nasa.gov/mars2020-raw-images/pub/ods/surface/sol/00090/ids/edr/browse/edl/EBE_0090_0674952393_193ECM_N0040048EDLC00090_0030LUJ01_1200.jpg", // Do we set this to be a supabase storage asset in prod?
77+
deposit: depositData?.name || "Unknown Resource",
78+
coverUrl: depositData?.icon_url || "https://example.com/default-image.jpg",
4779
explored: false,
4880
},
4981
]);
50-
82+
5183
if (response.error) {
5284
console.error(response.error);
5385
} else {
54-
55-
};
56-
};
57-
};
86+
// Handle success if needed
87+
}
88+
}
89+
};
5890

5991
return (
6092
<div>

0 commit comments

Comments
Β (0)