8000 update tutorials loading for new api · dashinja/coderoad-vscode@85f11a4 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 85f11a4

Browse files
committed
update tutorials loading for new api
1 parent a5da2d2 commit 85f11a4

File tree

2 files changed

+31
-23
lines changed

2 files changed

+31
-23
lines changed

web-app/src/containers/New/TutorialList/index.tsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,26 @@ interface Props {
99
}
1010

1111
const TutorialList = (props: Props) => {
12-
const onSelect = (tutorial: T.Tutorial) => {
13-
channel.machineSend({
14-
type: 'TUTORIAL_START',
15-
payload: {
16-
tutorial,
17-
}
18-
})
19-
}
20-
return (
21-
<div>
22-
{props.tutorialList.map((tutorial: T.Tutorial) => (
23-
<TutorialItem
24-
key={tutorial.id}
25-
onSelect={() => onSelect(tutorial)}
26-
title={tutorial.title || ''}
27-
text={tutorial.text || ''}
28-
/>
29-
))}
30-
</div>
31-
)
12+
const onSelect = (tutorial: T.Tutorial) => {
13+
channel.machineSend({
14+
type: 'TUTORIAL_START',
15+
payload: {
16+
tutorial,
17+
},
18+
})
19+
}
20+
return (
21+
<div>
22+
{props.tutorialList.map((tutorial: T.Tutorial) => (
23+
<TutorialItem
24+
key={tutorial.id}
25+
onSelect={() => onSelect(tutorial)}
26+
title={tutorial.version.summary.title || ''}
27+
text={tutorial.version.summary.description || ''}
28+
/>
29+
))}
30+
</div>
31+
)
3232
}
3333

3434
export default TutorialList

web-app/src/containers/New/index.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react'
22
import { useQuery } from '@apollo/react-hooks'
3-
import * as T from 'typings/graphql'
3+
import * as G from 'typings/graphql'
44
import * as CR from 'typings'
55

66
import queryTutorials from '../../services/apollo/queries/tutorials'
@@ -9,7 +9,7 @@ import ErrorView from '../../components/Error'
99
import TutorialList from './TutorialList'
1010

1111
interface Props {
12-
tutorialList: T.Tutorial[]
12+
tutorialList: G.Tutorial[]
1313
}
1414

1515
export const NewPage = (props: Props) => (
@@ -25,8 +25,12 @@ interface ContainerProps {
2525
send(action: CR.Action): void
2626
}
2727

28+
interface TutorialsData {
29+
tutorials: G.Tutorial[]
30+
}
31+
2832
const NewPageContainer = (props: ContainerProps) => {
29-
const { data, loading, error } = useQuery(queryTutorials)
33+
const { data, loading, error } = useQuery<TutorialsData>(queryTutorials)
3034
if (loading) {
3135
return <Loading />
3236
}
@@ -35,6 +39,10 @@ const NewPageContainer = (props: ContainerProps) => {
3539
return <ErrorView error={error} />
3640
}
3741

42+
if (!data) {
43+
return null
44+
}
45+
3846
return (
3947
<React.Suspense fallback={Loading}>
4048
<NewPage tutorialList={data.tutorials} />

0 commit comments

Comments
 (0)
0