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
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit779e104

Browse files
committed
refactor(Fragments/Job): fragment restructure / job banner
1 parent97bd129 commit779e104

File tree

41 files changed

+712
-271
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+712
-271
lines changed

‎containers/Banner/index.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { inject, observer } from 'mobx-react'
99

1010
importUserBannerfrom'../UserBanner'
1111
importPostBannerfrom'../PostBanner'
12+
importJobBannerfrom'../JobBanner'
1213
importCommunitiesBannerfrom'../CommunitiesBanner'
1314
importCommunityBannerfrom'../CommunityBanner'
1415

@@ -37,6 +38,9 @@ const BannerContent = ({ curRoute }) => {
3738
caseROUTE.POST:{
3839
return<PostBanner/>
3940
}
41+
caseROUTE.JOB:{
42+
return<JobBanner/>
43+
}
4044
caseROUTE.USER:{
4145
return<UserBanner/>
4246
}

‎containers/JobBanner/index.js‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
*
3+
* JobBanner
4+
*
5+
*/
6+
7+
importReactfrom'react'
8+
import{inject,observer}from'mobx-react'
9+
10+
// import { } from './styles'
11+
12+
import{makeDebugger,storePlug}from'../../utils'
13+
14+
import*aslogicfrom'./logic'
15+
/* eslint-disable no-unused-vars */
16+
constdebug=makeDebugger('C:JobBanner')
17+
/* eslint-enable no-unused-vars */
18+
19+
// NOTE: add me to ../containers/index
20+
classJobBannerContainerextendsReact.Component{
21+
componentWillMount(){
22+
const{ jobBanner}=this.props
23+
logic.init(jobBanner)
24+
}
25+
26+
render(){
27+
return(
28+
<div>
29+
<h2>JobBanner container!</h2>
30+
<div>impress me!</div>
31+
</div>
32+
)
33+
}
34+
}
35+
36+
exportdefaultinject(storePlug('jobBanner'))(observer(JobBannerContainer))

‎containers/JobBanner/logic.js‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// import R from 'ramda'
2+
3+
import{makeDebugger,$solver,asyncErr,ERR}from'../../utils'
4+
importSR71from'../../utils/network/sr71'
5+
6+
// import S from './schema'
7+
8+
constsr71$=newSR71()
9+
letsub$=null
10+
11+
/* eslint-disable no-unused-vars */
12+
constdebug=makeDebugger('L:JobBanner')
13+
/* eslint-enable no-unused-vars */
14+
15+
letstore=null
16+
17+
exportfunctionsomeMethod(){}
18+
19+
// ###############################
20+
// Data & Error handlers
21+
// ###############################
22+
23+
constDataSolver=[]
24+
constErrSolver=[
25+
{
26+
match:asyncErr(ERR.CRAPHQL),
27+
action:({ details})=>{
28+
debug('ERR.CRAPHQL -->',details)
29+
},
30+
},
31+
{
32+
match:asyncErr(ERR.TIMEOUT),
33+
action:({ details})=>{
34+
debug('ERR.TIMEOUT -->',details)
35+
},
36+
},
37+
{
38+
match:asyncErr(ERR.NETWORK),
39+
action:({ details})=>{
40+
debug('ERR.NETWORK -->',details)
41+
},
42+
},
43+
]
44+
45+
exportfunctioninit(_store){
46+
if(store)returnfalse
47+
store=_store
48+
49+
debug(store)
50+
if(sub$)sub$.unsubscribe()
51+
sub$=sr71$.data().subscribe($solver(DataSolver,ErrSolver))
52+
}

‎containers/JobBanner/schema.js‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
importgqlfrom'graphql-tag'
2+
3+
constsimpleMutation=gql`
4+
mutation($id: ID!) {
5+
post(id: $id) {
6+
id
7+
}
8+
}
9+
`
10+
constsimpleQuery=gql`
11+
query($filter: filter!) {
12+
post(id: $id) {
13+
id
14+
}
15+
}
16+
`
17+
18+
constschema={
19+
simpleMutation,
20+
simpleQuery,
21+
}
22+
23+
exportdefaultschema

‎containers/JobBanner/store.js‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* JobBanner store
3+
*
4+
*/
5+
6+
import{typesast,getParent}from'mobx-state-tree'
7+
// import R from 'ramda'
8+
9+
import{markStates,makeDebugger}from'../../utils'
10+
/* eslint-disable no-unused-vars */
11+
constdebug=makeDebugger('S:JobBanner')
12+
/* eslint-enable no-unused-vars */
13+
14+
// NOTE: add me to ../../stores/index && ../../stores/RootStore/index
15+
constJobBanner=t
16+
.model('JobBanner',{})
17+
.views(self=>({
18+
getroot(){
19+
returngetParent(self)
20+
},
21+
}))
22+
.actions(self=>({
23+
markState(sobj){
24+
markStates(sobj,self)
25+
},
26+
}))
27+
28+
exportdefaultJobBanner
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
importstyledfrom'styled-components'
2+
3+
// import Img from '../../../components/Img'
4+
// import { theme } from '../../../utils'
5+
6+
exportconstWrapper=styled.div``
7+
exportconstTitle=styled.div``
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// import React from 'react'
2+
// import { shallow } from 'enzyme'
3+
4+
// import JobBanner from '../index'
5+
6+
describe('TODO <JobBanner />',()=>{
7+
it('Expect to have unit tests specified',()=>{
8+
expect(true).toEqual(true)
9+
})
10+
})
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* JobBanner store test
3+
*
4+
*/
5+
6+
// import R from 'ramda'
7+
8+
// import JobBanner from '../index'
9+
10+
it('TODO: store test JobBanner',()=>{
11+
expect(1+1).toBe(2)
12+
})

‎containers/JobsThread/schema.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
importgqlfrom'graphql-tag'
2-
import{S}from'../fragments'
2+
import{P}from'../schemas'
33

44
constschema={
55
pagedJobs:gql`
6-
${S.pagedJobs}
6+
${P.pagedJobs}
77
`,
88
partialTags:gql`
9-
${S.partialTags}
9+
${P.partialTags}
1010
`,
1111
}
1212

‎containers/PostBanner/schema.js‎

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,6 @@
1-
importgqlfrom'graphql-tag'
1+
// import gql from 'graphql-tag'
2+
import{P}from'../schemas'
23

3-
constpostRaw=`
4-
query post($id: ID!) {
5-
post(id: $id) {
6-
id
7-
title
8-
body
9-
insertedAt
10-
updatedAt
11-
views
12-
length
13-
author {
14-
id
15-
avatar
16-
nickname
17-
bio
18-
location
19-
achievement {
20-
reputation
21-
}
22-
followersCount
23-
followingsCount
24-
}
25-
favoritedCount
26-
starredCount
27-
communities {
28-
id
29-
title
30-
logo
31-
}
32-
tags {
33-
id
34-
title
35-
color
36-
}
37-
}
38-
}
39-
`
40-
41-
constpost=gql`
42-
${postRaw}
43-
`
44-
45-
constschema={ post, postRaw}
4+
constschema={post:P.post}
465

476
exportdefaultschema

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp