Skip to content

Commit

Permalink
βš½οΈŽπŸ‘¨πŸ»β€βœˆοΈ ↝ Attempting to create sectors with more than just iron/coal
Browse files Browse the repository at this point in the history
  • Loading branch information
Gizmotronn committed Jan 26, 2024
1 parent 5b2959a commit 745d710
Showing 1 changed file with 39 additions and 7 deletions.
46 changes: 39 additions & 7 deletions components/Content/Planets/Activities/SectorSetup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,55 @@ export default function CreateBasePlanetSector() {
const createSector = async () => {
if (session) {
fetchUserPlanet();

// Array of available resources
const resources = ["Silicates", "Alloy", "Iron", "Fuel", "Water", "Coal"];

// Randomly choose a resource
const chosenResource = resources[Math.floor(Math.random() * resources.length)];

// Get the corresponding row from inventoryITEMS
let depositRowId;
if (chosenResource === "Coal") {
depositRowId = 11; // Row ID for Coal
} else if (chosenResource === "Silicates") {
depositRowId = 13; // Row ID for Silicates
} else {
// You can add similar conditions for other resources if needed
// depositRowId = 1; // Default to a row ID (you may want to adjust this)
depositRowId = 13;
}

// Fetch the corresponding row from inventoryITEMS
const { data: depositData, error: depositError } = await supabase
.from('inventoryITEMS')
.select('name, icon_url')
.eq('id', depositRowId)
.single();

if (depositError) {
console.error(depositError);
return;
}

// Set the deposit and coverUrl based on the chosen resource
const response = await supabase.from('basePlanetSectors').upsert([
{
anomaly: userPlanet,
owner: session?.user?.id,
deposit: "Iron", // Start off with Iron as a default resource
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?
deposit: depositData?.name || "Unknown Resource",
coverUrl: depositData?.icon_url || "https://example.com/default-image.jpg",
explored: false,
},
]);

if (response.error) {
console.error(response.error);
} else {

};
};
};
// Handle success if needed
}
}
};

return (
<div>
Expand Down

0 comments on commit 745d710

Please sign in to comment.