mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 09:23:13 +01:00
contract agreement notifications
This commit is contained in:
parent
6a1f58fdb4
commit
9b7a69bc20
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
import alt from '../alt';
|
||||
import Q from 'q';
|
||||
|
||||
import NotificationFetcher from '../fetchers/notification_fetcher';
|
||||
|
||||
@ -10,7 +11,8 @@ class NotificationActions {
|
||||
'updatePieceListNotifications',
|
||||
'updateEditionListNotifications',
|
||||
'updateEditionNotifications',
|
||||
'updatePieceNotifications'
|
||||
'updatePieceNotifications',
|
||||
'updateContractAgreementListNotifications'
|
||||
);
|
||||
}
|
||||
|
||||
@ -49,6 +51,18 @@ class NotificationActions {
|
||||
})
|
||||
.catch((err) => console.logGlobal(err));
|
||||
}
|
||||
|
||||
fetchContractAgreementListNotifications() {
|
||||
return Q.Promise((resolve, reject) => {
|
||||
NotificationFetcher
|
||||
.fetchContractAgreementListNotifications()
|
||||
.then((res) => {
|
||||
this.actions.updateContractAgreementListNotifications(res);
|
||||
resolve(res);
|
||||
})
|
||||
.catch((err) => console.logGlobal(err));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default alt.createActions(NotificationActions);
|
||||
|
@ -26,6 +26,7 @@ import EventActions from './actions/event_actions';
|
||||
import GoogleAnalyticsHandler from './third_party/ga';
|
||||
import RavenHandler from './third_party/raven';
|
||||
import IntercomHandler from './third_party/intercom';
|
||||
import NotificationsHandler from './third_party/notifications';
|
||||
/* eslint-enable */
|
||||
|
||||
initLogging();
|
||||
@ -73,7 +74,7 @@ class AppGateway {
|
||||
}
|
||||
|
||||
EventActions.applicationWillBoot(settings);
|
||||
Router.run(getRoutes(type, subdomain), Router.HistoryLocation, (App) => {
|
||||
window.appRouter = Router.run(getRoutes(type, subdomain), Router.HistoryLocation, (App) => {
|
||||
React.render(
|
||||
<App />,
|
||||
document.getElementById('main')
|
||||
|
@ -60,8 +60,8 @@ let ContractAgreementForm = React.createClass({
|
||||
},
|
||||
|
||||
getContracts() {
|
||||
if (this.state.contractList && this.state.contractList.count > 0) {
|
||||
let contractList = this.state.contractList.results;
|
||||
if (this.state.contractList && this.state.contractList.length > 0) {
|
||||
let contractList = this.state.contractList;
|
||||
return (
|
||||
<Property
|
||||
name='contract'
|
||||
@ -81,7 +81,7 @@ let ContractAgreementForm = React.createClass({
|
||||
<option
|
||||
name={i}
|
||||
key={i}
|
||||
value={ contract.name }>
|
||||
value={ contract.id }>
|
||||
{ contract.name }
|
||||
</option>
|
||||
);
|
||||
|
36
js/components/contract_notification.js
Normal file
36
js/components/contract_notification.js
Normal file
@ -0,0 +1,36 @@
|
||||
'use strict';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import NotificationStore from '../stores/notification_store';
|
||||
|
||||
import { mergeOptions } from '../utils/general_utils';
|
||||
|
||||
let ContractNotification = React.createClass({
|
||||
getInitialState() {
|
||||
return mergeOptions(
|
||||
NotificationStore.getState()
|
||||
);
|
||||
},
|
||||
|
||||
componentDidMount() {
|
||||
NotificationStore.listen(this.onChange);
|
||||
},
|
||||
|
||||
componentWillUnmount() {
|
||||
NotificationStore.unlisten(this.onChange);
|
||||
},
|
||||
|
||||
onChange(state) {
|
||||
this.setState(state);
|
||||
},
|
||||
|
||||
render() {
|
||||
|
||||
return (
|
||||
null
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
export default ContractNotification;
|
@ -0,0 +1,45 @@
|
||||
'use strict';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import NotificationStore from '../../../../../stores/notification_store';
|
||||
import WhitelabelStore from '../../../../../stores/whitelabel_store';
|
||||
|
||||
import { mergeOptions } from '../../../../../utils/general_utils';
|
||||
|
||||
let IkonotvContractNotifications = React.createClass({
|
||||
|
||||
getInitialState() {
|
||||
return mergeOptions(
|
||||
NotificationStore.getState(),
|
||||
WhitelabelStore.getState()
|
||||
);
|
||||
},
|
||||
|
||||
componentDidMount() {
|
||||
NotificationStore.listen(this.onChange);
|
||||
WhitelabelStore.listen(this.onChange);
|
||||
},
|
||||
|
||||
componentWillUnmount() {
|
||||
NotificationStore.unlisten(this.onChange);
|
||||
WhitelabelStore.unlisten(this.onChange);
|
||||
},
|
||||
|
||||
onChange(state) {
|
||||
this.setState(state);
|
||||
},
|
||||
|
||||
render() {
|
||||
console.log(this.state)
|
||||
return (
|
||||
<div className='container'>
|
||||
<div className='text-center'>
|
||||
<img src={this.state.whitelabel.logo} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
export default IkonotvContractNotifications;
|
@ -22,6 +22,7 @@ import CylandPieceList from './components/cyland/cyland_piece_list';
|
||||
import IkonotvPieceList from './components/ikonotv/ikonotv_piece_list';
|
||||
import IkonotvRequestLoan from './components/ikonotv/ikonotv_request_loan';
|
||||
import IkonotvPieceContainer from './components/ikonotv/ascribe_detail/ikonotv_piece_container';
|
||||
import IkonotvContractNotifications from './components/ikonotv/ikonotv_contract_notifications';
|
||||
|
||||
import CCRegisterPiece from './components/cc/cc_register_piece';
|
||||
|
||||
@ -77,6 +78,7 @@ let ROUTES = {
|
||||
<Route name="piece" path="pieces/:pieceId" handler={IkonotvPieceContainer} />
|
||||
<Route name="edition" path="editions/:editionId" handler={EditionContainer} />
|
||||
<Route name="settings" path="settings" handler={SettingsContainer} />
|
||||
<Route name="contract_notifications" path="verify" handler={IkonotvContractNotifications} />
|
||||
</Route>
|
||||
)
|
||||
};
|
||||
|
@ -31,6 +31,7 @@ let ApiUrls = {
|
||||
'notification_piece': AppConstants.apiEndpoint + 'notifications/pieces/${piece_id}/',
|
||||
'notification_editionlist': AppConstants.apiEndpoint + 'notifications/editions/',
|
||||
'notification_edition': AppConstants.apiEndpoint + 'notifications/editions/${edition_id}/',
|
||||
'notification_contractagreementlist': AppConstants.apiEndpoint + 'notifications/contract_agreements/',
|
||||
'ownership_contract_agreements': AppConstants.apiEndpoint + 'ownership/contract_agreements/',
|
||||
'ownership_consigns': AppConstants.apiEndpoint + 'ownership/consigns/',
|
||||
'ownership_consigns_confirm': AppConstants.apiEndpoint + 'ownership/consigns/confirm/',
|
||||
@ -51,8 +52,8 @@ let ApiUrls = {
|
||||
'ownership_unconsigns': AppConstants.apiEndpoint + 'ownership/unconsigns/',
|
||||
'ownership_unconsigns_deny': AppConstants.apiEndpoint + 'ownership/unconsigns/deny/',
|
||||
'ownership_unconsigns_request': AppConstants.apiEndpoint + 'ownership/unconsigns/request/',
|
||||
'ownership_contract':AppConstants.apiEndpoint + 'ownership/contracts/${contract_id}',
|
||||
"ownership_contract_list": AppConstants.apiEndpoint + 'ownership/contracts/',
|
||||
'ownership_contract': AppConstants.apiEndpoint + 'ownership/contracts/${contract_id}',
|
||||
'ownership_contract_list': AppConstants.apiEndpoint + 'ownership/contracts/',
|
||||
'piece': AppConstants.apiEndpoint + 'pieces/${piece_id}/',
|
||||
'piece_extradata': AppConstants.apiEndpoint + 'pieces/${piece_id}/extradata/',
|
||||
'piece_first_edition_id': AppConstants.apiEndpoint + 'pieces/${piece_id}/edition_index/',
|
||||
|
@ -19,6 +19,10 @@ let NotificationFetcher = {
|
||||
|
||||
fetchEditionNotifications(editionId) {
|
||||
return requests.get('notification_edition', {'edition_id': editionId});
|
||||
},
|
||||
|
||||
fetchContractAgreementListNotifications() {
|
||||
return requests.get('notification_contractagreementlist');
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -21,7 +21,7 @@ import SettingsContainer from './components/ascribe_settings/settings_container'
|
||||
import CoaVerifyContainer from './components/coa_verify_container';
|
||||
|
||||
import RegisterPiece from './components/register_piece';
|
||||
|
||||
import ContractNotification from './components/contract_notification';
|
||||
|
||||
import AppConstants from './constants/application_constants';
|
||||
|
||||
@ -44,6 +44,7 @@ const COMMON_ROUTES = (
|
||||
<Route name="password_reset" path="password_reset" handler={PasswordResetContainer} />
|
||||
<Route name="settings" path="settings" handler={SettingsContainer} />
|
||||
<Route name="coa_verify" path="verify" handler={CoaVerifyContainer} />
|
||||
<Route name="contract_notifications" path="verify" handler={ContractNotification} />
|
||||
</Route>
|
||||
);
|
||||
|
||||
|
@ -10,6 +10,7 @@ class NotificationStore {
|
||||
constructor() {
|
||||
this.pieceListNotifications = {};
|
||||
this.editionListNotifications = {};
|
||||
this.contractAgreementListNotifications = {};
|
||||
this.editionNotifications = null;
|
||||
this.pieceNotifications = null;
|
||||
this.bindActions(NotificationActions);
|
||||
@ -31,6 +32,10 @@ class NotificationStore {
|
||||
this.editionNotifications = res.notification;
|
||||
}
|
||||
|
||||
onUpdateContractAgreementListNotifications(res) {
|
||||
this.contractAgreementListNotifications = res.notifications;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default alt.createStore(NotificationStore, 'NotificationStore');
|
||||
|
36
js/third_party/notifications.js
vendored
Normal file
36
js/third_party/notifications.js
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
'use strict';
|
||||
|
||||
import alt from '../alt';
|
||||
import EventActions from '../actions/event_actions';
|
||||
|
||||
import NotificationActions from '../actions/notification_actions';
|
||||
|
||||
|
||||
class NotificationsHandler {
|
||||
|
||||
constructor() {
|
||||
this.bindActions(EventActions);
|
||||
this.loaded = false;
|
||||
}
|
||||
|
||||
onProfileDidLoad(profile) {
|
||||
if (this.loaded) {
|
||||
return;
|
||||
}
|
||||
let subdomain = window.location.host.split('.')[0];
|
||||
if (subdomain === 'ikonotv') {
|
||||
NotificationActions.fetchContractAgreementListNotifications().then(
|
||||
(res) => {
|
||||
if (res.notifications && res.notifications.length > 0) {
|
||||
this.loaded = true;
|
||||
console.log('Contractagreement notifications loaded');
|
||||
setTimeout(() => window.appRouter.transitionTo('contract_notifications'), 0);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
this.loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
export default alt.createStore(NotificationsHandler, 'NotificationsHandler');
|
Loading…
Reference in New Issue
Block a user