Skip to content

Commit

Permalink
Merge pull request #19 from tutorcruncher/enquiry-ga-label
Browse files Browse the repository at this point in the history
correct ga label for enquiries
  • Loading branch information
tomhamiltonstubber authored Mar 14, 2018
2 parents e818ab4 + 06ecec0 commit 1ad45bd
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tutorcruncher-socket",
"version": "1.3.5",
"version": "1.3.6",
"description": "TutorCruncher socket",
"author": "Samuel Colvin <samuel@tutorcruncher.com>",
"private": false,
Expand Down
5 changes: 4 additions & 1 deletion src/components/contractors/ConModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ class ConModal extends Component {
style={{transition: `all ${TRANSITION_TIME}ms ease-in-out`}}>

<IfElse v={this.state.show_enquiry}>
<EnquiryForm contractor={contractor} root={this.props.root} config={this.props.config}/>
<EnquiryForm contractor={contractor}
root={this.props.root}
config={this.props.config}
mode='con-modal'/>
{/*else:*/}
<ConDetails contractor={contractor}
contractor_extra={contractor_extra}
Expand Down
2 changes: 1 addition & 1 deletion src/components/enquiry/EnquiryModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const EnquiryModal = ({root, config, history}) => (
<Modal history={history} title={root.get_text('enquiry_title')}>
<div className="tcs-body">
<div className="tcs-content">
<EnquiryForm root={root} config={config}/>
<EnquiryForm root={root} config={config} mode='enquiry-modal'/>
</div>
</div>
</Modal>
Expand Down
2 changes: 1 addition & 1 deletion src/components/enquiry/PlainEnquiry.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import EnquiryForm from '../shared/EnquiryForm'

const PlainEnquiry = ({root, config}) => (
<div className="tcs-app">
<EnquiryForm root={root} config={config}/>
<EnquiryForm root={root} config={config} mode='vanilla'/>
</div>
)

Expand Down
11 changes: 7 additions & 4 deletions src/components/shared/EnquiryForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ class EnquiryForm extends Component {
grecaptcha_missing: false,
enquiry_data: {},
}
this.mode = this.props.mode || 'vanilla'
if (!this.props.mode) {
throw Error('Enquiry form mode not set')
}
this.grecaptcha_container_id = 'grecaptcha_' + this.props.config.random_id
this.render_grecaptcha = this.render_grecaptcha.bind(this)
this.submit = this.submit.bind(this)
this.set_enquiry_data = this.set_enquiry_data.bind(this)
}

componentDidMount () {
if (this.mode !== 'vanilla') {
if (this.props.mode !== 'vanilla') {
this.props.root.ga_event('enquiry-form', 'loaded', this.props.mode)
}

Expand Down Expand Up @@ -51,7 +53,7 @@ class EnquiryForm extends Component {

const r = await this.props.root.requests.post('enquiry', this.state.enquiry_data, [201, 400])
if (r.status === 201) {
this.props.root.ga_event('enquiry-form', 'submitted', this.mode)
this.props.root.ga_event('enquiry-form', 'submitted', this.props.mode)
this.setState({submitted: true})
} else {
console.warn('Invalid form:', r)
Expand Down Expand Up @@ -96,7 +98,8 @@ class EnquiryForm extends Component {
<IfElse v={this.state.submitted}>
<div className="tcs-submitted">
<Markdown content={
get_text(this.mode.includes('modal') ? 'enquiry_modal_submitted_thanks' : 'enquiry_submitted_thanks')
get_text(this.props.mode.includes('modal')
? 'enquiry_modal_submitted_thanks' : 'enquiry_submitted_thanks')
}/>
</div>
{/*else:*/}
Expand Down

0 comments on commit 1ad45bd

Please sign in to comment.