Reflects the changes to the url paramater for admin, is now names requestParam. Also the param is passed to Sidebar so that we can highlight the one selected.

This commit is contained in:
2017-10-21 09:44:12 +02:00
parent ebfb61d776
commit 87a2de1d0b

View File

@@ -29,7 +29,7 @@ class AdminComponent extends React.Component {
fetchJSON('https://apollo.kevinmidboe.com/api/v1/plex/requests/all', 'GET')
.then(result => {
this.setState({
requested_objects: result.requestedItems
requested_objects: result.requestedItems.reverse()
})
})
}
@@ -49,18 +49,25 @@ class AdminComponent extends React.Component {
return <LoginForm />
}
let display = undefined
if (this.props.match.params.search && this.state.requested_objects !== '') {
display = this.state.requested_objects[this.props.match.params.search]
let selectedRequest = undefined;
let listItemSelected = undefined;
const requestParam = this.props.match.params.request;
if (requestParam && this.state.requested_objects !== '') {
selectedRequest = this.state.requested_objects[requestParam]
listItemSelected = requestParam
}
return (
<div>
<div style={adminComponentStyle.sidebar}>
<Sidebar requested_objects={this.state.requested_objects} style={adminComponentStyle.sidebar}/>
<Sidebar
requested_objects={this.state.requested_objects}
listItemSelected={listItemSelected}
style={adminComponentStyle.sidebar} />
</div>
<div style={adminComponentStyle.selectedObjectPanel}>
<AdminRequestInfo display={display} />
<AdminRequestInfo selectedRequest={selectedRequest} />
</div>
</div>
)