-
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.
- Loading branch information
1 parent
a4ec7f9
commit b43217f
Showing
7 changed files
with
113 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
query getGlamp($glampId: Int) { | ||
glamp(glampId: $glampId) { | ||
id | ||
title | ||
description | ||
type | ||
price | ||
availableFrom | ||
availableTo | ||
adultCapacity | ||
childCapacity | ||
isLuxury | ||
} | ||
} |
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,51 @@ | ||
import { Shell } from "@/components/Shell"; | ||
import { | ||
GetGlampDocument, | ||
GetGlampQuery, | ||
GetGlampQueryVariables, | ||
useGetGlampQuery, | ||
} from "@/generated/graphql"; | ||
import { addApolloState, initializeApollo } from "@/utils/apolloClient"; | ||
import { GetServerSidePropsContext } from "next"; | ||
import { useRouter } from "next/router"; | ||
|
||
const GlampDetailPage = () => { | ||
const router = useRouter(); | ||
|
||
const { glampId } = router.query; | ||
|
||
const { data, loading } = useGetGlampQuery({ | ||
variables: { | ||
glampId: Number(glampId), | ||
}, | ||
}); | ||
|
||
if (loading) { | ||
<div>loading</div>; | ||
} | ||
|
||
return ( | ||
<Shell> | ||
<pre>{JSON.stringify(data, null, 2)}</pre> | ||
</Shell> | ||
); | ||
}; | ||
|
||
export default GlampDetailPage; | ||
|
||
export async function getServerSideProps(context: GetServerSidePropsContext) { | ||
const apolloClient = initializeApollo({ context }); | ||
|
||
const { glampId } = context.query; | ||
|
||
await apolloClient.query<GetGlampQuery, GetGlampQueryVariables>({ | ||
query: GetGlampDocument, | ||
variables: { | ||
glampId: Number(glampId), | ||
}, | ||
}); | ||
|
||
return addApolloState(apolloClient, { | ||
props: {}, | ||
}); | ||
} |
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