Stockage des objectifs selectionnes

pull/206/head
Mael 2018-03-22 17:41:45 +01:00 committed by Laurent Bossavit
parent cc68fc126a
commit 80abadba8e
6 changed files with 22 additions and 38 deletions

View File

@ -9,7 +9,8 @@ import { Line } from 'rc-progress'
@connect(state => ({
foldedSteps: state.foldedSteps,
nextSteps: state.nextSteps,
colour: state.themeColours.colour
colour: state.themeColours.colour,
conversationTargetNames: state.conversationTargetNames
}))
@translate()
export default class ProgressTip extends Component {
@ -19,16 +20,15 @@ export default class ProgressTip extends Component {
nextSteps,
foldedSteps,
colour,
conversationVisible,
selectingTargets
conversationTargetNames
} = this.props,
nbQuestions = nextSteps.length
if (selectingTargets && !conversationVisible)
if (conversationTargetNames && conversationTargetNames.length === 0)
return nbQuestions ? (
<p>Vous aurez {nextSteps.length} questions !</p>
) : null
if (!conversationVisible) return null
if (!conversationTargetNames) return null
return (
nbQuestions != 0 && (
<div className="progressTip">

View File

@ -9,34 +9,17 @@ import Explanation from './Explanation'
@withColours
export default class extends Component {
state = {
conversationVisible: false,
selectingTargets: false
}
render() {
let { colours } = this.props,
{ selectingTargets, conversationVisible } = this.state
let { colours } = this.props
return (
<div>
<FoldedSteps />
<div id="focusZone">
<GoToAnswers />
<TargetSelection
colours={colours}
conversationVisible={this.state.conversationVisible}
showConversation={() =>
this.setState({ conversationVisible: true })
}
selectingTargets={selectingTargets}
setSelectingTargets={() =>
this.setState({ selectingTargets: true })
}
/>
<ProgressTip {...{ selectingTargets, conversationVisible }} />
{this.state.conversationVisible && (
<Conversation textColourOnWhite={colours.textColourOnWhite} />
)}
<TargetSelection colours={colours} />
<ProgressTip />
<Conversation textColourOnWhite={colours.textColourOnWhite} />
<Explanation />
</div>
</div>

View File

@ -38,8 +38,8 @@ export default class TargetSelection extends Component {
}
render() {
this.firstEstimationComplete =
this.state.activeInput && this.props.targets.length > 0
let { targets, conversationTargetNames } = this.props
this.firstEstimationComplete = this.state.activeInput && targets.length > 0
return (
<div id="targetSelection">
{!this.firstEstimationComplete && <h1>Entrez un salaire mensuel</h1>}
@ -55,8 +55,8 @@ export default class TargetSelection extends Component {
{this.firstEstimationComplete && (
<div id="action">
{this.props.selectingTargets ? (
!this.props.conversationVisible && (
{conversationTargetNames ? (
!conversationTargetNames.length && (
<p>Que voulez-vous affiner ?</p>
)
) : (
@ -64,7 +64,7 @@ export default class TargetSelection extends Component {
<p>Estimation par défaut pour un CDI non cadre ... </p>
<BlueButton
onClick={() => {
this.props.setSelectingTargets()
this.props.setConversationTargets([])
}}
>
Personnaliser
@ -86,7 +86,7 @@ export default class TargetSelection extends Component {
} = this.props,
optionIsChecked = s => (conversationTargetNames || []).includes(s.name),
visibleCheckbox = s =>
this.props.selectingTargets && s.dottedName !== this.state.activeInput,
conversationTargetNames && s.dottedName !== this.state.activeInput,
toggleTarget = target =>
ifElse(contains(target), without(target), append(target))
@ -101,11 +101,10 @@ export default class TargetSelection extends Component {
id={s.name}
type="checkbox"
checked={optionIsChecked(s)}
onClick={() => this.props.showConversation()}
onChange={() =>
setConversationTargets(
toggleTarget(s.name)(
conversationTargetNames.filter(
(conversationTargetNames || []).filter(
t => !this.state.activeInput.includes(t)
)
)

View File

@ -23,7 +23,8 @@ import './conversation.css'
done: state.done,
nextSteps: state.nextSteps,
analysis: state.analysis,
parsedRules: state.parsedRules
parsedRules: state.parsedRules,
conversationTargetNames: state.conversationTargetNames
}),
dispatch => ({
reinitialise: () => {
@ -41,8 +42,10 @@ export default class Conversation extends Component {
parsedRules,
targetNames,
reinitialise,
textColourOnWhite
textColourOnWhite,
conversationTargetNames
} = this.props
if ((conversationTargetNames || []).length === 0) return null
return (
<>
<div id="currentQuestion">

View File

@ -7,7 +7,6 @@ export default ({ store }) => (
<Provider store={store}>
<div id="dev">
<Layout />
<DevTools />
</div>
</Provider>
)

View File

@ -180,7 +180,7 @@ export default initialRules =>
analysis: (state = null) => state,
targetNames: (state = popularTargetNames) => state,
conversationTargetNames: (state = []) => state,
conversationTargetNames: (state = null) => state,
situationGate: (state = name => null) => state,