-
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.
updates to structure, [id].tsx, moved data types into types
- Loading branch information
Kilian Berres
authored and
Kilian Berres
committed
Jul 18, 2024
1 parent
e15cd11
commit 846055a
Showing
8 changed files
with
96 additions
and
99 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// app/details/[id].tsx | ||
|
||
"use client"; | ||
|
||
import { Spinner } from '@metrostar/comet-extras'; | ||
import { Card } from '@metrostar/comet-uswds'; | ||
import { mockData } from '../../data/spacecraft'; | ||
import { Spacecraft } from '../../types/spacecraft'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import React from 'react'; | ||
import { useRouter } from 'next/router'; | ||
import ErrorNotification from '@components/error-notification/error-notification'; | ||
import useAuth from '@hooks/use-auth'; | ||
// import axios from '@src/utils/axios'; | ||
|
||
export const Details = (): React.ReactElement => { | ||
const router = useRouter(); | ||
Check failure on line 17 in src/app/details/[id].tsx
|
||
const { id } = router.query; | ||
const { isSignedIn } = useAuth(); | ||
const { isLoading, error, data } = useQuery<Spacecraft, { message: string }>({ | ||
queryKey: ['details', id], | ||
queryFn: () => | ||
// axios.get(`/spacecraft/${id}`).then((response) => { | ||
// return response.data; | ||
// }), | ||
|
||
// TODO: Remove this mock response and uncomment above if API available | ||
Promise.resolve( | ||
mockData.items.filter((item) => item.id.toString() === id)[0], | ||
), | ||
enabled: isSignedIn && !!id, | ||
}); | ||
|
||
return ( | ||
<div className="grid-container"> | ||
<> | ||
<div className="grid-row"> | ||
<div className="grid-col"> | ||
<h1>Details</h1> | ||
</div> | ||
</div> | ||
{error && ( | ||
<div className="grid-row padding-bottom-2"> | ||
<div className="grid-col"> | ||
<ErrorNotification error={error.message} /> | ||
</div> | ||
</div> | ||
)} | ||
<div className="grid-row"> | ||
<div className="grid-col"> | ||
{isLoading ? ( | ||
<Spinner | ||
id="spinner" | ||
type="small" | ||
loadingText="Loading..." | ||
className="padding-top-2" | ||
/> | ||
) : data ? ( | ||
<Card id="details-card"> | ||
<ul> | ||
<li> | ||
<b>Name:</b> {data.name} | ||
</li> | ||
<li> | ||
<b>Description:</b> {data.description} | ||
</li> | ||
<li> | ||
<b>Affiliation:</b> {data.affiliation} | ||
</li> | ||
<li> | ||
<b>Dimensions:</b> {data.dimensions} | ||
</li> | ||
<li> | ||
<b>Appearances:</b> {data.appearances} | ||
</li> | ||
</ul> | ||
</Card> | ||
) : ( | ||
<>No items found</> | ||
)} | ||
</div> | ||
</div> | ||
</> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Details; |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -10,4 +10,4 @@ export interface TableData { | |
export interface ChartData { | ||
x: string; | ||
y: number; | ||
} | ||
} |