jobs store fetching
This commit is contained in:
@ -5,7 +5,7 @@ import { Grid, Row } from 'react-bootstrap';
|
|||||||
export default contain(
|
export default contain(
|
||||||
{
|
{
|
||||||
store: 'jobsStore',
|
store: 'jobsStore',
|
||||||
actions: 'jobActions'
|
fetchAction: 'jobActions.getJobs'
|
||||||
},
|
},
|
||||||
React.createClass({
|
React.createClass({
|
||||||
displayName: 'Jobs',
|
displayName: 'Jobs',
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
import { Actions } from 'thundercats';
|
import { Actions } from 'thundercats';
|
||||||
|
import debugFactory from 'debug';
|
||||||
|
|
||||||
|
const debug = debugFactory('freecc:jobs:actions');
|
||||||
|
|
||||||
export default Actions({
|
export default Actions({
|
||||||
|
setJobs: null,
|
||||||
getJob(id) {
|
getJob(id) {
|
||||||
return { id };
|
return { id };
|
||||||
},
|
},
|
||||||
@ -8,4 +12,16 @@ export default Actions({
|
|||||||
return { params };
|
return { params };
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.refs({ displayName: 'JobsActions' });
|
.refs({ displayName: 'JobActions' })
|
||||||
|
.init(({ instance: jobActions, args: [services] }) => {
|
||||||
|
jobActions.getJobs.subscribe(() => {
|
||||||
|
services.read('job', null, null, (err, jobs) => {
|
||||||
|
if (err) {
|
||||||
|
debug('job services experienced an issue', err);
|
||||||
|
jobActions.setJobs({ jobs: [] });
|
||||||
|
}
|
||||||
|
jobActions.setJobs({ jobs });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return jobActions;
|
||||||
|
});
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
import { Store } from 'thundercats';
|
import { Store } from 'thundercats';
|
||||||
|
|
||||||
|
const { setter } = Store;
|
||||||
|
|
||||||
export default Store()
|
export default Store()
|
||||||
.refs({ displayName: 'JobsStore' })
|
.refs({ displayName: 'JobsStore' })
|
||||||
.init(({ instance: jobsStore, args: [cat] }) => {
|
.init(({ instance: jobsStore, args: [cat] }) => {
|
||||||
let jobsActions = cat.getActions('JobsActions');
|
let jobActions = cat.getActions('JobActions');
|
||||||
jobsStore.register(jobsActions.getJob);
|
jobsStore.register(setter(jobActions.setJobs));
|
||||||
});
|
});
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
import Fetchr from 'fetchr';
|
import Fetchr from 'fetchr';
|
||||||
import getHikesService from '../services/hikes';
|
import getHikesService from '../services/hikes';
|
||||||
|
import getJobServices from '../services/job';
|
||||||
import getUserServices from '../services/user';
|
import getUserServices from '../services/user';
|
||||||
|
|
||||||
export default function bootServices(app) {
|
export default function bootServices(app) {
|
||||||
const hikesService = getHikesService(app);
|
const hikesService = getHikesService(app);
|
||||||
|
const jobServices = getJobServices(app);
|
||||||
const userServices = getUserServices(app);
|
const userServices = getUserServices(app);
|
||||||
|
|
||||||
Fetchr.registerFetcher(hikesService);
|
Fetchr.registerFetcher(hikesService);
|
||||||
|
Fetchr.registerFetcher(jobServices);
|
||||||
Fetchr.registerFetcher(userServices);
|
Fetchr.registerFetcher(userServices);
|
||||||
app.use('/services', Fetchr.middleware());
|
app.use('/services', Fetchr.middleware());
|
||||||
}
|
}
|
||||||
|
12
server/services/job.js
Normal file
12
server/services/job.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
export default function getJobServices(app) {
|
||||||
|
const { Job } = app.models;
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: 'job',
|
||||||
|
read: (req, resource, params, config, cb) => {
|
||||||
|
Job.find({}, (err, jobs) => {
|
||||||
|
cb(err, jobs);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
Reference in New Issue
Block a user