2018-07-06 11:45:36 +00:00
|
|
|
import React from 'react';
|
|
|
|
import RelatedInterviewsList from '../interviews/relatedInterviewsList'
|
|
|
|
import InterviewsList from '../interviews/interviewsList';
|
|
|
|
import SingleInterview from '../interviews/singleInterview';
|
|
|
|
import TopicsList from '../topicsList';
|
|
|
|
import ProjectsList from '../projectsList';
|
|
|
|
import SearchResults from '../searchResults';
|
|
|
|
import Data from '../../data/archives/interviews';
|
|
|
|
import './style.scss';
|
|
|
|
|
|
|
|
class Search extends React.Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
term: '',
|
|
|
|
isSingleInterviewModalOpen: false,
|
|
|
|
isInterviewsListModalOpen: false,
|
2018-07-06 12:03:08 +00:00
|
|
|
activeSingleInterviewId: 1,
|
2018-07-06 11:45:36 +00:00
|
|
|
isSearchActive: false,
|
|
|
|
};
|
|
|
|
this.onInputChange = this.onInputChange.bind(this);
|
|
|
|
this.toggleSingleInterview = this.toggleSingleInterview.bind(this);
|
|
|
|
this.toggleInterviewsListModal = this.toggleInterviewsListModal.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
onInputChange(event) {
|
|
|
|
this.setState({
|
|
|
|
term: event.target.value,
|
|
|
|
isSearchActive: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
if (event.target.value.length === 0) {
|
|
|
|
this.setState({isSearchActive: false});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
toggleInterviewsListModal() {
|
|
|
|
const { isInterviewsListModalOpen } = this.state;
|
|
|
|
this.setState({
|
|
|
|
isInterviewsListModalOpen: !isInterviewsListModalOpen,
|
|
|
|
isSingleInterviewModalOpen: false,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
toggleSingleInterview(event) {
|
2018-07-06 12:03:08 +00:00
|
|
|
const { isSingleInterviewModalOpen, isInterviewsListModalOpen } = this.state;
|
2018-07-06 11:45:36 +00:00
|
|
|
this.setState({
|
2018-07-06 12:03:08 +00:00
|
|
|
isInterviewsListModalOpen: !isInterviewsListModalOpen,
|
2018-07-06 11:45:36 +00:00
|
|
|
isSingleInterviewModalOpen: !isSingleInterviewModalOpen,
|
2018-07-06 12:03:08 +00:00
|
|
|
activeSingleInterviewId: Number(event.target.id),
|
2018-07-06 11:45:36 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
getSelectedInterview() {
|
2018-07-06 12:03:08 +00:00
|
|
|
const { activeSingleInterviewId } = this.state;
|
|
|
|
const selectedInterview = Data.find( item => item.id === activeSingleInterviewId);
|
2018-07-06 11:45:36 +00:00
|
|
|
return selectedInterview;
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2018-07-06 12:03:08 +00:00
|
|
|
const { isSingleInterviewModalOpen, isInterviewsListModalOpen, isSearchActive, activeSingleInterviewId } = this.state;
|
2018-07-06 11:45:36 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="browse-wrap">
|
|
|
|
<div className="search-bar">
|
|
|
|
<div className="container">
|
|
|
|
<h3>Browse Archives</h3>
|
|
|
|
<input
|
|
|
|
className="search-input"
|
|
|
|
type="search"
|
|
|
|
placeholder="Search archives"
|
|
|
|
value={this.state.term}
|
|
|
|
onChange={this.onInputChange}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="browse-content-wrap container">
|
|
|
|
<div className="browse-content-left">
|
|
|
|
{isSearchActive && <RelatedInterviewsList data={Data} toggleSingleInterview={this.toggleSingleInterview} />}
|
|
|
|
</div>
|
|
|
|
<div className="browse-content-right">
|
|
|
|
{isSearchActive ? <SearchResults /> :
|
|
|
|
(
|
|
|
|
<React.Fragment>
|
|
|
|
<InterviewsList
|
|
|
|
data={Data}
|
|
|
|
isInterviewsListModalOpen={isInterviewsListModalOpen}
|
|
|
|
toggleSingleInterview={this.toggleSingleInterview}
|
|
|
|
toggleInterviewsListModal={this.toggleInterviewsListModal}
|
|
|
|
/>
|
|
|
|
<TopicsList />
|
|
|
|
<ProjectsList />
|
|
|
|
</React.Fragment>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
{isSingleInterviewModalOpen &&
|
|
|
|
(<SingleInterview
|
2018-07-06 12:03:08 +00:00
|
|
|
activeSingleInterviewId={activeSingleInterviewId}
|
2018-07-06 11:45:36 +00:00
|
|
|
selectedInterview={this.getSelectedInterview()}
|
|
|
|
toggleSingleInterview={this.toggleSingleInterview}
|
|
|
|
/>)
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Search;
|