From 56f3375702dce0087cc8a52b6527abc3120bb5da Mon Sep 17 00:00:00 2001 From: Mats <64415243+mnyflot@users.noreply.github.com> Date: Sun, 14 Apr 2024 16:46:16 +0200 Subject: [PATCH] 258 bug make whole satellite lien clickable (#300) * fix(frontend): :bug: Turn table into shadcn table and make only the text clickable * feat(frontend): :sparkles: make whole satellites table row clickable * style(frontend): :rotating_light: fix linting error --- frontend/src/app/satellites/page.tsx | 34 +++++++----- .../satelliteData/SatelliteStatsTableRow.tsx | 55 +++++++++---------- 2 files changed, 48 insertions(+), 41 deletions(-) diff --git a/frontend/src/app/satellites/page.tsx b/frontend/src/app/satellites/page.tsx index 9e02a25..4502e7b 100644 --- a/frontend/src/app/satellites/page.tsx +++ b/frontend/src/app/satellites/page.tsx @@ -6,6 +6,14 @@ import { } from "@/components/PageHeader"; import SatelliteStatsTableRow from "@/components/satelliteData/SatelliteStatsTableRow"; import { getClient } from "@/lib/ApolloClient"; +import { + Table, + TableBody, + TableHead, + TableHeader, + TableRow, +} from "@/components/shadcn/table"; + const GET_SATELLITES = gql(` query GET_SATELLITES { satellites { @@ -45,17 +53,17 @@ export default async function Satellites() { to see more details. - - - - - - - - - - - +
SatelliteSpeedAltitudeLatitudeLongitude
+ + + Satellite + Speed + Altitude + Latitude + Longitude + + + {graphqlData?.data?.satellites?.data?.map( (satellite: any) => { let satelliteName = @@ -69,8 +77,8 @@ export default async function Satellites() { ); }, )} - -
+ + ); } catch (error) { diff --git a/frontend/src/components/satelliteData/SatelliteStatsTableRow.tsx b/frontend/src/components/satelliteData/SatelliteStatsTableRow.tsx index 29c5750..b6c3097 100644 --- a/frontend/src/components/satelliteData/SatelliteStatsTableRow.tsx +++ b/frontend/src/components/satelliteData/SatelliteStatsTableRow.tsx @@ -2,7 +2,8 @@ import { useState, useEffect } from "react"; import { convertSatrec, SatelliteInfo } from "@/lib/convertSatrec"; import { useSatelliteStore } from "@/lib/store"; -import Link from "next/link"; +import { TableCell, TableRow } from "@/components/shadcn/table"; +import { useRouter } from "next/navigation"; const updateInterval = 10; @@ -18,6 +19,8 @@ export default function SatelliteStatsTableRow({ null, ); + const router = useRouter(); + // Fetch satellite data on component mount useEffect(() => { fetchAndSetSatelliteData(satName); @@ -50,33 +53,29 @@ export default function SatelliteStatsTableRow({ ); } + + function handleClick() { + router.replace(`/satellites/${slug}`); + } + return ( - - - - {satName} - - - - - {satelliteInfo.velocity + " km/s"} - - - - - {satelliteInfo.altitude + " km"} - - - - - {satelliteInfo.latitudeDeg + "° N"} - - - - - {satelliteInfo.longitudeDeg + "° E"} - - - + + {satName} + + {satelliteInfo.velocity + " km/s"} + + + {satelliteInfo.altitude + " km"} + + + {satelliteInfo.latitudeDeg + "° N"} + + + {satelliteInfo.longitudeDeg + "° E"} + + ); }