Skip to content

Commit

Permalink
πŸ‘¨β€πŸ‘¦β€πŸ‘¦πŸŒ… ↝ [SGV2-152]: Users can now be redirected to the first scene!
Browse files Browse the repository at this point in the history
  • Loading branch information
Gizmotronn committed Aug 18, 2024
1 parent 6e7e127 commit 3e5c46e
Show file tree
Hide file tree
Showing 8 changed files with 435 additions and 37 deletions.
73 changes: 70 additions & 3 deletions app/(anomalies)/(planets)/generated.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
"use client";

import React, { useEffect, useState } from "react";
import { useSupabaseClient, useSession } from "@supabase/auth-helpers-react";
import { useActivePlanet } from "@/context/ActivePlanet";
import { Card } from "@/components/ui/card";
import { useRouter } from "next/navigation";

interface Classification {
id: number;
Expand Down Expand Up @@ -139,11 +142,75 @@ const GeneratedStarterPlanet: React.FC = () => {
Now, it's time to travel to your planet, where your adventure truly begins. Get ready to
explore, discover, and make your mark!
</p>
<AddMissionsAndItems />
</div>
</Card>
);
};

const AddMissionsAndItems: React.FC = () => {
const supabase = useSupabaseClient();
const session = useSession();
const { activePlanet } = useActivePlanet();
const router = useRouter();

const handleAddMissionsAndItems = async () => {
if (!session || !activePlanet) return;

const userId = session.user.id;
const anomalyId = activePlanet.id;

// Define missions and items to add
const missionsToAdd = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13, 17, 18];
const itemsToAdd = [11, 12, 13, 14, 15, 16, 19, 22, 23, 26, 28, 29, 30, 32];

try {
// Insert missions
const { error: missionError } = await supabase
.from("missions")
.insert(missionsToAdd.map(missionId => ({
user: userId,
mission: missionId,
time_of_completion: null, // Set this to null or current timestamp if needed
rewarded_items: [], // Add items if any
})));

if (missionError) throw missionError;

// Insert items into inventory
const { error: inventoryError } = await supabase
.from("inventory")
.insert(itemsToAdd.map(itemId => ({
item: itemId,
owner: userId,
quantity: 1, // Default quantity, adjust as needed
time_of_deploy: new Date(), // Set current timestamp or as needed
anomaly: anomalyId,
parentItem: null // Set if applicable
})));

if (inventoryError) throw inventoryError;

// Redirect to /scenes/v1
router.push("/scenes/v1");

} catch (error: any) {
console.error("Error adding missions or inventory items:", error.message);
}
};

return (
<div className="text-center">
<button
onClick={handleAddMissionsAndItems}
className="bg-blue-500 text-white py-2 px-4 rounded"
>
Add Missions and Items
</button>
</div>
);
};

function DropletIcon(props: any) {
return (
<svg
Expand All @@ -161,7 +228,7 @@ function DropletIcon(props: any) {
<path d="M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z" />
</svg>
);
}
};

function LeafIcon(props: any) {
return (
Expand All @@ -181,7 +248,7 @@ function LeafIcon(props: any) {
<path d="M2 21c0-3 1.85-5.36 5.08-6C9.5 14.52 12 13 13 12" />
</svg>
);
}
};

function TelescopeIcon(props: any) {
return (
Expand All @@ -206,6 +273,6 @@ function TelescopeIcon(props: any) {
<circle cx="12" cy="13" r="2" />
</svg>
);
}
};

export default GeneratedStarterPlanet;
2 changes: 1 addition & 1 deletion app/(layout)/currentSections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useActivePlanet } from "@/context/ActivePlanet";
import { TellUsWhatYouThinkClassification } from "@/Classifications/ClassificationForm";
// import NavigationMenu from "./navigation/pogo-menu";

export function Panels() {
export function Panels() {
const supabase = useSupabaseClient();
const session = useSession();

Expand Down
5 changes: 4 additions & 1 deletion app/api/gameplay/missions/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ const missions: Mission[] = [
{ id: 1370102, name: "Create your profile", description: "Fill in your profile so that your discoveries can be credited", rewards: []},
{ id: 1370103, name: "Discover your first planet", description: "Use the first graphs provided to you to confirm the validity of an exoplanet candidate", rewards: []}, // Update description so the user understands they'll be visiting/based on this planet after the onboarding
{ id: 1370104, name: 'Initial roover photos classification', description: 'Send out a rover to explore your planet', rewards: []},
{ id: 1370105, name: 'Initial animal classification', description: 'Update this row', rewards: []},
{ id: 1370105, name: 'Initial animal classification', description: 'Update this row', rewards: [],},
{ id: 1370106, name: 'Generated planet', description: "Here's what we know about your planet. Why not visit it?", rewards: []},
{
id: 1370107, name: "Activate retro mode", description: "Going back to the first V2.0 beta after finishing onboarding", rewards: [],
},
];

export async function GET(req: NextRequest) {
Expand Down
60 changes: 34 additions & 26 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,33 +51,41 @@ export default function Home() {
);
};

// const renderContent = () => {
// if (missionCompletionStatus.has(101)) {
// return (
// <Layout bg={true}>
// <Panels />
// </Layout>
// );
// } else if (!missionCompletionStatus.has(100)) {
// return (
// <OnboardingLayout bg={true}>
// <OnboardingWindow />
// </OnboardingLayout>
// );
// // } else if (!missionCompletionStatus.has(101) && missionCompletionStatus.has(100)) {
// // return (
// // <OnboardingLayout bg={true}>
// // <FirstScene />
// // </OnboardingLayout>
// // );
// } else if (!missionCompletionStatus.has(101)) {
// return (
// <Layout bg={true}>
// <Panels />
// </Layout>
// )
// }
// };

const renderContent = () => {
if (missionCompletionStatus.has(101)) {
return (
<Layout bg={true}>
<Panels />
</Layout>
);
} else if (!missionCompletionStatus.has(100)) {
return (
<OnboardingLayout bg={true}>
<OnboardingWindow />
</OnboardingLayout>
);
// } else if (!missionCompletionStatus.has(101) && missionCompletionStatus.has(100)) {
// return (
// <OnboardingLayout bg={true}>
// <FirstScene />
// </OnboardingLayout>
// );
} else if (!missionCompletionStatus.has(101)) {
return (
<Layout bg={true}>
<Panels />
</Layout>
)
}
};
return (
<OnboardingLayout bg={true}>
<OnboardingWindow />
</OnboardingLayout>
)
}

return (
<>
Expand Down
Loading

0 comments on commit 3e5c46e

Please sign in to comment.