Adds paypal button and completes the number of views
This commit is contained in:
@ -27,7 +27,7 @@ app$({ history, location: appLocation })
|
|||||||
.flatMap(
|
.flatMap(
|
||||||
({ AppCat }) => {
|
({ AppCat }) => {
|
||||||
// instantiate the cat with service
|
// instantiate the cat with service
|
||||||
const appCat = AppCat(null, services);
|
const appCat = AppCat(null, services, history);
|
||||||
// hydrate the stores
|
// hydrate the stores
|
||||||
return hydrate(appCat, catState)
|
return hydrate(appCat, catState)
|
||||||
.map(() => appCat);
|
.map(() => appCat);
|
||||||
|
@ -5,13 +5,13 @@ import { HikesActions, HikesStore } from './routes/Hikes/flux';
|
|||||||
import { JobActions, JobsStore} from './routes/Jobs/flux';
|
import { JobActions, JobsStore} from './routes/Jobs/flux';
|
||||||
|
|
||||||
export default Cat()
|
export default Cat()
|
||||||
.init(({ instance: cat, args: [services] }) => {
|
.init(({ instance: cat, args: [services, history] }) => {
|
||||||
cat.register(AppActions, null, services);
|
cat.register(AppActions, null, services, history);
|
||||||
cat.register(AppStore, null, cat);
|
cat.register(AppStore, null, cat);
|
||||||
|
|
||||||
cat.register(HikesActions, null, services);
|
cat.register(HikesActions, null, services);
|
||||||
cat.register(HikesStore, null, cat);
|
cat.register(HikesStore, null, cat);
|
||||||
|
|
||||||
cat.register(JobActions, null, services);
|
cat.register(JobActions, null, cat, services);
|
||||||
cat.register(JobsStore, null, cat);
|
cat.register(JobsStore, null, cat);
|
||||||
});
|
});
|
||||||
|
@ -16,10 +16,20 @@ export default Actions({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
getUser: null
|
getUser: null,
|
||||||
|
goTo: null,
|
||||||
|
goBack: null
|
||||||
})
|
})
|
||||||
.refs({ displayName: 'AppActions' })
|
.refs({ displayName: 'AppActions' })
|
||||||
.init(({ instance: appActions, args: [services] }) => {
|
.init(({ instance: appActions, args: [services, history] }) => {
|
||||||
|
appActions.goTo.subscribe((url) => {
|
||||||
|
history.pushState(null, url);
|
||||||
|
});
|
||||||
|
|
||||||
|
appActions.goBack.subscribe(() => {
|
||||||
|
history.goBack();
|
||||||
|
});
|
||||||
|
|
||||||
appActions.getUser.subscribe(({ isPrimed }) => {
|
appActions.getUser.subscribe(({ isPrimed }) => {
|
||||||
if (isPrimed) {
|
if (isPrimed) {
|
||||||
debug('isPrimed');
|
debug('isPrimed');
|
||||||
|
71
common/app/routes/Jobs/components/GoToPayPal.jsx
Normal file
71
common/app/routes/Jobs/components/GoToPayPal.jsx
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
import React, { PropTypes } from 'react';
|
||||||
|
import { Col, Well, Row } from 'react-bootstrap';
|
||||||
|
import { contain } from 'thundercats-react';
|
||||||
|
|
||||||
|
export default contain(
|
||||||
|
{
|
||||||
|
store: 'JobsStore',
|
||||||
|
actions: 'JobActions',
|
||||||
|
map({ job: { id } = {} }) {
|
||||||
|
return { id };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
React.createClass({
|
||||||
|
displayName: 'GoToPayPal',
|
||||||
|
|
||||||
|
propTypes: {
|
||||||
|
id: PropTypes.string
|
||||||
|
},
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { id } = this.props;
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Row>
|
||||||
|
<Col
|
||||||
|
xs={ 12 }
|
||||||
|
sm={ 8 }
|
||||||
|
smOffset={ 2 }
|
||||||
|
md={ 6 }
|
||||||
|
mdOffset={ 3 }>
|
||||||
|
<Well>
|
||||||
|
<form
|
||||||
|
action='https://www.sandbox.paypal.com/cgi-bin/webscr'
|
||||||
|
method='post'
|
||||||
|
target='_top'>
|
||||||
|
<input
|
||||||
|
name='cmd'
|
||||||
|
type='hidden'
|
||||||
|
value='_s-xclick' />
|
||||||
|
<input
|
||||||
|
name='hosted_button_id'
|
||||||
|
type='hidden'
|
||||||
|
value='ZVU498PLMPHKU' />
|
||||||
|
<input
|
||||||
|
alt='PayPal - The safer, easier way to pay online!'
|
||||||
|
border='0'
|
||||||
|
name='submit'
|
||||||
|
src={
|
||||||
|
'https://www.sandbox.paypal.com/' +
|
||||||
|
'en_US/i/btn/btn_buynowCC_LG.gif'
|
||||||
|
}
|
||||||
|
type='image' />
|
||||||
|
<input
|
||||||
|
name='custom'
|
||||||
|
type='hidden'
|
||||||
|
value={ '' + id } />
|
||||||
|
<img
|
||||||
|
alt=''
|
||||||
|
border='0'
|
||||||
|
height='1'
|
||||||
|
src='https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif'
|
||||||
|
width='1' />
|
||||||
|
</form>
|
||||||
|
</Well>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
19
common/app/routes/Jobs/components/NewJobCompleted.jsx
Normal file
19
common/app/routes/Jobs/components/NewJobCompleted.jsx
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import React, { PropTypes } from 'react';
|
||||||
|
import { Well, Row } from 'react-bootstrap';
|
||||||
|
|
||||||
|
export default React.createClass({
|
||||||
|
displayName: 'NewJobCompleted',
|
||||||
|
propTypes: {
|
||||||
|
},
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Row>
|
||||||
|
<Well>
|
||||||
|
Congrats!
|
||||||
|
</Well>
|
||||||
|
</Row>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
@ -1,5 +1,4 @@
|
|||||||
import React, { PropTypes } from 'react';
|
import React, { PropTypes } from 'react';
|
||||||
import { History } from 'react-router';
|
|
||||||
import { Well, Button, Row } from 'react-bootstrap';
|
import { Well, Button, Row } from 'react-bootstrap';
|
||||||
import { contain } from 'thundercats-react';
|
import { contain } from 'thundercats-react';
|
||||||
import ShowJob from './ShowJob.jsx';
|
import ShowJob from './ShowJob.jsx';
|
||||||
@ -7,7 +6,10 @@ import ShowJob from './ShowJob.jsx';
|
|||||||
export default contain(
|
export default contain(
|
||||||
{
|
{
|
||||||
store: 'JobsStore',
|
store: 'JobsStore',
|
||||||
actions: 'JobActions',
|
actions: [
|
||||||
|
'appActions',
|
||||||
|
'jobActions'
|
||||||
|
],
|
||||||
map({ form: job = {} }) {
|
map({ form: job = {} }) {
|
||||||
return { job };
|
return { job };
|
||||||
}
|
}
|
||||||
@ -15,15 +17,14 @@ export default contain(
|
|||||||
React.createClass({
|
React.createClass({
|
||||||
displayName: 'Preview',
|
displayName: 'Preview',
|
||||||
|
|
||||||
mixins: [History],
|
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
job: PropTypes.object
|
appActions: PropTypes.object,
|
||||||
|
job: PropTypes.object,
|
||||||
|
jobActions: PropTypes.object
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { job } = this.props;
|
const { appActions, job, jobActions } = this.props;
|
||||||
const { history } = this;
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<ShowJob job={ job } />
|
<ShowJob job={ job } />
|
||||||
@ -31,12 +32,18 @@ export default contain(
|
|||||||
<Well>
|
<Well>
|
||||||
<Button
|
<Button
|
||||||
block={ true }
|
block={ true }
|
||||||
className='signup-btn' >
|
className='signup-btn'
|
||||||
|
onClick={ () => {
|
||||||
|
jobActions.saveJobToDb({
|
||||||
|
goTo: '/jobs/new/check-out',
|
||||||
|
job
|
||||||
|
});
|
||||||
|
}}>
|
||||||
Looks great! Let's Check Out
|
Looks great! Let's Check Out
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
block={ true }
|
block={ true }
|
||||||
onClick={ () => history.goBack() } >
|
onClick={ () => appActions.goBack() } >
|
||||||
Head back and make edits
|
Head back and make edits
|
||||||
</Button>
|
</Button>
|
||||||
</Well>
|
</Well>
|
||||||
|
@ -31,6 +31,7 @@ export default Actions({
|
|||||||
},
|
},
|
||||||
setError: null,
|
setError: null,
|
||||||
getJob: null,
|
getJob: null,
|
||||||
|
saveJobToDb: null,
|
||||||
getJobs(params) {
|
getJobs(params) {
|
||||||
return { params };
|
return { params };
|
||||||
},
|
},
|
||||||
@ -61,7 +62,7 @@ export default Actions({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.refs({ displayName: 'JobActions' })
|
.refs({ displayName: 'JobActions' })
|
||||||
.init(({ instance: jobActions, args: [services] }) => {
|
.init(({ instance: jobActions, args: [cat, services] }) => {
|
||||||
jobActions.getJobs.subscribe(() => {
|
jobActions.getJobs.subscribe(() => {
|
||||||
services.read('jobs', null, null, (err, jobs) => {
|
services.read('jobs', null, null, (err, jobs) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -100,5 +101,17 @@ export default Actions({
|
|||||||
jobActions.setForm(job);
|
jobActions.setForm(job);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
jobActions.saveJobToDb.subscribe(({ goTo, job }) => {
|
||||||
|
const appActions = cat.getActions('appActions');
|
||||||
|
services.create('jobs', { job }, null, (err, job) => {
|
||||||
|
if (err) {
|
||||||
|
debug('job services experienced an issue', err);
|
||||||
|
return jobActions.setError(err);
|
||||||
|
}
|
||||||
|
jobActions.setJobs({ job });
|
||||||
|
appActions.goTo(goTo);
|
||||||
|
});
|
||||||
|
});
|
||||||
return jobActions;
|
return jobActions;
|
||||||
});
|
});
|
||||||
|
@ -2,6 +2,8 @@ import Jobs from './components/Jobs.jsx';
|
|||||||
import NewJob from './components/NewJob.jsx';
|
import NewJob from './components/NewJob.jsx';
|
||||||
import Show from './components/Show.jsx';
|
import Show from './components/Show.jsx';
|
||||||
import Preview from './components/Preview.jsx';
|
import Preview from './components/Preview.jsx';
|
||||||
|
import GoToPayPal from './components/GoToPayPal.jsx';
|
||||||
|
import NewJobCompleted from './components/NewJobCompleted.jsx';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* index: /jobs list jobs
|
* index: /jobs list jobs
|
||||||
@ -19,6 +21,12 @@ export default {
|
|||||||
}, {
|
}, {
|
||||||
path: 'jobs/new/preview',
|
path: 'jobs/new/preview',
|
||||||
component: Preview
|
component: Preview
|
||||||
|
}, {
|
||||||
|
path: 'jobs/new/check-out',
|
||||||
|
component: GoToPayPal
|
||||||
|
}, {
|
||||||
|
path: 'jobs/new/completed',
|
||||||
|
component: NewJobCompleted
|
||||||
}, {
|
}, {
|
||||||
path: 'jobs/:id',
|
path: 'jobs/:id',
|
||||||
component: Show
|
component: Show
|
||||||
|
@ -3,7 +3,15 @@ export default function getJobServices(app) {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
name: 'jobs',
|
name: 'jobs',
|
||||||
read: (req, resource, params, config, cb) => {
|
create(req, resource, { job } = {}, body, config, cb) {
|
||||||
|
if (!job) {
|
||||||
|
return cb(new Error('job creation should get a job object'));
|
||||||
|
}
|
||||||
|
Job.create(job, (err, savedJob) => {
|
||||||
|
cb(err, savedJob);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
read(req, resource, params, config, cb) {
|
||||||
const id = params ? params.id : null;
|
const id = params ? params.id : null;
|
||||||
if (id) {
|
if (id) {
|
||||||
return Job.findById(id, cb);
|
return Job.findById(id, cb);
|
||||||
|
Reference in New Issue
Block a user