fix(my-joyent): fix package selection

This commit is contained in:
Sara Vieira 2017-09-18 16:30:31 +01:00 committed by Sérgio Ramos
parent 3a425ee7e4
commit beb8141869
2 changed files with 24 additions and 6 deletions

View File

@ -27,9 +27,9 @@ class Packages extends Component {
this.handleClick = this.handleClick.bind(this); this.handleClick = this.handleClick.bind(this);
} }
handleClick(i) { handleClick(id) {
this.setState({ this.setState({
selected: i selected: id
}); });
} }
render() { render() {
@ -39,12 +39,12 @@ class Packages extends Component {
return ( return (
<ListStyled> <ListStyled>
{packages.length > 0 ? ( {packages.length > 0 ? (
packages.map((pack, i) => ( packages.map(pack => (
<Col xs={12} sm={6} md={4} lg={3} key={i}> <Col xs={12} sm={6} md={4} lg={3} key={pack.id}>
<Package <Package
pack={pack} pack={pack}
onClick={() => this.handleClick(i)} onClick={() => this.handleClick(pack.id)}
selected={selected === i} selected={selected === pack.id}
/> />
</Col> </Col>
)) ))

View File

@ -1,5 +1,6 @@
[ [
{ {
"id": 1,
"name": "High CPU 0.25", "name": "High CPU 0.25",
"vcpus": 0.25, "vcpus": 0.25,
"memory": 0.256, "memory": 0.256,
@ -8,6 +9,7 @@
"price": "0.016" "price": "0.016"
}, },
{ {
"id": 2,
"name": "High CPU 0.75", "name": "High CPU 0.75",
"vcpus": 0.5, "vcpus": 0.5,
"memory": 0.768, "memory": 0.768,
@ -16,6 +18,7 @@
"price": "0.033" "price": "0.033"
}, },
{ {
"id": 3,
"name": "High CPU 1.75", "name": "High CPU 1.75",
"vcpus": 1, "vcpus": 1,
"memory": 1.8, "memory": 1.8,
@ -24,6 +27,7 @@
"price": "0.066" "price": "0.066"
}, },
{ {
"id": 4,
"name": "High CPU 3.75", "name": "High CPU 3.75",
"vcpus": 2, "vcpus": 2,
"memory": 3.8, "memory": 3.8,
@ -32,6 +36,7 @@
"price": "0.131" "price": "0.131"
}, },
{ {
"id": 5,
"name": "High CPU 7.75", "name": "High CPU 7.75",
"vcpus": 4, "vcpus": 4,
"memory": 7.8, "memory": 7.8,
@ -40,6 +45,7 @@
"price": "0.263" "price": "0.263"
}, },
{ {
"id": 6,
"name": "High CPU 15.75", "name": "High CPU 15.75",
"vcpus": 8, "vcpus": 8,
"memory": 15.8, "memory": 15.8,
@ -48,6 +54,7 @@
"price": "0.525" "price": "0.525"
}, },
{ {
"id": 7,
"name": "General 3.75", "name": "General 3.75",
"vcpus": 1, "vcpus": 1,
"memory": 3.8, "memory": 3.8,
@ -56,6 +63,7 @@
"price": "0.084" "price": "0.084"
}, },
{ {
"id": 8,
"name": "General 7.75", "name": "General 7.75",
"vcpus": 2, "vcpus": 2,
"memory": 7.8, "memory": 7.8,
@ -64,6 +72,7 @@
"price": "0.166" "price": "0.166"
}, },
{ {
"id": 9,
"name": "General 15.75", "name": "General 15.75",
"vcpus": 4, "vcpus": 4,
"memory": 15.8, "memory": 15.8,
@ -72,6 +81,7 @@
"price": "0.333" "price": "0.333"
}, },
{ {
"id": 10,
"name": "General 31.75", "name": "General 31.75",
"vcpus": 8, "vcpus": 8,
"memory": 31.8, "memory": 31.8,
@ -80,6 +90,7 @@
"price": "0.665" "price": "0.665"
}, },
{ {
"id": 11,
"name": "High RAM 15.75", "name": "High RAM 15.75",
"vcpus": 2, "vcpus": 2,
"memory": 15.8, "memory": 15.8,
@ -88,6 +99,7 @@
"price": "0.259" "price": "0.259"
}, },
{ {
"id": 12,
"name": "High RAM 31.75", "name": "High RAM 31.75",
"vcpus": 4, "vcpus": 4,
"memory": 31.8, "memory": 31.8,
@ -96,6 +108,7 @@
"price": "0.52" "price": "0.52"
}, },
{ {
"id": 13,
"name": "High RAM 63.75", "name": "High RAM 63.75",
"vcpus": 8, "vcpus": 8,
"memory": 63.8, "memory": 63.8,
@ -104,6 +117,7 @@
"price": "1.039" "price": "1.039"
}, },
{ {
"id": 14,
"name": "Fast Disk 31.75", "name": "Fast Disk 31.75",
"vcpus": 4, "vcpus": 4,
"memory": 31.8, "memory": 31.8,
@ -112,6 +126,7 @@
"price": "1.066" "price": "1.066"
}, },
{ {
"id": 15,
"name": "Fast Disk 63.75", "name": "Fast Disk 63.75",
"vcpus": 8, "vcpus": 8,
"memory": 63.8, "memory": 63.8,
@ -120,6 +135,7 @@
"price": "2.31" "price": "2.31"
}, },
{ {
"id": 16,
"name": "Big Disk 15.75", "name": "Big Disk 15.75",
"vcpus": 2, "vcpus": 2,
"memory": 15.8, "memory": 15.8,
@ -128,6 +144,7 @@
"price": "0.413" "price": "0.413"
}, },
{ {
"id": 17,
"name": "Big Disk 31.75", "name": "Big Disk 31.75",
"vcpus": 4, "vcpus": 4,
"memory": 31.8, "memory": 31.8,
@ -136,6 +153,7 @@
"price": "0.825" "price": "0.825"
}, },
{ {
"id": 18,
"name": "Big Disk 63.75", "name": "Big Disk 63.75",
"vcpus": 8, "vcpus": 8,
"memory": 63.8, "memory": 63.8,