-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
43 lines (38 loc) · 1.09 KB
/
index.js
File metadata and controls
43 lines (38 loc) · 1.09 KB
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
import React, { useState } from 'react'
import moment from 'moment'
import { connect } from 'react-redux'
import { mapHubs } from '../../../../redux/hubs/selectors'
const HubSelector = ({ hubs }) => {
console.log(hubs)
const [selectedHub, changeHub] = useState(hubs?.[0]?.id)
return (
<div>
{hubs?.map((hub) => (
<div
className={
selectedHub === hub.id ? 'HubListElem visible' : 'HubListElem'
}
>
<div className="HubName" onClick={() => changeHub(hub.id)}>
{hub.name}
</div>
<div className="LocalTime">
{moment(moment(), 'h:mm a').utcOffset(hub.timezone)}
</div>
<div className="HubDetails">
<p className="HubDetails--country">{hub.country}</p>
<p className="HubDetails--address">
{hub.address}
<br />
{hub.contact}
</p>
</div>
</div>
))}
</div>
)
}
const mapStateToProps = (state) => ({
hubs: mapHubs(state),
})
export default connect(mapStateToProps)(HubSelector)