-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor individual satellites page (#176)
* refactor(frontend): 🎨 create interfaces for SatelliteInfo and Projects * refactor(frontend): 🎨 Prettier write * refactor(frontend): 🚑 Fix type annotations in page.tsx files * refactor(frontend): 🎨 prettier write * refactor: build fix * build: typing * fix(frontend):
- Loading branch information
Mads Hermansen
authored and
GitHub
committed
Apr 2, 2024
1 parent
2865f46
commit e9ef5be
Showing
7 changed files
with
147 additions
and
116 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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import { gql } from "@/__generated__/gql"; | ||
| import { Projects, SatelliteInfo } from "@/app/satellites/[satelliteSlug]/page"; | ||
| import { getClient } from "../ApolloClient"; | ||
|
|
||
| const GET_SATELLITE_INFO = | ||
| gql(`query GET_SATELLITE_INFO($filters: SatelliteFiltersInput) { | ||
| satellites(filters: $filters) { | ||
| data { | ||
| id | ||
| attributes { | ||
| celestrakURL | ||
| catalogNumberNORAD | ||
| content | ||
| name | ||
| projects { | ||
| data { | ||
| attributes { | ||
| title | ||
| coverImage { | ||
| data { | ||
| attributes { | ||
| url | ||
| } | ||
| } | ||
| } | ||
| slug | ||
| } | ||
| id | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| `); | ||
|
|
||
| export default async function fetchSatelliteInfo({ | ||
| params, | ||
| }: { | ||
| params: { satelliteSlug: string }; | ||
| }) { | ||
| let satelliteInfo: SatelliteInfo; | ||
|
|
||
| const filters = { | ||
| name: { | ||
| eq: params.satelliteSlug, | ||
| }, | ||
| }; | ||
|
|
||
| const graphqlData = await getClient().query({ | ||
| query: GET_SATELLITE_INFO, | ||
| variables: { | ||
| filters: filters, | ||
| }, | ||
| }); | ||
|
|
||
| let projects: Projects[] = []; | ||
|
|
||
| graphqlData?.data?.satellites?.data[0]?.attributes?.projects?.data.map( | ||
| (project: any) => { | ||
| projects.push({ | ||
| id: project.id, | ||
| title: project.attributes?.title, | ||
| coverImage: | ||
| project.attributes?.coverImage?.data?.attributes?.url, | ||
| slug: project.attributes?.slug, | ||
| }); | ||
| }, | ||
| ); | ||
|
|
||
| satelliteInfo = { | ||
| name: graphqlData?.data?.satellites?.data[0]?.attributes?.name ?? "", | ||
| content: | ||
| graphqlData?.data?.satellites?.data[0]?.attributes?.content ?? "", | ||
| relatedProjects: projects ?? [], | ||
| }; | ||
|
|
||
| return satelliteInfo; | ||
| } |