Skip to content

Commit 9c911bb

Browse files
Merge pull request #22 from tutorcruncher/terms-and-conditions
adding terms and conditions
2 parents 29952e5 + 2a5e968 commit 9c911bb

File tree

6 files changed

+39
-6
lines changed

6 files changed

+39
-6
lines changed

public/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
router_mode: 'history',
6464
mode: 'enquiry',
6565
api_root: api_root,
66+
terms_link: 'https://www.example.com',
6667
})
6768
socket(public_key, {
6869
element: '#socket4',

src/components/shared/EnquiryForm.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ class EnquiryForm extends Component {
9393
get_text('contractor_enquiry', {contractor_name: this.props.contractor.name}) :
9494
get_text('enquiry', {})
9595
)
96+
const terms_field = this.props.config.terms_link && {
97+
type: 'checkbox',
98+
field: 'terms_and_conditions',
99+
label: get_text('terms_title'),
100+
help_class: 'tcs-terms',
101+
required: true,
102+
}
96103
return (
97104
<div className="tcs-enquiry">
98105
<IfElse v={this.state.submitted}>
@@ -118,6 +125,17 @@ class EnquiryForm extends Component {
118125
set_enquiry_data={this.set_enquiry_data}/>
119126
))}
120127

128+
{terms_field && <Input key="terms"
129+
field={terms_field}
130+
get_text={get_text}
131+
enquiry_data={this.state.enquiry_data}
132+
set_enquiry_data={this.set_enquiry_data}>
133+
{get_text('terms_help')}&nbsp;
134+
<a href={this.props.config.terms_link} target="_blank">
135+
{get_text('terms_link')}
136+
</a>.
137+
</Input>}
138+
121139
<div id={this.grecaptcha_container_id} className="grecaptcha"/>
122140

123141
<If v={this.state.grecaptcha_missing}>

src/components/shared/Input.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ class Input extends Component {
130130

131131
render () {
132132
const field = this.props.field
133-
const field_label = field.label + (field.required ? this.props.get_text('required') : '')
133+
let field_label = field.label
134+
field_label += field.required && field.type !== 'checkbox' ? this.props.get_text('required') : ''
134135
const name = field.prefix ? field.prefix + '-' + field.field : field.field
135136
let value
136137
if (field.prefix) {
@@ -144,8 +145,8 @@ class Input extends Component {
144145
return (
145146
<div className="tcs-field" id={'field-' + name}>
146147
<Input field={field} name={name} value={value} field_label={field_label} on_change={this.on_change}/>
147-
<div className={'help-text' + (field.prefix ? '' : ' muted')}>
148-
{field.help_text}
148+
<div className={field.help_class || ('help-text' + (field.prefix ? '' : ' muted'))}>
149+
{this.props.children || field.help_text}
149150
</div>
150151
</div>
151152
)

src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ const STRINGS = {
8989
location: 'Location',
9090
not_you_sign_out: 'Not you? sign out',
9191
added: 'Added',
92-
assuming_timezone: "Times are based off your browser's timezone of {timezone}"
92+
assuming_timezone: "Times are based off your browser's timezone of {timezone}",
93+
terms_title: 'Terms and Conditions',
94+
terms_help: 'I have read and agree to the',
95+
terms_link: 'terms and conditions',
9396
}
9497

9598
const MODES = ['grid', 'list', 'enquiry', 'enquiry-modal', 'appointments']

src/styles/enquiry.scss

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,18 @@ form.tcs {
2424
}
2525
}
2626

27+
.tcs-terms {
28+
color: #666;
29+
a {
30+
color: #044d9c;
31+
text-decoration: none;
32+
}
33+
}
34+
2735
.grecaptcha > div {
28-
margin: 0 auto;
36+
margin: 8px auto;
2937
}
38+
3039
.error-msg {
3140
color: darkred;
3241
text-align: center;

src/styles/input.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ $border-radius: 5px;
4040
display: block;
4141
}
4242
input[type="checkbox"] {
43-
width: auto;
43+
width: auto;
44+
margin-right: 10px;
4445
}
4546
.help-text {
4647
font-size: 14px;

0 commit comments

Comments
 (0)