File tree Expand file tree Collapse file tree 4 files changed +59
-6
lines changed
Expand file tree Collapse file tree 4 files changed +59
-6
lines changed Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import PropTypes from 'prop-types' ;
3+ import { List as SuiList , TransitionGroup } from 'semantic-ui-react' ;
4+
5+ export default class List extends React . Component {
6+ render ( ) {
7+ const { children, elements} = this . props ;
8+ return (
9+ < TransitionGroup
10+ as = { SuiList }
11+ duration = { 200 }
12+ animation = "fade left"
13+ >
14+ { elements . map ( element => (
15+ < SuiList . Item key = { element . _id } >
16+ { children ( element ) }
17+ </ SuiList . Item >
18+ ) ) }
19+ </ TransitionGroup >
20+ ) ;
21+ }
22+ }
23+
24+ List . propTypes = {
25+ children : PropTypes . func . isRequired ,
26+ elements : PropTypes . array . isRequired ,
27+ } ;
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import PropTypes from 'prop-types' ;
33import { Button , Card } from 'semantic-ui-react' ;
4+ import { removeVin } from '/imports/api/vinNumbers/methods' ;
45
56export default class VinNumberCard extends React . Component {
6- // @todo #16:30min Implement remove VIN method
7+ onRemove ( ) {
8+ const { vin : { _id} } = this . props ;
9+ removeVin . callPromise ( { _id} )
10+ . catch ( ( err ) => {
11+ alert ( 'An error occured. Please check the console' ) ;
12+ console . error ( err ) ;
13+ } ) ;
14+ }
15+
716 // @todo #16:30min Implement approve VIN method
817 render ( ) {
918 const { vin} = this . props ;
@@ -16,7 +25,7 @@ export default class VinNumberCard extends React.Component {
1625 < Card . Content extra >
1726 < Button . Group fluid >
1827 < Button basic positive > Approve</ Button >
19- < Button basic negative > Remove</ Button >
28+ < Button basic negative onClick = { ( ) => this . onRemove ( ) } > Remove</ Button >
2029 </ Button . Group >
2130 </ Card . Content >
2231 </ Card >
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import PropTypes from 'prop-types' ;
3+ import VinNumberCard from './VinNumberCard' ;
4+ import List from '/client/components/List' ;
5+
6+ export default class VinNumbers extends React . Component {
7+ render ( ) {
8+ const { vinNumbers} = this . props ;
9+ return (
10+ < List elements = { vinNumbers } >
11+ { vin => < VinNumberCard vin = { vin } /> }
12+ </ List >
13+ ) ;
14+ }
15+ }
16+
17+ VinNumbers . propTypes = {
18+ vinNumbers : PropTypes . array . isRequired ,
19+ } ;
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
44import Loader from '/client/components/Loader' ;
55import { VinNumbers } from '/imports/api/vinNumbers/collection' ;
66import AddVinForm from './AddVinForm' ;
7- import VinNumberCard from './VinNumberCard ' ;
7+ import VinNumbersList from './VinNumbersList ' ;
88
99class VinNumbersPage extends React . Component {
1010 renderVinNumbersList ( ) {
@@ -13,9 +13,7 @@ class VinNumbersPage extends React.Component {
1313 return < Loader /> ;
1414 }
1515
16- return vinNumbers . map ( vin => (
17- < VinNumberCard key = { vin . _id } vin = { vin } />
18- ) ) ;
16+ return < VinNumbersList vinNumbers = { vinNumbers } /> ;
1917 }
2018
2119 render ( ) {
You can’t perform that action at this time.
0 commit comments