Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit4456261

Browse files
committed
setup new page query
1 parent4bd3fad commit4456261

File tree

3 files changed

+54
-40
lines changed

3 files changed

+54
-40
lines changed

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

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,50 @@ import { Button } from '@alifd/next'
44
importCondfrom'../../components/Cond'
55
importDataContextfrom'../../utils/DataContext'
66
import{send}from'../../utils/vscode'
7+
import{useQuery}from'@apollo/react-hooks'
8+
importqueryfrom'./query'
9+
710
importLoadingPagefrom'../../containers/LoadingPage'
811

912
interfaceProps{
13+
state:any
14+
tutorialList:any[]
1015
onNew(tutorialId:string):void
1116
}
1217

13-
exportconstNewPage=(props:Props)=>{
18+
exportconstNewPage=(props:Props)=>(
19+
<div>
20+
<Condstate={props.state}path="SelectTutorial.NewTutorial.SelectTutorial">
21+
<div>
22+
<h2>Start a new Project</h2>
23+
{props.tutorialList.map(tutorial=>(
24+
<div>
25+
<h3>{tutorial.title}</h3>
26+
<p>{tutorial.description}</p>
27+
<ButtononClick={()=>props.onNew(tutorial.id)}>Start</Button>
28+
</div>
29+
))}
30+
</div>
31+
</Cond>
32+
<Condstate={props.state}path="SelectTutorial.NewTutorial.InitializeTutorial">
33+
<LoadingPagetext="Launching Tutorial..."/>
34+
</Cond>
35+
</div>
36+
)
37+
38+
exportdefault()=>{
39+
console.log('load new')
1440
const{ state}=React.useContext(DataContext)
41+
const{ data, loading, error}=useQuery(query)
1542
const[tutorialList]=React.useState([{id:'1',title:'Demo',description:'A basic demo'}])
16-
// context
17-
return(
18-
<div>
19-
<Condstate={state}path="SelectTutorial.NewTutorial.SelectTutorial">
20-
<div>
21-
<h2>Start a new Project</h2>
22-
{tutorialList.map(tutorial=>(
23-
<div>
24-
<h3>{tutorial.title}</h3>
25-
<p>{tutorial.description}</p>
26-
<ButtononClick={()=>props.onNew(tutorial.id)}>Start</Button>
27-
</div>
28-
))}
29-
</div>
30-
</Cond>
31-
<Condstate={state}path="SelectTutorial.NewTutorial.InitializeTutorial">
32-
<LoadingPagetext="Launching Tutorial..."/>
33-
</Cond>
34-
</div>
35-
)
36-
}
43+
console.log('data',data)
44+
if(loading){
45+
returnnull
46+
}
3747

38-
exportdefault()=><NewPageonNew={()=>send('TUTORIAL_START')}/>
48+
if(error){
49+
return<div>'Error'</div>
50+
}
51+
52+
return<NewPageonNew={()=>send('TUTORIAL_START')}state={state}tutorialList={tutorialList}/>
53+
}

‎web-app/src/containers/New/query.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import{gql}from'apollo-boost'
2+
3+
exportdefaultgql`
4+
query getTutorials {
5+
tutorials {
6+
id
7+
title
8+
text
9+
codingLanguage
10+
latestVersion {
11+
version
12+
coderoadVersion
13+
}
14+
}
15+
}
16+
`

‎web-app/src/containers/New/tutorials.gql

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp