Skip to content

Commit

Permalink
🎓🦍 ↝ [SGV2-166 #142]: Fix generator issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Gizmotronn committed Aug 27, 2024
1 parent d101527 commit e9faad4
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 2,596 deletions.
36 changes: 20 additions & 16 deletions app/(anomalies)/(data)/Mars-Photos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ export const RooverFromAppeears: React.FC = () => {
{rovers.length > 0 ? (
rovers.map((rover) => (
<div key={rover.id} className="text-center col-span-3">
<div className="mb-4">
{/* <div className="mb-4">
<img
src='https://github.com/Signal-K/client/blob/SGV2-154/public/assets/Archive/Inventory/Structures/TelescopeReceiver.png?raw=true'
alt='telescope'
className="w-24 h-24 mb-2"
/>
</div>
</div> */}
<div className="p-2 max-w-4xl mx-auto rounded-lg bg-[#1D2833] text-[#F7F5E9] rounded-md bg-clip-padding backdrop-filter backdrop-blur-md bg-opacity-70">
<div className='relative h-64 w-full'>
<img
Expand All @@ -137,12 +137,24 @@ export const RooverFromAppeears: React.FC = () => {
className="relative z-10 w-full h-full object-contain"
/>
</div>
<ClassificationForm
anomalyId={rover.id.toString()}
anomalyType="roverImg"
missionNumber={1370104}
assetMentioned={rover.avatar_url}
/>

{!imagesCollected && (
<button
onClick={handleCollectAndClassify}
className="col-span-3 mt-4 px-4 py-2 bg-blue-500 text-white rounded-lg shadow-md hover:bg-blue-700"
>
Collect this image
</button>
)}

{imagesCollected && (
<ClassificationForm
anomalyId={rover.id.toString()}
anomalyType="roverImg"
missionNumber={1370104}
assetMentioned={rover.avatar_url}
/>
)}
</div>
</div>
))
Expand All @@ -151,14 +163,6 @@ export const RooverFromAppeears: React.FC = () => {
{rovers[0]?.avatar_url}
</div>
)}
{rovers.length > 0 && !imagesCollected && (
<button
onClick={handleCollectAndClassify}
className="col-span-3 mt-4 px-4 py-2 bg-blue-500 text-white rounded-lg shadow-md hover:bg-blue-700"
>
Collect this image
</button>
)}
{isClassified && (
<div className="col-span-3 mt-4">
<h3 className="text-lg font-semibold text-center">
Expand Down
23 changes: 15 additions & 8 deletions app/(anomalies)/(planets)/generated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface Classification {
id: number;
anomaly: number;
classificationtype: string;
classificationConfiguration?: { activePlanet?: number }; // Updated to include classificationConfiguration
}

const GeneratedStarterPlanet: React.FC = () => {
Expand All @@ -31,17 +32,23 @@ const GeneratedStarterPlanet: React.FC = () => {
// Fetch all classifications related to the activePlanet
const { data: allClassifications, error: allError } = await supabase
.from("classifications")
.select("id, anomaly, classificationtype")
.eq("author", session.user.id)
.eq("anomaly", activePlanet.id);
.select("id, anomaly, classificationtype, classificationConfiguration")
.eq("author", session.user.id);

if (allError) throw allError;

setClassifications(allClassifications || []);
// Filter classifications by activePlanet.id
const filteredClassifications = allClassifications?.filter(
(c: Classification) =>
c.anomaly === activePlanet.id ||
(c.classificationConfiguration?.activePlanet === activePlanet.id)
) || [];

setClassifications(filteredClassifications);

// Fetch one classification of each type
const lightcurve = allClassifications?.find((c: { classificationtype: string; }) => c.classificationtype === "planet") || null;
const roverImg = allClassifications?.find((c: { classificationtype: string; }) => c.classificationtype === "roverImg") || null;
const lightcurve = filteredClassifications.find((c: { classificationtype: string; }) => c.classificationtype === "planet") || null;
const roverImg = filteredClassifications.find((c: { classificationtype: string; }) => c.classificationtype === "roverImg") || null;

setOneLightcurve(lightcurve);
setOneRoverImg(roverImg);
Expand Down Expand Up @@ -146,10 +153,10 @@ const GeneratedStarterPlanet: React.FC = () => {
<p className="text-sm mt-2">
Great job completing the onboarding! You're all set.
</p>
<p className="text-sm mt-2">
{/* <p className="text-sm mt-2">
Now, it's time to travel to your planet, where your adventure truly begins. Get ready to
explore, discover, and make your mark!
</p>
</p> */}
<p className="text-sm mt-2">
We're still working on the first chapter, but if you'd like, we do have some old gameplay components for you to check out,
and there's plenty more to classify.
Expand Down
18 changes: 12 additions & 6 deletions app/(create)/(classifications)/PostForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ const ClassificationForm: React.FC<ClassificationFormProps> = ({ anomalyType, an
value
])
);


// Add activePlanet.id to classificationConfiguration
if (activePlanet?.id) {
classificationConfiguration.activePlanet = activePlanet.id;
}

try {
const { data: classificationData, error: classificationError } = await supabase
.from("classifications")
Expand All @@ -116,10 +121,10 @@ const ClassificationForm: React.FC<ClassificationFormProps> = ({ anomalyType, an
media: [uploads, assetMentioned],
anomaly: anomalyId,
classificationtype: anomalyType,
classificationConfiguration,
classificationConfiguration, // Include the configuration with activePlanet
})
.single();

if (classificationError) {
console.error("Error creating classification:", classificationError.message);
alert("Failed to create classification. Please try again.");
Expand All @@ -130,25 +135,26 @@ const ClassificationForm: React.FC<ClassificationFormProps> = ({ anomalyType, an
setSelectedOptions({});
setUploads([]);
}

if (!activePlanet?.id) {
const { error: profileUpdateError } = await supabase
.from("profiles")
.update({ location: anomalyId })
.eq("id", session?.user?.id);

if (profileUpdateError) {
console.error("Error updating profile with active planet:", profileUpdateError.message);
alert("Failed to update active planet. Please try again.");
return;
}
}

await handleMissionComplete();
} catch (error) {
console.error("Unexpected error:", error);
}
};


const addMedia = async (e: React.ChangeEvent<HTMLInputElement>) => {
const files = e.target.files;
Expand Down
9 changes: 3 additions & 6 deletions app/(scenes)/roovers/deployAndReturn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
CardHeader,
CardTitle,
CardDescription,
CardContent,
CardContent,
} from "@/components/ui/card";
import { Avatar, AvatarImage, AvatarFallback } from "@/components/ui/avatar";
import { Button } from "@/components/ui/button";
Expand Down Expand Up @@ -108,10 +108,9 @@ export default function DeployRooversInitial() {
<div className="flex items-center gap-4">
<Avatar className="h-12 w-12 bg-pastel-pink text-white">
<AvatarImage
src="https://cdn-icons-png.flaticon.com/512/124/124544.png"
src="/assets/Captn.jpg"
alt="Astra"
/>
<AvatarFallback>A</AvatarFallback>
</Avatar>
<div>
<CardTitle className="text-pastel-pink font-heading">
Expand Down Expand Up @@ -166,9 +165,7 @@ export default function DeployRooversInitial() {
</div>
)}
<Button
className={`w-full ${
isDeployed ? "bg-pastel-green" : "bg-pastel-pink"
} text-gray-800`}
className="bg-[#85DDA2]"
onClick={deployRover}
disabled={isDeployed}
>
Expand Down
2 changes: 1 addition & 1 deletion app/(settings)/profile/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default function UserAvatar({ url, size, onUpload }: UserAvatarProps) {
)}

<div style={{ width: size }}>
<label className="btn bg-red-800 text-white my-2">
<label className="btn bg-[#85DDA2] text-white my-2">
{uploading ? "Uploading..." : "Upload new avatar"}
<input
style={{ display: 'none' }}
Expand Down
16 changes: 8 additions & 8 deletions app/(settings)/profile/form.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react";
import React, { useState, useEffect } from "react";
import UserAvatar from "./Avatar";
import UserAvatar from "./Avatar";

export default function ProfileCardModal() {
const supabase = useSupabaseClient();
Expand Down Expand Up @@ -106,18 +106,18 @@ export default function ProfileCardModal() {

return (
<form onSubmit={(e) => updateProfile(e)} className="form-widget p-6 rounded-md shadow-lg max-w-md mx-auto">
<h2 className="text-2xl font-bold mb-4 text-red-800">Edit profile</h2>
<p className="text-red-800 mb-6">Provide details about yourself and any other pertinent information.</p>
<h2 className="text-2xl font-bold mb-4 text-[#85DDA2]">Edit profile</h2>
<p className="text-[#85DDA2] mb-6">Provide details about yourself and any other pertinent information.</p>
<div className="mb-4">
<label htmlFor="avatar" className="block text-sm font-medium text-red-800">Profile avatar</label>
<label htmlFor="avatar" className="block text-sm font-medium text-[#85DDA2]">Profile avatar</label>
<UserAvatar
url={avatar_url}
size={150}
onUpload={(url) => setAvatarUrl(url)}
/>
</div>
<div className="mb-4">
<label htmlFor="full_name" className="block text-sm font-bold text-red-800">Full name</label>
<label htmlFor="full_name" className="block text-sm font-bold text-[#85DDA2]">Full name</label>
<input
id="full_name"
type="text"
Expand All @@ -127,7 +127,7 @@ export default function ProfileCardModal() {
/>
</div>
<div className="mb-4">
<label htmlFor="username" className="block text-sm font-medium text-red-800">Username</label>
<label htmlFor="username" className="block text-sm font-medium text-[#85DDA2]">Username</label>
<input
id="username"
type="text"
Expand All @@ -138,7 +138,7 @@ export default function ProfileCardModal() {
/>
</div>
<div className="mb-4">
<label htmlFor="email" className="block text-sm font-medium text-red-800">Email: </label>
<label htmlFor="email" className="block text-sm font-medium text-[#85DDA2]">Email: </label>
<input
className="mt-1 block w-full px-3 py-2 bg-gray-800 text-white rounded-md border border-gray-600 shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm"
id="email"
Expand All @@ -155,7 +155,7 @@ export default function ProfileCardModal() {
<div>
<button
type="submit"
className="block w-full bg-red-800 text-white font-bold py-2 px-4 rounded-md shadow-sm hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500"
className="block w-full bg-[#85DDA2] text-white font-bold py-2 px-4 rounded-md shadow-sm hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500"
disabled={loading}
>
{loading ? "Loading ..." : "Update profile"}
Expand Down
94 changes: 1 addition & 93 deletions public/sw.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion public/sw.js.map

This file was deleted.

Loading

0 comments on commit e9faad4

Please sign in to comment.