generated from theodorusclarence/ts-nextjs-tailwind-starter
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add UsesPage query and type; add data to page
- Loading branch information
Showing
5 changed files
with
92 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { gql } from '@apollo/client'; | ||
|
||
import { flattenToObject } from '@/lib/graphqlUtils'; | ||
|
||
import apolloClient from '../../apollo/apollo-client'; | ||
|
||
import { UsesPage } from '@/types/UsesPage'; | ||
|
||
export async function queryUsesPage() { | ||
const { data } = await apolloClient.query({ query: UsesPageQuery }); | ||
|
||
return flattenToObject<UsesPage>(data.usesPage); | ||
} | ||
|
||
export const UsesPageQuery = gql` | ||
{ | ||
usesPage { | ||
data { | ||
id | ||
attributes { | ||
hardware { | ||
title | ||
content | ||
} | ||
programmingTools { | ||
title | ||
content | ||
} | ||
productivity { | ||
title | ||
content | ||
} | ||
media { | ||
title | ||
content | ||
} | ||
security { | ||
title | ||
content | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`; |
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,4 @@ | ||
export interface TitledParagraph { | ||
title: string; | ||
content: string; | ||
} |
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,9 @@ | ||
import { TitledParagraph } from '@/types/Shared'; | ||
|
||
export interface UsesPage { | ||
hardware: TitledParagraph; | ||
media: TitledParagraph; | ||
productivity: TitledParagraph; | ||
programmingTools: TitledParagraph; | ||
security: TitledParagraph; | ||
} |