-
-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from oslabs-beta/collections
Collections
- Loading branch information
Showing
15 changed files
with
227 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React, { Component } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import * as actions from '../../actions/actions'; | ||
import collectionsController from '../../controllers/collectionsController' | ||
import Collection from '../display/Collection.jsx' | ||
|
||
const mapStateToProps = store => ({ | ||
collections: store.business.collections, | ||
}); | ||
|
||
const mapDispatchToProps = dispatch => ({ | ||
deleteFromCollection: (collection) => { dispatch(actions.deleteFromCollection(collection)) }, | ||
collectionToReqRes: (reqResArray) => { dispatch(actions.collectionToReqRes(reqResArray)) }, | ||
}); | ||
|
||
class CollectionsContainer extends Component { | ||
constructor(props) { | ||
super(props); | ||
} | ||
|
||
render() { | ||
|
||
let collectionComponents = this.props.collections.map((collection, idx) => { | ||
return <Collection | ||
content={collection} key={idx} | ||
deleteFromCollection = {this.props.deleteFromCollection} | ||
collectionToReqRes = {this.props.collectionToReqRes} | ||
/> | ||
}) | ||
|
||
return ( | ||
<div className={'collections-container'}> | ||
<h1>Collections</h1> | ||
{collectionComponents} | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
export default connect( | ||
mapStateToProps, | ||
mapDispatchToProps, | ||
)(CollectionsContainer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React, { Component } from 'react'; | ||
import collectionsController from '../../controllers/collectionsController'; | ||
import Trashcan from '../../../assets/img/Trashcan.png' | ||
|
||
class Collection extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = {}; | ||
this.deleteCollection = this.deleteCollection.bind(this); | ||
this.addCollectionToReqResContainer = this.addCollectionToReqResContainer.bind(this); | ||
} | ||
|
||
addCollectionToReqResContainer() { | ||
this.props.collectionToReqRes(this.props.content.reqResArray) | ||
} | ||
|
||
deleteCollection(e) { | ||
this.props.deleteFromCollection(this.props.content); //a function we need to make in the container | ||
collectionsController.deleteCollectionFromIndexedDb(e.target.id); | ||
} | ||
|
||
render() { | ||
return ( | ||
<> | ||
<div className={'collection-container collection-text-container'} onClick={this.addCollectionToReqResContainer}> | ||
<div className={'collection-name'}> {this.props.content.name} | ||
</div> | ||
</div> | ||
<div className='collection-delete-container'> | ||
<div className='collection-delete-fade'> | ||
</div> | ||
<div className={'collection-delete-button'} onClick={this.deleteCollection}> | ||
<img className='collection-delete-image' src={Trashcan} id={this.props.content.id} ></img> | ||
</div> | ||
</div> | ||
</> | ||
) | ||
} | ||
} | ||
|
||
export default Collection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.