summaryrefslogtreecommitdiff
path: root/src/SearchResults.js
blob: d3563fa329d19ce97a8d61d1178607b2ccccab44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import React, { Component } from 'react';
import './SearchResults.css';
import striptags from 'striptags';

class SearchResult extends Component {

  badge(f) {
    if (this.props.data.udf[f]) {
      return (
        <span className="badge">
          {this.props.data.udf[f].label}{' '}
        </span>
      );
    } else {
      return null;
    }
  }

  image() {
    const src = this.props.data['image-url'];
    if (src) {
      return (<img src={src} alt="" />);
    } else {
      return null;
    }
  }

  render() {

    return (
      <div className="Result">
        <h3>{this.props.data.name}</h3>

        <div className="image">
          {this.image()}
        </div>

        <div className="details">
          {this.badge('udf_3')}
          {this.badge('udf_2')}
          {this.badge('udf_1')}
          {this.props.data.childcare ? (<span className="badge">Childcare</span>) : null}

          <p>{striptags(this.props.data.description)}</p>

          <p>
            <span className="label">Day</span>: {this.props.data.meetingDay.label}{" "}
            <span className="label">Time</span>: {this.props.data.meetingTime.label}{" "}
            <span className="label">Location</span>: {this.props.data['location-city']}
          </p>
          <p>
            <span className="label">Group Leader</span>: {this.props.data['leader-name']}{" "}
          </p>
          <p>
            <a className="btn" target="_new" href="https://motionchurch.ccbchurch.com/goto/forms/133/responses/new">Contact Group</a>
          </p>
        </div>
      </div>
    );
  }

}

class SearchResults extends Component {

  render() {
    let results = this.props.results.map((result) => {
      return (
        <SearchResult key={result.id} data={result}></SearchResult>
      );
    });

    return (
      <div className="SearchResults">
        <p className="result-count">Found {results.length} groups</p>
        {results}
      </div>
    );
  }

}

export default SearchResults;