-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚵🏻♀️🌈 ↝ [SSP-39 SSP-42]: Generators can now show in missions inside …
…alternate post card views
- Loading branch information
1 parent
0f6b300
commit 456666e
Showing
7 changed files
with
373 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
components/Structures/Missions/Astronomers/PlanetHunters/PlanetMaker.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
"use client"; | ||
|
||
import React, { useEffect, useState } from "react"; | ||
import { PostCardSingleWithGenerator } from "@/content/Posts/PostWithGen"; | ||
import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react"; | ||
|
||
interface Classification { | ||
id: number; | ||
created_at: string; | ||
content: string | null; | ||
author: string | null; | ||
anomaly: number | null; | ||
media: any | null; | ||
classificationtype: string | null; | ||
classificationConfiguration: any | null; | ||
}; | ||
|
||
export default function PHClassificationGenerator() { | ||
const supabase = useSupabaseClient(); | ||
const session = useSession(); | ||
|
||
const [classifications, setClassifications] = useState<any[]>([]); | ||
const [loading, setLoading] = useState<boolean>(true); | ||
const [error, setError] = useState<string | null>(null); | ||
|
||
const fetchClassifications = async () => { | ||
if (!session?.user) { | ||
setError("User session not found."); | ||
setLoading(false); | ||
return; | ||
}; | ||
|
||
setLoading(true); | ||
setError(null); | ||
try { | ||
const { data, error } = await supabase | ||
.from('classifications') | ||
.select('*') | ||
.eq("author", session.user.id) | ||
.eq('classificationtype', 'planet') | ||
.order('created_at', { ascending: false }) as { data: Classification[]; error: any }; | ||
|
||
if (error) throw error; | ||
|
||
const processedData = data.map((classification) => { | ||
const media = classification.media; | ||
let images: string[] = []; | ||
|
||
if (Array.isArray(media) && media.length === 2 && typeof media[1] === "string") { | ||
images.push(media[1]); | ||
} else if (media && media.uploadUrl) { | ||
images.push(media.uploadUrl); | ||
}; | ||
|
||
const votes = classification.classificationConfiguration?.votes || 0; | ||
|
||
return { ...classification, images, votes }; | ||
}); | ||
|
||
setClassifications(processedData); | ||
} catch (error) { | ||
console.error("Error fetching classifications:", error); | ||
setError("Failed to load classifications."); | ||
} finally { | ||
setLoading(false); | ||
}; | ||
}; | ||
|
||
useEffect(() => { | ||
fetchClassifications(); | ||
}, [session]); | ||
|
||
return ( | ||
<div className="space-y-8"> | ||
{loading ? ( | ||
<p>Loading classifications</p> | ||
) : error ? ( | ||
<p>{error}</p> | ||
) : ( | ||
classifications.map((classification) => ( | ||
<PostCardSingleWithGenerator | ||
key={classification.id} | ||
classificationId={classification.id} | ||
title={classification.title} | ||
author={classification.author} | ||
content={classification.content} | ||
votes={classification.votes || 0} | ||
category={classification.category} | ||
tags={classification.tags || []} | ||
images={classification.images || []} | ||
anomalyId={classification.anomaly} | ||
classificationConfig={classification.classificationConfiguration} | ||
classificationType={classification.classificationtype} | ||
/> | ||
)) | ||
)} | ||
</div> | ||
); | ||
}; |
99 changes: 99 additions & 0 deletions
99
components/Structures/Missions/Meteorologists/Cloudspotting/CloudMaker.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
"use client"; | ||
|
||
import React, { useEffect, useState } from "react"; | ||
import { PostCardSingleWithGenerator } from "@/content/Posts/PostWithGen"; | ||
import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react"; | ||
|
||
interface Classification { | ||
id: number; | ||
created_at: string; | ||
content: string | null; | ||
author: string | null; | ||
anomaly: number | null; | ||
media: any | null; | ||
classificationtype: string | null; | ||
classificationConfiguration: any | null; | ||
}; | ||
|
||
export default function CloudClassificationGenerator() { | ||
const supabase = useSupabaseClient(); | ||
const session = useSession(); | ||
|
||
const [classifications, setClassifications] = useState<any[]>([]); | ||
const [loading, setLoading] = useState<boolean>(true); | ||
const [error, setError] = useState<string | null>(null); | ||
|
||
const fetchClassifications = async () => { | ||
if (!session?.user) { | ||
setError("User session not found."); | ||
setLoading(false); | ||
return; | ||
}; | ||
|
||
setLoading(true); | ||
setError(null); | ||
try { | ||
const { data, error } = await supabase | ||
.from('classifications') | ||
.select('*') | ||
.eq("author", session.user.id) | ||
.eq('classificationtype', 'cloud') | ||
.order('created_at', { ascending: false }) as { data: Classification[]; error: any }; | ||
|
||
if (error) throw error; | ||
|
||
const processedData = data.map((classification) => { | ||
const media = classification.media; | ||
let images: string[] = []; | ||
|
||
if (Array.isArray(media) && media.length === 2 && typeof media[1] === "string") { | ||
images.push(media[1]); | ||
} else if (media && media.uploadUrl) { | ||
images.push(media.uploadUrl); | ||
} | ||
|
||
const votes = classification.classificationConfiguration?.votes || 0; | ||
|
||
return { ...classification, images, votes }; | ||
}); | ||
|
||
setClassifications(processedData); | ||
} catch (error) { | ||
console.error("Error fetching classifications:", error); | ||
setError("Failed to load classifications."); | ||
} finally { | ||
setLoading(false); | ||
}; | ||
}; | ||
|
||
useEffect(() => { | ||
fetchClassifications(); | ||
}, [session]); | ||
|
||
return ( | ||
<div className="space-y-8"> | ||
{loading ? ( | ||
<p>Loading classifications</p> | ||
) : error ? ( | ||
<p>{error}</p> | ||
) : ( | ||
classifications.map((classification) => ( | ||
<PostCardSingleWithGenerator | ||
key={classification.id} | ||
classificationId={classification.id} | ||
title={classification.title} | ||
author={classification.author} | ||
content={classification.content} | ||
votes={classification.votes || 0} | ||
category={classification.category} | ||
tags={classification.tags || []} | ||
images={classification.images || []} | ||
anomalyId={classification.anomaly} | ||
classificationConfig={classification.classificationConfiguration} | ||
classificationType={classification.classificationtype} | ||
/> | ||
)) | ||
)} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.