Skip to content

Commit 2bc96a1

Browse files
committed
cleanup gql paths
1 parent 204840f commit 2bc96a1

File tree

7 files changed

+27
-23
lines changed

7 files changed

+27
-23
lines changed

web-app/src/components/Level/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Button, Step } from '@alifd/next'
22
import * as React from 'react'
3-
import * as T from '../../../../typings/graphql'
3+
import * as T from 'typings/graphql'
44

55
import Markdown from '../Markdown'
66
import LevelStageSummary from './LevelStageSummary'

web-app/src/components/Stage/index.tsx

+20-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Button, Step } from '@alifd/next'
22
import * as React from 'react'
3-
import CR from 'typings'
3+
import * as T from 'typings/graphql'
44

55
import Markdown from '../Markdown'
66
import StepDescription from './StepDescription'
@@ -23,36 +23,39 @@ const styles = {
2323
}
2424

2525
interface Props {
26-
stage: CR.TutorialStage
27-
steps: {
28-
[stepId: string]: any // CC.Step
29-
}
26+
stage: T.Stage
3027
complete: boolean
3128
onContinue(): void
3229
}
3330

34-
const Stage = ({ stage, steps, onContinue, complete }: Props) => {
35-
const { stepList, content } = stage
36-
const { title, text } = content
31+
const Stage = ({ stage, onContinue, complete }: Props) => {
32+
if (!stage.steps) {
33+
throw new Error('No Stage steps found')
34+
}
35+
3736
// grab the active step
38-
const activeIndex = stepList.findIndex((stepId: string) => {
39-
return steps[stepId].status.active
37+
const activeIndex: number = stage.steps.findIndex((step: T.Step | null) => {
38+
return step && step.status === 'ACTIVE'
4039
})
40+
4141
return (
4242
<div style={styles.card}>
4343
<div style={styles.content}>
44-
<h2 style={styles.title}>{title}</h2>
45-
<Markdown>{text}</Markdown>
44+
<h2 style={styles.title}>{stage.title}</h2>
45+
<Markdown>{stage.text || ''}</Markdown>
4646
</div>
4747
<div style={styles.steps}>
4848
<Step current={activeIndex} direction="ver" shape="dot" animation readOnly>
49-
{stepList.map((stepId: string, index: number) => {
50-
const step = steps[stepId]
49+
{stage.steps.map((step: T.Step | null, index: number) => {
50+
if (!step) {
51+
return null
52+
}
53+
const hide = status === 'INCOMPLETE'
5154
return (
5255
<Step.Item
53-
key={stepId}
54-
title={step.content.title || `Step ${index + 1}`}
55-
content={<StepDescription content={step.content} status={step.status} />}
56+
key={step.id}
57+
title={step.title || `Step ${index + 1}`}
58+
content={<StepDescription text={step.text} hide={hide} />}
5659
/>
5760
)
5861
})}

web-app/src/components/TutorialList/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react'
22

3-
import * as T from '../../../../typings/graphql'
3+
import * as T from 'typings/graphql'
44
import TutorialItem from './TutorialItem'
55

66
interface Props {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import * as React from 'react'
22
import { useQuery } from '@apollo/react-hooks'
33
import { Button, Card } from '@alifd/next'
4+
import * as T from 'typings/graphql'
45

56
import { send } from '../../utils/vscode'
67
import LoadingPage from '../LoadingPage'
78
import queryTutorial from './queryTutorial'
89
import ErrorView from '../../components/Error'
9-
import * as T from '../../../../typings/graphql'
1010

1111
interface Props {
1212
tutorial: T.Tutorial

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

+1-1
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 T from 'typings/graphql'
44

55
import queryTutorials from './queryTutorials'
66
import { send } from '../../utils/vscode'

web-app/src/containers/Tutorial/LevelSummaryPage/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as React from 'react'
22
import { useQuery } from '@apollo/react-hooks'
3+
import * as T from 'typings/graphql'
34

45
import ErrorView from '../../../components/Error'
56
import Level from '../../../components/Level'
6-
import * as T from '../../../../../typings/graphql'
77
import queryLevel from './queryLevel'
88

99
interface LevelProps {

web-app/tsconfig.paths.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"baseUrl": "src",
44
"rootDirs": ["src", "stories"],
55
"paths": {
6-
"typings": ["../../typings/index.d.ts"]
6+
"typings": ["../../typings/index.d.ts"],
7+
"typings/graphql": ["../../typings/graphql.d.ts"]
78
},
89
"allowSyntheticDefaultImports": true
910
},

0 commit comments

Comments
 (0)