Created
January 30, 2018 00:37
-
-
Save franciscotln/7fbf2a6f22dce5795f0fef28516d26b9 to your computer and use it in GitHub Desktop.
no outside data
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
import * as React from 'react'; | |
import * as R from 'ramda'; | |
import { connect, Dispatch } from 'react-redux'; | |
import { bindActionCreators } from 'redux'; | |
import { Title } from '../../shared/components/title'; | |
import { StuffTypeItems } from '../../shared/components/subscription-calculator'; | |
import { Button } from '../../shared/components/button'; | |
import { ItemComponent } from './stuff-type/item'; | |
import { setStuffType, SubscriptionCalculatorActions } from '../store/subscription-calculator.actions'; | |
interface Props { | |
handleChange: (payload: string) => SubscriptionCalculatorActions; | |
} | |
interface stuffTypeItem { | |
key: number; | |
title: string; | |
content: string; | |
value: string; | |
} | |
interface StateProps { | |
stuffType: string; | |
stuffTypeItems: stuffTypeItem[] | |
} | |
const stuffTypeItems: stuffTypeItem[] = [ | |
{ | |
key: 0, | |
title: 'Complete inboedel', | |
content: 'Bijvoorbeeld: Wanneer het huis leeg moet vanwege een verhuizing.', | |
value: '1', | |
}, | |
{ | |
key: 1, | |
title: 'Deel inboedel', | |
content: 'Bijvoorbeeld: Bij de renovatie van een specifieke ruimte.', | |
value: '2', | |
}, | |
{ | |
key: 2, | |
title: 'Complete inboedel', | |
content: `Bijvoorbeeld: Speelgoed waar de kinderen te oud voor zijn. Of seizoensgebonden spullen; kleding, | |
tuinattributen, motorfiets.`, | |
value: '3', | |
}, | |
]; | |
function StuffType(props: Props & StateProps) { | |
return ( | |
<div> | |
<Title size="h3" weight="light" color="blue">1. Wat wil je opslaan</Title> | |
<StuffTypeItems> | |
{props.stuffTypeItems.map((item: stuffTypeItem) => | |
<ItemComponent isChecked={props.stuffType === item.value} {...props} {...item} /> | |
)} | |
</StuffTypeItems> | |
<Button disabled={props.stuffType === ''}>Stap 2.</Button> | |
</div> | |
); | |
} | |
const mapStateToProps = (state: any) => ({ | |
stuffTypeItems, | |
stuffType: R.pathOr<string>('', [ 'subscriptionCalculator', 'stuffType' ], state), | |
}); | |
const mapDispatchToProps = (dispatch: Dispatch<any>) => bindActionCreators({ | |
handleChange: setStuffType | |
}, dispatch); | |
export const StuffTypeComponent = connect<StateProps, Props, any>(mapStateToProps, mapDispatchToProps)(StuffType); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment