diff --git a/frontend/src/app/satellites/[satelliteSlug]/page.tsx b/frontend/src/app/satellites/[satelliteSlug]/page.tsx index e8c44ba..a2871a9 100644 --- a/frontend/src/app/satellites/[satelliteSlug]/page.tsx +++ b/frontend/src/app/satellites/[satelliteSlug]/page.tsx @@ -1,8 +1,16 @@ -export const runtime = "edge"; +import React from "react"; import BlockRendererClient from "@/components/BlockRendererClient"; import fetchSatelliteInfo from "@/lib/data/fetchSatelliteInfo"; import { BlocksContent } from "@strapi/blocks-react-renderer"; import RelatedProjectsAndSatellites from "@/components/RelatedProjectsAndSatellites"; +import SatelliteDataHome from "@/components/satelliteData/SatelliteDataHome"; +import { useSatelliteStore } from "@/lib/store"; +import SolarDataComponent from "@/components/SolarActivity/SolarData"; +function setSelectedSatelliteSlug(satelliteSlug: string) { + const setSelectedSatellite = + useSatelliteStore.getState().setSelectedSatellite; + setSelectedSatellite(satelliteSlug); +} export interface SatelliteInfo { name: string; @@ -23,44 +31,39 @@ export default async function SatelliteInfoPage({ }: { params: { satelliteSlug: string }; }) { - try { - const satelliteInfo: SatelliteInfo = await fetchSatelliteInfo({ - params: params, - }); + setSelectedSatelliteSlug(params.satelliteSlug); + const satelliteInfo: SatelliteInfo = await fetchSatelliteInfo({ + params: params, + }); + + if (!satelliteInfo) return
Loading...
; + + return ( + <> + - return (

{satelliteInfo.name}

-
-

Altitude: {"1234"}km

-

Speed: {"1223"}km/s

-

Latitude: {"24.65"}°

-

Longitude: {"26.12"}°

-
+ - {satelliteInfo.relatedProjects?.length != 0 ? ( + {satelliteInfo.relatedProjects?.length ? (

Related Projects

) : null}
{satelliteInfo.relatedProjects?.map( - (project: ProjectOrSatellite) => { - return ( - - ); - }, + (project: ProjectOrSatellite) => ( + + ), )}
- ); - } catch (error) { - console.error("Error fetching satellite info:", error); - return
Error fetching satellite info
; - } + + ); } diff --git a/frontend/src/app/satellites/page.tsx b/frontend/src/app/satellites/page.tsx index fcdfccd..037a43c 100644 --- a/frontend/src/app/satellites/page.tsx +++ b/frontend/src/app/satellites/page.tsx @@ -1,11 +1,7 @@ export const runtime = "edge"; import { gql } from "@/__generated__/gql"; import { getClient } from "@/lib/ApolloClient"; -import Link from "next/link"; -import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; -import SatelliteStatsTable from "@/components/satelliteData/SatelliteStatsTable"; -import Image from "next/image"; -import { OuiImage } from "@/components/fullBlogCard"; +import SatelliteCard from "@/components/ui/satelliteCard"; const OUTSIDE_STRAPI_URL = process.env.OUTSIDE_STRAPI_URL; const GET_SATELLITES = gql(` @@ -50,38 +46,12 @@ export default async function Satellites() { let missionStatus = satellite?.attributes?.missionStatus ?? ""; return ( - - - - - {satellite?.attributes?.name} - - - - - {previewImage ? ( - {previewImage} - ) : ( -
- -
- )} -
-
- + // eslint-disable-next-line react/jsx-key + ); })} diff --git a/frontend/src/components/SolarActivity/SolarData.tsx b/frontend/src/components/SolarActivity/SolarData.tsx index 46bad4f..181fab8 100644 --- a/frontend/src/components/SolarActivity/SolarData.tsx +++ b/frontend/src/components/SolarActivity/SolarData.tsx @@ -1,3 +1,4 @@ +"use client"; import React, { useEffect, useRef, useState } from "react"; import { Chart, registerables } from "chart.js"; import { DateTime } from "luxon"; diff --git a/frontend/src/components/ui/satelliteCard.tsx b/frontend/src/components/ui/satelliteCard.tsx new file mode 100644 index 0000000..32a1257 --- /dev/null +++ b/frontend/src/components/ui/satelliteCard.tsx @@ -0,0 +1,65 @@ +"use client"; +import React from "react"; +import Image from "next/image"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import SatelliteStatsTable from "@/components/satelliteData/SatelliteStatsTable"; +// Import OuiImage or your placeholder image component here +import { OuiImage } from "@/components/fullBlogCard"; +//import { useSatelliteStore } from "@/lib/store"; + +interface SatelliteCardProps { + satelliteName: string; + missionStatus: string; + previewImage?: string; // Optional +} + +const SatelliteCard: React.FC = ({ + satelliteName, + missionStatus, + previewImage, +}) => { + /*const setSelectedSatellite = useSatelliteStore( + (state) => state.setSelectedSatellite, + );*/ + + const handleSatelliteCardClick = (satelliteName: string) => () => { + //setSelectedSatellite(satelliteName); + window.location.href = `/satellites/${encodeURIComponent(satelliteName)}`; + }; + + return ( +
+ {" "} + {/* Ensure the link is clickable and accessible */} + + + {satelliteName} + + + + {previewImage ? ( + {satelliteName} + ) : ( +
+ +
+ )} +
+
+
+ ); +}; + +export default SatelliteCard;