From 22aa0139aee197cdf718275e360478a9ca2d17b2 Mon Sep 17 00:00:00 2001 From: diminator Date: Mon, 7 Sep 2015 12:03:59 +0200 Subject: [PATCH] terms and conditions page with accept/deny Needed: copyright societies in backend --- .../ikonotv/ikonotv_contract_notifications.js | 132 ++++++++++++++++-- .../whitelabel/wallet/wallet_routes.js | 2 +- js/constants/api_urls.js | 2 + js/stores/notification_store.js | 2 +- sass/ascribe_notification_page.scss | 51 +++++++ sass/main.scss | 1 + 6 files changed, 176 insertions(+), 14 deletions(-) create mode 100644 sass/ascribe_notification_page.scss diff --git a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_contract_notifications.js b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_contract_notifications.js index 5e30d370..db369564 100644 --- a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_contract_notifications.js +++ b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_contract_notifications.js @@ -1,14 +1,34 @@ 'use strict'; import React from 'react'; +import Router from 'react-router'; +import Glyphicon from 'react-bootstrap/lib/Glyphicon'; +import Button from 'react-bootstrap/lib/Button'; + +import Form from '../../../../ascribe_forms/form'; +import Property from '../../../../ascribe_forms/property'; +import InputCheckbox from '../../../../ascribe_forms/input_checkbox'; + +import NotificationActions from '../../../../../actions/notification_actions'; import NotificationStore from '../../../../../stores/notification_store'; import WhitelabelStore from '../../../../../stores/whitelabel_store'; +import GlobalNotificationModel from '../../../../../models/global_notification_model'; +import GlobalNotificationActions from '../../../../../actions/global_notification_actions'; + +import apiUrls from '../../../../../constants/api_urls'; + +import requests from '../../../../../utils/requests'; +import { getLangText } from '../../../../../utils/lang_utils'; import { mergeOptions } from '../../../../../utils/general_utils'; +let Navigation = Router.Navigation; + let IkonotvContractNotifications = React.createClass({ + mixins: [Navigation], + getInitialState() { return mergeOptions( NotificationStore.getState(), @@ -19,6 +39,9 @@ let IkonotvContractNotifications = React.createClass({ componentDidMount() { NotificationStore.listen(this.onChange); WhitelabelStore.listen(this.onChange); + if (this.state.contractAgreementListNotifications === null){ + NotificationActions.fetchContractAgreementListNotifications(); + } }, componentWillUnmount() { @@ -30,22 +53,107 @@ let IkonotvContractNotifications = React.createClass({ this.setState(state); }, - render() { - console.log(this.state) - return ( -
-
-
- -
-
- + displayContract(){ + let notifications = this.state.contractAgreementListNotifications[0]; + let blob = notifications.contract_agreement.contract.blob; + if (blob.mime === 'pdf') { + return ( +
+ +
+ ); + } + return ( +
+ + + Download contract +
); + }, + + handleConfirmSuccess() { + let notification = new GlobalNotificationModel(getLangText('You have accepted the conditions'), 'success', 10000); + GlobalNotificationActions.appendGlobalNotification(notification); + this.transitionTo('pieces'); + }, + + handleDeny() { + let contractAgreement = this.state.contractAgreementListNotifications[0].contract_agreement; + requests.post(apiUrls.ownership_contract_agreements_deny, {contract_agreement_id: contractAgreement.id}).then( + () => this.handleDenySuccess() + ); + }, + + handleDenySuccess() { + let notification = new GlobalNotificationModel(getLangText('You have denied the conditions'), 'success', 10000); + GlobalNotificationActions.appendGlobalNotification(notification); + this.transitionTo('pieces'); + }, + + render() { + + if (this.state.contractAgreementListNotifications && + this.state.contractAgreementListNotifications.length > 0) { + let contractAgreement = this.state.contractAgreementListNotifications[0].contract_agreement; + return ( +
+
+
+ +
+ {getLangText('Production Contract')} +
+
+ {this.displayContract()} +
+

{getLangText('Are you a member of any copyright societies?')}

+

+ ARS, DACS, Bildkunst, Pictoright, SODRAC, Copyright Agency/Viscopy, SAVA, Bildrecht GmbH, + SABAM, AUTVIS, CREAIMAGEN, SONECA, Copydan, EAU, Kuvasto, GCA, HUNGART, IVARO, SIAE, JASPAR-SPDA, + AKKA/LAA, LATGA-A, SOMAAP, ARTEGESTION, CARIER, BONO, APSAV, SPA, GESTOR, VISaRTA, RAO, LITA, + DALRO, VeGaP, BUS, ProLitteris, AGADU, AUTORARTE, BUBEDRA, BBDA, BCDA, BURIDA, ADAVIS, BSDA +

+
+ + +

+ }> + + + + {' ' + getLangText('Yes') } + + + + +
+
+
+
+ ); + } + return null; } }); diff --git a/js/components/whitelabel/wallet/wallet_routes.js b/js/components/whitelabel/wallet/wallet_routes.js index 4a0f022c..bc9e0e19 100644 --- a/js/components/whitelabel/wallet/wallet_routes.js +++ b/js/components/whitelabel/wallet/wallet_routes.js @@ -78,7 +78,7 @@ let ROUTES = { - + ) }; diff --git a/js/constants/api_urls.js b/js/constants/api_urls.js index 54a398d2..fcf9be6f 100644 --- a/js/constants/api_urls.js +++ b/js/constants/api_urls.js @@ -33,6 +33,8 @@ let ApiUrls = { 'notification_edition': AppConstants.apiEndpoint + 'notifications/editions/${edition_id}/', 'notification_contractagreementlist': AppConstants.apiEndpoint + 'notifications/contract_agreements/', 'ownership_contract_agreements': AppConstants.apiEndpoint + 'ownership/contract_agreements/', + 'ownership_contract_agreements_confirm': AppConstants.apiEndpoint + 'ownership/contract_agreements/${contract_agreement_id}/accept/', + 'ownership_contract_agreements_deny': AppConstants.apiEndpoint + 'ownership/contract_agreements/${contract_agreement_id}/reject/', 'ownership_consigns': AppConstants.apiEndpoint + 'ownership/consigns/', 'ownership_consigns_confirm': AppConstants.apiEndpoint + 'ownership/consigns/confirm/', 'ownership_consigns_deny': AppConstants.apiEndpoint + 'ownership/consigns/deny/', diff --git a/js/stores/notification_store.js b/js/stores/notification_store.js index 84c5f5d7..9f6bdecf 100644 --- a/js/stores/notification_store.js +++ b/js/stores/notification_store.js @@ -10,7 +10,7 @@ class NotificationStore { constructor() { this.pieceListNotifications = {}; this.editionListNotifications = {}; - this.contractAgreementListNotifications = {}; + this.contractAgreementListNotifications = null; this.editionNotifications = null; this.pieceNotifications = null; this.bindActions(NotificationActions); diff --git a/sass/ascribe_notification_page.scss b/sass/ascribe_notification_page.scss new file mode 100644 index 00000000..f7cccbde --- /dev/null +++ b/sass/ascribe_notification_page.scss @@ -0,0 +1,51 @@ + +.notification-contract-download { + +} + +.notification-contract-wrapper{ + text-align: center; +} + +.notification-contract-logo { + + img { + margin-bottom: 1em; + } + .notification-contract-header { + font-size: 2em; + text-transform: uppercase; + margin-bottom: 0.8em; + } +} + +.notification-contract-pdf, .notification-contract-footer { + width: 100%; + max-width: 750px; + margin: 0 auto; +} +.notification-contract-pdf { + embed { + border: 1px solid #cccccc; + width: 100%; + height: 60vh; + margin-bottom: 0.4em; + } + .notification-contract-pdf-download { + text-align: left; + margin-left: 1em; + } +} + +.notification-contract-footer { + text-align: left; + padding: 1em; + h1 { + margin-top: 0.4em; + font-size: 1.4em; + } + p { + font-size: 0.9em; + color: #444444; + } +} \ No newline at end of file diff --git a/sass/main.scss b/sass/main.scss index fb71ff2a..c325fdf7 100644 --- a/sass/main.scss +++ b/sass/main.scss @@ -25,6 +25,7 @@ $BASE_URL: '<%= BASE_URL %>'; @import 'ascribe_global_action'; @import 'ascribe_global_notification'; @import 'ascribe_notification_list'; +@import 'ascribe_notification_page'; @import 'ascribe_piece_register'; @import 'offset_right'; @import 'ascribe_settings';