Merge branch 'master' into mx
This commit is contained in:
commit
65a03c55e2
5 changed files with 50 additions and 29 deletions
|
@ -42,7 +42,7 @@ const styles = theme => ({
|
||||||
class EnhancedSearch extends Component {
|
class EnhancedSearch extends Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {query, onUpdateQuery, onColumnChange} = this.props;
|
const {query, onUpdateQuery, onColumnChange, textComponent} = this.props;
|
||||||
const { classes } = this.props;
|
const { classes } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -62,6 +62,7 @@ class EnhancedSearch extends Component {
|
||||||
startAdornment: <InputAdornment position="start"><Search /></InputAdornment>,
|
startAdornment: <InputAdornment position="start"><Search /></InputAdornment>,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
{textComponent}
|
||||||
<br />
|
<br />
|
||||||
{this.props.showSearchColumns && this.props.columns.map(column => (
|
{this.props.showSearchColumns && this.props.columns.map(column => (
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
|
|
|
@ -57,6 +57,7 @@ const defaultProps = {
|
||||||
onEdit: () => {},
|
onEdit: () => {},
|
||||||
onDelete: () => {},
|
onDelete: () => {},
|
||||||
onMultipleDelete: () => {},
|
onMultipleDelete: () => {},
|
||||||
|
description: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,6 +88,8 @@ class EnhancedTable extends Component {
|
||||||
const orderBy = property;
|
const orderBy = property;
|
||||||
let order = 'desc';
|
let order = 'desc';
|
||||||
|
|
||||||
|
if(orderBy === 'map') return;
|
||||||
|
|
||||||
if (this.state.orderBy === property && this.state.order === 'desc') {
|
if (this.state.orderBy === property && this.state.order === 'desc') {
|
||||||
order = 'asc';
|
order = 'asc';
|
||||||
}
|
}
|
||||||
|
@ -94,15 +97,15 @@ class EnhancedTable extends Component {
|
||||||
const data =
|
const data =
|
||||||
order === 'desc'
|
order === 'desc'
|
||||||
? this.state.data.sort((a, b) => {
|
? this.state.data.sort((a, b) => {
|
||||||
let a_value = a[orderBy];
|
let a_value = (a[orderBy] !== undefined) ? a[orderBy]: '';
|
||||||
let b_value = b[orderBy];
|
let b_value = (b[orderBy] !== undefined) ? b[orderBy]: '';
|
||||||
a_value = a_value.hasOwnProperty('searchText') ? a_value.searchText.toLowerCase() : a_value.toLowerCase();
|
a_value = a_value.hasOwnProperty('searchText') ? a_value.searchText.toLowerCase() : a_value.toLowerCase();
|
||||||
b_value = b_value.hasOwnProperty('searchText') ? b_value.searchText.toLowerCase() : b_value.toLowerCase();
|
b_value = b_value.hasOwnProperty('searchText') ? b_value.searchText.toLowerCase() : b_value.toLowerCase();
|
||||||
return (b_value < a_value) ? -1 : 1;
|
return (b_value < a_value) ? -1 : 1;
|
||||||
})
|
})
|
||||||
: this.state.data.sort((a, b) => {
|
: this.state.data.sort((a, b) => {
|
||||||
let a_value = a[orderBy];
|
let a_value = (a[orderBy] !== undefined) ? a[orderBy]: '';
|
||||||
let b_value = b[orderBy];
|
let b_value = (b[orderBy] !== undefined) ? b[orderBy]: '';
|
||||||
a_value = a_value.hasOwnProperty('searchText') ? a_value.searchText.toLowerCase() : a_value.toLowerCase();
|
a_value = a_value.hasOwnProperty('searchText') ? a_value.searchText.toLowerCase() : a_value.toLowerCase();
|
||||||
b_value = b_value.hasOwnProperty('searchText') ? b_value.searchText.toLowerCase() : b_value.toLowerCase();
|
b_value = b_value.hasOwnProperty('searchText') ? b_value.searchText.toLowerCase() : b_value.toLowerCase();
|
||||||
if(a_value.trim() === '') a_value = 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';
|
if(a_value.trim() === '') a_value = 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';
|
||||||
|
@ -250,6 +253,7 @@ class EnhancedTable extends Component {
|
||||||
return (
|
return (
|
||||||
<div style={styles.root}>
|
<div style={styles.root}>
|
||||||
<EnhancedSearch
|
<EnhancedSearch
|
||||||
|
textComponent={this.props.description}
|
||||||
query={searchQuery}
|
query={searchQuery}
|
||||||
columns={searchColumns}
|
columns={searchColumns}
|
||||||
showSearchColumns={showSearchColumns}
|
showSearchColumns={showSearchColumns}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { FormattedMessage, FormattedHTMLMessage } from 'react-intl';
|
||||||
import Modal from 'react-modal';
|
import Modal from 'react-modal';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import Button from '@material-ui/core/Button';
|
import Button from '@material-ui/core/Button';
|
||||||
|
import sortBy from 'sort-by';
|
||||||
|
|
||||||
// Custom components
|
// Custom components
|
||||||
import AppHeader from '../AppHeader';
|
import AppHeader from '../AppHeader';
|
||||||
|
@ -143,7 +144,8 @@ class AmbassadorsPage extends Component {
|
||||||
searchText: ambassador.telegram,
|
searchText: ambassador.telegram,
|
||||||
value: (
|
value: (
|
||||||
<a
|
<a
|
||||||
href={`https://t.me/${(ambassador.telegram.trim().charAt(0) === '@') ? ambassador.telegram.trim().slice(1): ambassador.telegram.trim()}`}
|
href={`https://t.me/${(ambassador.telegram.trim().charAt(0) === '@') ?
|
||||||
|
ambassador.telegram.trim().slice(1): ambassador.telegram.trim()}`}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>{ambassador.telegram}</a>
|
>{ambassador.telegram}</a>
|
||||||
|
@ -244,7 +246,7 @@ class AmbassadorsPage extends Component {
|
||||||
addLocationSearchText(cities){
|
addLocationSearchText(cities){
|
||||||
let searchText = '';
|
let searchText = '';
|
||||||
cities.forEach((location) => {
|
cities.forEach((location) => {
|
||||||
searchText += `${(location.name).replace(/(^|\s)\S/g, l => l.toUpperCase())} - ${countries.getName(location.country)} `;
|
searchText += `${countries.getName(location.country)} - ${(location.name).replace(/(^|\s)\S/g, l => l.toUpperCase())}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
return searchText;
|
return searchText;
|
||||||
|
@ -315,7 +317,7 @@ class AmbassadorsPage extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { data } = this.state.ambassadors;
|
let { data } = this.state.ambassadors;
|
||||||
const { ambassadorsSearch, merchantMarkers } = this.state;
|
const { ambassadorsSearch, merchantMarkers } = this.state;
|
||||||
|
|
||||||
const ambassadorsMarkers = [];
|
const ambassadorsMarkers = [];
|
||||||
|
@ -346,6 +348,18 @@ class AmbassadorsPage extends Component {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
data = data.sort(sortBy('location.searchText'));
|
||||||
|
|
||||||
|
const textComponent = (
|
||||||
|
<span>
|
||||||
|
<FormattedHTMLMessage id="ambassadors.description1" />
|
||||||
|
<Link to="/merchants">
|
||||||
|
<FormattedMessage id="ambassadors.merchants_link_description" />
|
||||||
|
</Link>
|
||||||
|
<FormattedHTMLMessage id="ambassadors.description2" />
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<AppHeader />
|
<AppHeader />
|
||||||
|
@ -356,21 +370,12 @@ class AmbassadorsPage extends Component {
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-md-10 mx-md-auto">
|
<div className="col-md-10 mx-md-auto">
|
||||||
|
|
||||||
|
|
||||||
<h2 className="ambassadorsTitle" style={centerStyle}><FormattedMessage id="ambassadors.title" /></h2>
|
<h2 className="ambassadorsTitle" style={centerStyle}><FormattedMessage id="ambassadors.title" /></h2>
|
||||||
{ /* Conditional Rendering */}
|
{ /* Conditional Rendering */}
|
||||||
{(this.state.loading) ? (
|
{(this.state.loading) ? (
|
||||||
<img src={LoadingGif} alt="Loading" style={loadingStyle} />
|
<img src={LoadingGif} alt="Loading" style={loadingStyle} />
|
||||||
): (
|
): (
|
||||||
<div>
|
<div>
|
||||||
<p style={{ textAlign: 'left', marginRight: 20 }}>
|
|
||||||
<FormattedHTMLMessage id="ambassadors.description1" />
|
|
||||||
<Link to="/merchants">
|
|
||||||
<FormattedMessage id="ambassadors.merchants_link_description" />
|
|
||||||
</Link>
|
|
||||||
<FormattedHTMLMessage id="ambassadors.description2" />
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
isOpen={this.state.mapsModalIsOpen}
|
isOpen={this.state.mapsModalIsOpen}
|
||||||
onRequestClose={() => this.closeMapsModal()}
|
onRequestClose={() => this.closeMapsModal()}
|
||||||
|
@ -392,9 +397,10 @@ class AmbassadorsPage extends Component {
|
||||||
<div>
|
<div>
|
||||||
<br />
|
<br />
|
||||||
<EnhancedTable
|
<EnhancedTable
|
||||||
|
description={textComponent}
|
||||||
columnData={columnData}
|
columnData={columnData}
|
||||||
data={data}
|
data={data}
|
||||||
orderBy="nickname"
|
orderBy="Location"
|
||||||
showSearchColumns={false}
|
showSearchColumns={false}
|
||||||
rowsPerPage={10}
|
rowsPerPage={10}
|
||||||
isAdmin={false}
|
isAdmin={false}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { FormattedMessage, FormattedHTMLMessage } from 'react-intl';
|
||||||
import Modal from 'react-modal';
|
import Modal from 'react-modal';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import Button from '@material-ui/core/Button';
|
import Button from '@material-ui/core/Button';
|
||||||
|
import sortBy from 'sort-by';
|
||||||
|
|
||||||
// Custom components
|
// Custom components
|
||||||
import AppHeader from '../AppHeader';
|
import AppHeader from '../AppHeader';
|
||||||
|
@ -53,9 +54,9 @@ const mapsStyles = {
|
||||||
|
|
||||||
const columnData = [
|
const columnData = [
|
||||||
{ id: 'name', numeric: false, disablePadding: true, label: 'Name' },
|
{ id: 'name', numeric: false, disablePadding: true, label: 'Name' },
|
||||||
|
{ id: 'phone', numeric: false, disablePadding: true, label: 'Contact' },
|
||||||
{ id: 'address', numeric: false, disablePadding: true, label: 'Address' },
|
{ id: 'address', numeric: false, disablePadding: true, label: 'Address' },
|
||||||
{ id: 'city', numeric: false, disablePadding: false, label: 'City' },
|
{ id: 'location', numeric: false, disablePadding: false, label: 'Location' },
|
||||||
{ id: 'country', numeric: false, disablePadding: false, label: 'Country' },
|
|
||||||
{ id: 'map', numeric: false, disablePadding: false, label: 'Maps', disableSearch: true}
|
{ id: 'map', numeric: false, disablePadding: false, label: 'Maps', disableSearch: true}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -203,6 +204,10 @@ class MerchantsPage extends Component {
|
||||||
<div><b>Address</b>: {merchant.address}</div>
|
<div><b>Address</b>: {merchant.address}</div>
|
||||||
{(merchant.phone) && (<div><b>Phone</b>: {merchant.phone}</div>)}
|
{(merchant.phone) && (<div><b>Phone</b>: {merchant.phone}</div>)}
|
||||||
</div>;
|
</div>;
|
||||||
|
merchant.location = {
|
||||||
|
searchText: `${merchant.country} - ${merchant.city}`,
|
||||||
|
value: (merchant.city) ? `${merchant.city} - ${merchant.country}`: merchant.country
|
||||||
|
}
|
||||||
merchant.map = <Button
|
merchant.map = <Button
|
||||||
className="App-button"
|
className="App-button"
|
||||||
variant="contained"
|
variant="contained"
|
||||||
|
@ -255,7 +260,7 @@ class MerchantsPage extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { data: merchantsData } = this.state.merchants;
|
let { data: merchantsData } = this.state.merchants;
|
||||||
const { ambassadorsMarkers, merchantsSearch } = this.state;
|
const { ambassadorsMarkers, merchantsSearch } = this.state;
|
||||||
|
|
||||||
const merchantMarkers = merchantsSearch.map(merchant => {
|
const merchantMarkers = merchantsSearch.map(merchant => {
|
||||||
|
@ -273,6 +278,17 @@ class MerchantsPage extends Component {
|
||||||
return marker;
|
return marker;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
merchantsData = merchantsData.sort(sortBy('location.searchText'));
|
||||||
|
|
||||||
|
const textComponent = (
|
||||||
|
<span>
|
||||||
|
<FormattedHTMLMessage id="merchants.description1" />
|
||||||
|
<Link to="/ambs">
|
||||||
|
<FormattedMessage id="merchants.ambassadors_link_description" />
|
||||||
|
</Link>
|
||||||
|
<FormattedHTMLMessage id="merchants.description2" />
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
@ -289,13 +305,6 @@ class MerchantsPage extends Component {
|
||||||
<img src={LoadingGif} alt="Loading" style={loadingStyle} />
|
<img src={LoadingGif} alt="Loading" style={loadingStyle} />
|
||||||
): (
|
): (
|
||||||
<div>
|
<div>
|
||||||
<p style={{ textAlign: 'left', marginRight: 20 }}>
|
|
||||||
<FormattedHTMLMessage id="merchants.description1" />
|
|
||||||
<Link to="/ambs">
|
|
||||||
<FormattedMessage id="merchants.ambassadors_link_description" />
|
|
||||||
</Link>
|
|
||||||
<FormattedHTMLMessage id="merchants.description2" />
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
isOpen={this.state.mapsModalIsOpen}
|
isOpen={this.state.mapsModalIsOpen}
|
||||||
|
@ -319,6 +328,7 @@ class MerchantsPage extends Component {
|
||||||
<div>
|
<div>
|
||||||
<br />
|
<br />
|
||||||
<EnhancedTable
|
<EnhancedTable
|
||||||
|
description={textComponent}
|
||||||
columnData={columnData}
|
columnData={columnData}
|
||||||
data={merchantsData}
|
data={merchantsData}
|
||||||
orderBy="account"
|
orderBy="account"
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
const GOOGLE_MAPS_API = 'AIzaSyD5BzjBYtpnQcztK18LEIvDZr9Y0L99k0s';
|
const GOOGLE_MAPS_API = 'AIzaSyAwVFmgFPt_0fji8qFH5ecGG1A_ZviHe7M';
|
||||||
|
|
||||||
export default GOOGLE_MAPS_API;
|
export default GOOGLE_MAPS_API;
|
||||||
|
|
Loading…
Reference in a new issue