Change goToPayPal flow
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, history);
|
const appCat = AppCat(null, services);
|
||||||
// hydrate the stores
|
// hydrate the stores
|
||||||
return hydrate(appCat, catState)
|
return hydrate(appCat, catState)
|
||||||
.map(() => appCat);
|
.map(() => appCat);
|
||||||
@ -36,6 +36,20 @@ app$({ history, location: appLocation })
|
|||||||
// redirects in the future
|
// redirects in the future
|
||||||
({ nextLocation, props }, appCat) => ({ nextLocation, props, appCat })
|
({ nextLocation, props }, appCat) => ({ nextLocation, props, appCat })
|
||||||
)
|
)
|
||||||
|
.doOnNext(({ appCat }) => {
|
||||||
|
const appStore = appCat.getStore('appStore');
|
||||||
|
const appActions = appCat.getActions('appActions');
|
||||||
|
|
||||||
|
appStore
|
||||||
|
.distinctUntilChanged()
|
||||||
|
.subscribe(function({ route = appLocation.pathname }) {
|
||||||
|
history.pushState(null, route);
|
||||||
|
});
|
||||||
|
|
||||||
|
appActions.goBack.subscribe(function() {
|
||||||
|
history.goBack();
|
||||||
|
});
|
||||||
|
})
|
||||||
.flatMap(({ props, appCat }) => {
|
.flatMap(({ props, appCat }) => {
|
||||||
props.history = history;
|
props.history = history;
|
||||||
return Render(
|
return Render(
|
||||||
|
@ -5,8 +5,8 @@ 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, history] }) => {
|
.init(({ instance: cat, args: [services] }) => {
|
||||||
cat.register(AppActions, null, services, history);
|
cat.register(AppActions, null, services);
|
||||||
cat.register(AppStore, null, cat);
|
cat.register(AppStore, null, cat);
|
||||||
|
|
||||||
cat.register(HikesActions, null, services);
|
cat.register(HikesActions, null, services);
|
||||||
|
@ -17,19 +17,13 @@ export default Actions({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getUser: null,
|
getUser: null,
|
||||||
goTo: null,
|
goTo(route) {
|
||||||
|
return { route };
|
||||||
|
},
|
||||||
goBack: null
|
goBack: null
|
||||||
})
|
})
|
||||||
.refs({ displayName: 'AppActions' })
|
.refs({ displayName: 'AppActions' })
|
||||||
.init(({ instance: appActions, args: [services, history] }) => {
|
.init(({ instance: appActions, args: [services] }) => {
|
||||||
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');
|
||||||
|
@ -14,10 +14,10 @@ export default Store({
|
|||||||
value: initValue
|
value: initValue
|
||||||
},
|
},
|
||||||
init({ instance: appStore, args: [cat] }) {
|
init({ instance: appStore, args: [cat] }) {
|
||||||
const { setUser, setTitle } = cat.getActions('appActions');
|
const { goTo, setUser, setTitle } = cat.getActions('appActions');
|
||||||
const register = createRegistrar(appStore);
|
const register = createRegistrar(appStore);
|
||||||
|
|
||||||
register(setter(fromMany(setUser, setTitle)));
|
register(setter(fromMany(setUser, setTitle, goTo)));
|
||||||
|
|
||||||
return appStore;
|
return appStore;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,10 @@ const paypalIds = {
|
|||||||
export default contain(
|
export default contain(
|
||||||
{
|
{
|
||||||
store: 'JobsStore',
|
store: 'JobsStore',
|
||||||
actions: 'jobActions',
|
actions: [
|
||||||
|
'jobActions',
|
||||||
|
'appActions'
|
||||||
|
],
|
||||||
map({
|
map({
|
||||||
job: { id, isHighlighted } = {},
|
job: { id, isHighlighted } = {},
|
||||||
buttonId = isHighlighted ?
|
buttonId = isHighlighted ?
|
||||||
@ -40,6 +43,7 @@ export default contain(
|
|||||||
displayName: 'GoToPayPal',
|
displayName: 'GoToPayPal',
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
appActions: PropTypes.object,
|
||||||
id: PropTypes.string,
|
id: PropTypes.string,
|
||||||
isHighlighted: PropTypes.bool,
|
isHighlighted: PropTypes.bool,
|
||||||
buttonId: PropTypes.string,
|
buttonId: PropTypes.string,
|
||||||
@ -51,6 +55,11 @@ export default contain(
|
|||||||
jobActions: PropTypes.object
|
jobActions: PropTypes.object
|
||||||
},
|
},
|
||||||
|
|
||||||
|
goToJobBoard() {
|
||||||
|
const { appActions } = this.props;
|
||||||
|
appActions.goTo('/jobs');
|
||||||
|
},
|
||||||
|
|
||||||
renderDiscount(discountAmount) {
|
renderDiscount(discountAmount) {
|
||||||
if (!discountAmount) {
|
if (!discountAmount) {
|
||||||
return null;
|
return null;
|
||||||
@ -217,7 +226,8 @@ export default contain(
|
|||||||
<form
|
<form
|
||||||
action='https://www.sandbox.paypal.com/cgi-bin/webscr'
|
action='https://www.sandbox.paypal.com/cgi-bin/webscr'
|
||||||
method='post'
|
method='post'
|
||||||
target='_top'>
|
onClick={ this.goToJobBoard }
|
||||||
|
target='_blank'>
|
||||||
<input
|
<input
|
||||||
name='cmd'
|
name='cmd'
|
||||||
type='hidden'
|
type='hidden'
|
||||||
|
Reference in New Issue
Block a user