Skip to content

Feature/load from GitHub #174

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 17 commits into from
Apr 2, 2020
Merged
Prev Previous commit
Next Next commit
cleanup
  • Loading branch information
ShMcK committed Mar 31, 2020
commit 4832c0ad09f1f34461ad5b41eb6366c9199f50de
3 changes: 1 addition & 2 deletions web-app/src/components/Error/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ApolloError } from 'apollo-boost'
import * as React from 'react'
import { css, jsx } from '@emotion/core'
import onError from '../../services/sentry/onError'
Expand All @@ -14,7 +13,7 @@ const styles = {
}

interface Props {
error?: ApolloError
error?: Error
}

const ErrorView = ({ error }: Props) => {
Expand Down
6 changes: 4 additions & 2 deletions web-app/src/containers/SelectTutorial/LoadTutorialSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react'
import useFetch from '../../services/hooks/useFetch'
import * as TT from 'typings/tutorial'
import TutorialOverview from '../../components/TutorialOverview'
import Loading from '../Loading'

interface Props {
url: string
Expand All @@ -12,13 +13,14 @@ interface Props {
const LoadTutorialSummary = (props: Props) => {
const { data, error, loading } = useFetch<TT.Tutorial>(props.url)
if (loading) {
return <div>Loading...</div>
return <Loading text="Loading tutorial summary..." />
}
// TODO: improve error handling
if (error) {
return <div>{JSON.stringify(error)}</div>
}
if (!data) {
return <div>No data returned</div>
return <div>No data returned for tutorial</div>
}
const onNext = () => {
props.send({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const styles = {
padding: '1rem',
width: '100%',
height: 'auto',
backgroundColor: 'yellow',
},
}

Expand Down
21 changes: 4 additions & 17 deletions web-app/src/containers/SelectTutorial/index.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
import * as React from 'react'
import * as T from 'typings'
import * as TT from 'typings/tutorial'
import SelectTutorialForm from './SelectTutorialForm'
import LoadTutorialSummary from './LoadTutorialSummary'

const styles = {
page: {
position: 'relative' as 'relative',
height: 'auto',
width: '100%',
},
header: {
selectPage: {
padding: '1rem',
},
}

interface ContainerProps {
send(action: T.Action): void
context: T.MachineContext
}

interface TutorialsData {
tutorials: TT.Tutorial[]
}

interface Props {
send: any
context: any
Expand All @@ -31,11 +22,7 @@ const SelectTutorialPage = (props: Props) => {
const [url, setUrl] = React.useState<string | null>(null)
return (
<div css={styles.page}>
{!url && (
<div css={styles.header}>
<SelectTutorialForm onUrlChange={setUrl} />
</div>
)}
{!url && <SelectTutorialForm onUrlChange={setUrl} />}
{url && <LoadTutorialSummary url={url} send={props.send} onClear={() => setUrl(null)} />}
</div>
)
Expand Down