Skip to content

Commit e28961c

Browse files
committed
photo urls for list views
1 parent b4437da commit e28961c

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tutorcruncher-socket",
3-
"version": "1.3.3",
3+
"version": "1.3.4",
44
"description": "TutorCruncher socket",
55
"author": "Samuel Colvin <[email protected]>",
66
"private": false,

src/components/contractors/ConModal.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Component } from 'react'
22
import Modal from '../shared/Modal'
3-
import { Location, IfElse } from '../shared/Tools'
3+
import {Location, IfElse, Photo} from '../shared/Tools'
44
import ConDetails from './ConDetails'
55
import EnquiryForm from '../shared/EnquiryForm'
66
import Stars from './Stars'
@@ -51,15 +51,11 @@ class ConModal extends Component {
5151
)
5252
}
5353
const {contractor, contractor_extra} = _con
54-
let photo_src = contractor.photo
55-
if (photo_src.startsWith('/')) {
56-
photo_src = this.props.config.api_root + photo_src
57-
}
5854
return (
5955
<Modal history={this.props.history} title={contractor.name} last_url={this.props.last_url}>
6056
<div className="tcs-body">
6157
<div className="tcs-extra">
62-
<img src={photo_src} alt={contractor.name}/>
58+
<Photo contractor={contractor} config={this.props.config}/>
6359

6460
<Stars contractor={contractor} root={this.props.root}/>
6561

src/components/contractors/Contractors.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ class Contractors extends Component {
169169
</If>
170170
<DisplayComponent
171171
contractors={this.state.contractor_response ? this.state.contractor_response.results : []}
172+
config={this.props.config}
172173
root={this.props.root}/>
173174
<If v={error_message}>
174175
<div className="tcs-no-contractors">

src/components/contractors/List.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Component } from 'react'
22
import {Link} from 'react-router-dom'
3-
import {Location, Markdown, If} from '../shared/Tools'
3+
import {Location, Markdown, If, Photo} from '../shared/Tools'
44
import Stars from './Stars'
55

66
class AnimateLink extends Component {
@@ -23,25 +23,25 @@ class AnimateLink extends Component {
2323
}
2424
}
2525

26-
export const Grid = ({contractors, root}) => (
26+
export const Grid = ({contractors, root, config}) => (
2727
<div className="tcs-flex">
2828
{contractors.map((contractor, i) => (
2929
<AnimateLink key={i} delay={i * 50} to={root.url(contractor.link)} className="tcs-col">
3030
<div className="tcs-item tcs-box">
31-
<img src={contractor.photo} alt={contractor.name} className="tcs-thumb"/>
31+
<Photo contractor={contractor} config={config} className="tcs-thumb"/>
3232
<h3 className="tcs-name">{contractor.name}</h3>
3333
</div>
3434
</AnimateLink>
3535
))}
3636
</div>
3737
)
3838

39-
export const List = ({contractors, root}) => (
39+
export const List = ({contractors, root, config}) => (
4040
<div className="tcs-list">
4141
{contractors.map((contractor, i) => (
4242
<AnimateLink key={i} delay={i * 80} to={root.url(contractor.link)} className="tcs-item">
4343
<div className="tcs-image-col">
44-
<img src={contractor.photo} alt={contractor.name} className="tcs-thumb"/>
44+
<Photo contractor={contractor} config={config} className="tcs-thumb"/>
4545
<button className="tcs-button">
4646
{root.get_text('view_profile')}
4747
</button>

src/components/shared/Tools.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,11 @@ export const IfElse = ({v, children}) => {
6060
export const Markdown = ({content}) => (
6161
<div className="tcs-md" dangerouslySetInnerHTML={{__html: to_markdown(content)}}/>
6262
)
63+
64+
export const Photo = ({contractor, config, className}) => {
65+
let photo_src = contractor.photo
66+
if (photo_src.startsWith('/')) {
67+
photo_src = config.api_root + photo_src
68+
}
69+
return <img src={photo_src} alt={contractor.name} className={className}/>
70+
}

0 commit comments

Comments
 (0)