Skip to content

Fix/update to api #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Oct 15, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update tutorials loading for new api
  • Loading branch information
ShMcK committed Oct 14, 2019
commit 85f11a4da4200c56e17a188a63514929f0cf6c7a
40 changes: 20 additions & 20 deletions web-app/src/containers/New/TutorialList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ interface Props {
}

const TutorialList = (props: Props) => {
const onSelect = (tutorial: T.Tutorial) => {
channel.machineSend({
type: 'TUTORIAL_START',
payload: {
tutorial,
}
})
}
return (
<div>
{props.tutorialList.map((tutorial: T.Tutorial) => (
<TutorialItem
key={tutorial.id}
onSelect={() => onSelect(tutorial)}
title={tutorial.title || ''}
text={tutorial.text || ''}
/>
))}
</div>
)
const onSelect = (tutorial: T.Tutorial) => {
channel.machineSend({
type: 'TUTORIAL_START',
payload: {
tutorial,
},
})
}
return (
<div>
{props.tutorialList.map((tutorial: T.Tutorial) => (
<TutorialItem
key={tutorial.id}
onSelect={() => onSelect(tutorial)}
title={tutorial.version.summary.title || ''}
text={tutorial.version.summary.description || ''}
/>
))}
</div>
)
}

export default TutorialList
14 changes: 11 additions & 3 deletions web-app/src/containers/New/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react'
import { useQuery } from '@apollo/react-hooks'
import * as T from 'typings/graphql'
import * as G from 'typings/graphql'
import * as CR from 'typings'

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

interface Props {
tutorialList: T.Tutorial[]
tutorialList: G.Tutorial[]
}

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

interface TutorialsData {
tutorials: G.Tutorial[]
}

const NewPageContainer = (props: ContainerProps) => {
const { data, loading, error } = useQuery(queryTutorials)
const { data, loading, error } = useQuery<TutorialsData>(queryTutorials)
if (loading) {
return <Loading />
}
Expand All @@ -35,6 +39,10 @@ const NewPageContainer = (props: ContainerProps) => {
return <ErrorView error={error} />
}

if (!data) {
return null
}

return (
<React.Suspense fallback={Loading}>
<NewPage tutorialList={data.tutorials} />
Expand Down