@@ -9,21 +9,22 @@ import { Button, Modal } from 'react-bootstrap'
99import { Link } from 'react-router-dom'
1010import { library } from '@fortawesome/fontawesome-svg-core'
1111import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
12- import { faEdit , faLink , faHeart , faMobileAlt , faStickyNote , faSuperscript } from '@fortawesome/free-solid-svg-icons'
12+ import { faEdit , faLink , faHeart , faMobileAlt , faStickyNote , faSuperscript , faBell , faBellSlash } from '@fortawesome/free-solid-svg-icons'
1313import logo from './../images/metriq_logo_secondary_blue.png'
1414import Commento from '../components/Commento'
1515import FormFieldWideRow from '../components/FormFieldWideRow'
1616import SocialShareIcons from '../components/SocialShareIcons'
1717import { metricValueRegex , nonblankRegex } from '../components/ValidationRegex'
1818import ResultsTable from '../components/ResultsTable'
1919import FormFieldAlertRow from '../components/FormFieldAlertRow'
20+ import SubscribeButton from '../components/SubscriptionButton'
2021const FormFieldRow = React . lazy ( ( ) => import ( '../components/FormFieldRow' ) )
2122const FormFieldTypeaheadRow = React . lazy ( ( ) => import ( '../components/FormFieldTypeaheadRow' ) )
2223const SubmissionRefsAddModal = React . lazy ( ( ) => import ( '../components/SubmissionRefsAddModal' ) )
2324const SubmissionRefsDeleteModal = React . lazy ( ( ) => import ( '../components/SubmissionRefsDeleteModal' ) )
2425const ResultsAddModal = React . lazy ( ( ) => import ( '../components/ResultsAddModal' ) )
2526
26- library . add ( faEdit , faLink , faHeart , faMobileAlt , faStickyNote , faSuperscript )
27+ library . add ( faEdit , faLink , faHeart , faMobileAlt , faStickyNote , faSuperscript , faBell , faBellSlash )
2728
2829class Submission extends React . Component {
2930 constructor ( props ) {
@@ -96,6 +97,7 @@ class Submission extends React.Component {
9697 }
9798
9899 this . handleEditSubmissionDetails = this . handleEditSubmissionDetails . bind ( this )
100+ this . handleSubscribe = this . handleSubscribe . bind ( this )
99101 this . handleModerationReport = this . handleModerationReport . bind ( this )
100102 this . handleHideEditModal = this . handleHideEditModal . bind ( this )
101103 this . handleEditModalDone = this . handleEditModalDone . bind ( this )
@@ -136,6 +138,20 @@ class Submission extends React.Component {
136138 this . setState ( { showEditModal : true , modalMode : mode , submission : submission } )
137139 }
138140
141+ handleSubscribe ( ) {
142+ if ( this . props . isLoggedIn ) {
143+ axios . post ( config . api . getUriPrefix ( ) + '/submission/' + this . props . match . params . id + '/subscribe' , { } )
144+ . then ( res => {
145+ this . setState ( { item : res . data . data } )
146+ } )
147+ . catch ( err => {
148+ window . alert ( 'Error: ' + ErrorHandler ( err ) + '\nSorry! Check your connection and login status, and try again.' )
149+ } )
150+ } else {
151+ this . handleLoginRedirect ( )
152+ }
153+ }
154+
139155 handleModerationReport ( ) {
140156 let mode = 'Moderation'
141157 const modalTextMode = 'Moderation'
@@ -574,6 +590,7 @@ class Submission extends React.Component {
574590 < TooltipTrigger message = 'Edit submission' >
575591 < Button className = 'submission-button' variant = 'secondary' aria-label = 'Edit submission' onClick = { this . handleEditSubmissionDetails } > < FontAwesomeIcon icon = 'edit' /> </ Button >
576592 </ TooltipTrigger >
593+ < SubscribeButton isSubscribed = { this . state . item . isSubscribed } typeLabel = 'submission' onSubscribe = { this . handleSubscribe } />
577594 < SocialShareIcons url = { config . api . getUriPrefix ( ) + '/submission/' + this . props . match . params . id } />
578595 </ FormFieldWideRow >
579596 < br />
0 commit comments