-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapplication.jsx
72 lines (60 loc) · 2.53 KB
/
application.jsx
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
/*global React, ReactDOM, InputCountrySelect, ReactBootstrap*/
const DemoApplication = React.createClass({
getInitialState: function () {
return {
firstCountrySelected: false,
secondCountrySelected: false,
secondDefaultCountryCode: 'BLR'
};
},
onFirstCountryChanged: function (selectedCountry) {
this.setState({firstCountrySelected: selectedCountry});
console.log('You have selected first country ', selectedCountry);
},
onSecondCountryChanged: function (selectedCountry) {
this.setState({secondCountrySelected: selectedCountry});
console.log('You have selected second country ', selectedCountry);
},
maybeShowAlertForFirstCountry: function () {
if (this.state.firstCountrySelected && this.state.firstCountrySelected.translatedName) {
return (
<Well bsStyle="info">
Hey, you have just selected <strong>{this.state.firstCountrySelected.translatedName}</strong>
</Well>
);
}
},
maybeShowAlertForSecondCountry: function () {
if (this.state.secondCountrySelected && this.state.secondCountrySelected.translatedName) {
return (
<Well bsStyle="info">
Hey, you have just selected <strong>{this.state.secondCountrySelected.translatedName}</strong>
</Well>
);
}
},
render: function () {
var divStyle = {
width: '400'
};
return (
<div style={divStyle}>
<Panel header="Here is a country selector with custom data provider:">
{this.maybeShowAlertForFirstCountry()}
<InputCountrySelect language="de"
countries={this.props.customCountriesData}
onCountryChanged={this.onFirstCountryChanged}
/>
</Panel>
<Panel header="Here is a country selector filled with data loaded from https://restcountries.eu :">
{this.maybeShowAlertForSecondCountry()}
<InputCountrySelect language="en"
firstEmptyRow={false}
defaultCountryCode={this.state.secondDefaultCountryCode}
onCountryChanged={this.onSecondCountryChanged}
/>
</Panel>
</div>
)
}
});