Skip to content

Commit fe20bcb

Browse files
committed
fix types on bookmark and upvote mutations
1 parent 14f9796 commit fe20bcb

File tree

6 files changed

+20
-24
lines changed

6 files changed

+20
-24
lines changed

packages/gatsby-theme/src/components/community/BookmarkMutation.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { Mutation } from 'react-apollo';
33
import { loginUser } from '../../utils/auth';
44
import { BookmarkButton } from '../shared/buttons';
55
import { BookmarkTutorial } from '../../utils/queries';
6+
import { BookmarkTutorialMutation } from '../../graphqlTypes';
67
import { optionalChaining } from '../../utils/helpers';
7-
88
import { handleMutationResponse, ApiErrors } from '../../utils/errorHandling';
99

1010
const BookmarkMutation = ({ tutorial }) => (
11-
<Mutation
11+
<Mutation<BookmarkTutorialMutation>
1212
mutation={BookmarkTutorial}
1313
variables={{
1414
id: tutorial.id,

packages/gatsby-theme/src/components/community/UpvoteMutation.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ import { VoteButton } from '../shared/buttons';
66
import { Heading, Flex } from '../shared/base';
77
import { optionalChaining } from '../../utils/helpers';
88
import { UpvoteTutorial } from '../../utils/queries';
9+
import { UpvoteTutorialMutation } from '../../graphqlTypes';
910

1011
const UpvoteMutation = ({ tutorial }) => (
11-
<Mutation mutation={UpvoteTutorial} variables={{ id: tutorial.id }}>
12+
<Mutation<UpvoteTutorialMutation>
13+
mutation={UpvoteTutorial}
14+
variables={{ id: tutorial.id }}
15+
>
1216
{upvote => {
1317
let active = optionalChaining(() => tutorial.viewerUserTutorial.upvoted);
1418
let upvotes = optionalChaining(() => tutorial.upvotes);

packages/gatsby-theme/src/components/courses/CourseCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Query } from 'react-apollo';
44
import ProgressBar from '../shared/ProgressBar';
55
import { TutorialButton } from '../shared/buttons';
66
import { getTutorialbyGatsbyID } from '../../utils/queries';
7-
import { GetTutorialbyGatsbyIdQuery } from '../../graphqlTypes';
7+
import { GetTutorialbyGatsbyIdQuery, Maybe } from '../../graphqlTypes';
88
import { getTutorialOverviewSlug } from '../../utils/getTutorialSlug';
99
import { optionalChaining, percent } from '../../utils/helpers';
1010

packages/gatsby-theme/src/components/courses/CourseSection.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@ type QueryData = {
1313
node: Mdx;
1414
};
1515

16-
// type Node = {
17-
// id: string;
18-
// fileAbsolutePath: string;
19-
// frontmatter: Frontmatter;
20-
// };
21-
22-
// type Frontmatter = {
23-
// id: string;
24-
// tutorialTitle: string;
25-
// description: string;
26-
// };
27-
2816
const CourseSection: React.FunctionComponent<CourseSectionProps> = ({
2917
heading,
3018
body,

packages/gatsby-theme/src/components/templates/TutorialOverview.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ interface PageTemplateProps {
1515
}
1616

1717
const PageTemplate: React.FunctionComponent<PageTemplateProps> = ({ data }) => {
18-
let gatsbyID = optionalChaining(() => data.overview.frontmatter.id);
18+
let gatsbyID = optionalChaining(() => data!.overview!.frontmatter!.id);
1919

2020
// This is so that the start button can link to the user's current path
2121
// TO DO find a better way to pass in the which chapter the user is currently on
2222
const chapterPaths = optionalChaining(() =>
23-
data.allMdx.edges.map(a =>
23+
data!.allMdx!.edges.map(a =>
2424
getTutorialSlug(optionalChaining(() => a.node.fileAbsolutePath)),
2525
),
2626
);
@@ -29,11 +29,11 @@ const PageTemplate: React.FunctionComponent<PageTemplateProps> = ({ data }) => {
2929
<Layout>
3030
<Content>
3131
<Flex>
32-
<Box width={3 / 4} aligncontent="center">
32+
<Box width={3 / 4}>
3333
<TutorialHeader
3434
width={1 / 2}
35-
title={data!.overview!.frontmatter!.tutorialTitle}
36-
description={data!.overview!.frontmatter!.description}
35+
title={data!.overview!.frontmatter!.tutorialTitle || 'blank'}
36+
description={data!.overview!.frontmatter!.description || 'blank'}
3737
tags={['React', 'Apollo', 'Javascript']}
3838
/>
3939
</Box>

packages/gatsby-theme/src/components/tutorial/TutorialSidebar.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import { SpectrumButton } from '../shared/buttons';
66

77
type SidebarProps = {
88
tutorialTitle: string;
9-
chapters: string[];
9+
chapters: Chapter;
10+
};
11+
type Chapter = {
12+
chapterTitle: string;
13+
chapterPath: string;
1014
};
1115

1216
export const Sidebar: React.FunctionComponent<SidebarProps> = ({
@@ -22,8 +26,8 @@ export const Sidebar: React.FunctionComponent<SidebarProps> = ({
2226
</Card>
2327
<ul>
2428
{chapters.map(chapter => (
25-
<li key={chapter.chapterTitle}>
26-
<a href={chapter.chapterPath}>{chapter.chapterTitle}</a>
29+
<li key={chapter!.chapterTitle}>
30+
<a href={chapter!.chapterPath}>{chapter!.chapterTitle}</a>
2731
</li>
2832
))}
2933
</ul>

0 commit comments

Comments
 (0)