@@ -8,6 +8,8 @@ import { makeStyles } from "@material-ui/core/styles";
88import { switchViewToPlace } from "src/state/thunks/handleSearchQuery" ;
99import { Link , useHistory } from "react-router-dom" ;
1010import { WelcomeModalStep } from "./welcomeStepsConfig" ;
11+ import { useSelector } from "react-redux" ;
12+ import { State } from "src/state" ;
1113
1214function isValidPostalCode ( text : string ) {
1315 return / ^ [ 0 - 9 ] { 5 } $ / . test ( text ) ;
@@ -33,10 +35,10 @@ export const WelcomeModalPostalCode: React.FC = () => {
3335 const classes = { ...useCommonWelcomeModalStyles ( ) , ...useStyles ( ) } ;
3436 const dispatch = useThunkDispatch ( ) ;
3537 const history = useHistory ( ) ;
36- const [ postCode , setPostCode ] = useState ( "" ) ;
38+ const postCode = useSelector ( ( state : State ) => state . app . intro . postCode ) ;
39+ const checked = useSelector ( ( state : State ) => state . app . intro . isPrivacyChecked ) ;
3740 const [ validatePostalCode , setValidatePostalCode ] = useState ( false ) ;
3841 const [ validateCheckbox , setValidateCheckbox ] = useState ( false ) ;
39- const [ checked , setChecked ] = useState ( false ) ;
4042
4143 function onSkip ( ) {
4244 setValidateCheckbox ( true ) ;
@@ -64,7 +66,7 @@ export const WelcomeModalPostalCode: React.FC = () => {
6466 }
6567
6668 function handleCheckedChange ( event : React . ChangeEvent < HTMLInputElement > ) {
67- setChecked ( event . target . checked ) ;
69+ dispatch ( AppApi . setIntroValues ( { isPrivacyChecked : event . target . checked } ) ) ;
6870 }
6971
7072 const isCheckboxError = validateCheckbox && ! checked ;
@@ -83,15 +85,16 @@ export const WelcomeModalPostalCode: React.FC = () => {
8385 helperText = { isPostCodeError ? "Bitte valide PLZ eingeben" : null }
8486 variant = "outlined"
8587 type = "number"
88+ value = { postCode }
8689 onChange = { ( event ) => {
87- setPostCode ( event . target . value ) ;
90+ dispatch ( AppApi . setIntroValues ( { postCode : event . target . value } ) ) ;
8891 } }
8992 onKeyPress = { onKeyPress }
9093 style = { { margin : "50px 0 30px 0" , width : "180px" , height : "80px" } }
9194 />
9295
9396 < div style = { { display : "flex" , flexDirection : "row" , alignItems : "center" , marginBottom : "10px" } } >
94- < Checkbox value = { checked } onChange = { handleCheckedChange } />
97+ < Checkbox value = { checked } checked = { checked } onChange = { handleCheckedChange } />
9598 < Typography className = { classes . smallText } style = { isCheckboxError ? { color : "red" } : { } } >
9699 Ja, ich habe die < Link to = { WelcomeModalStep . StepPostalCodeDataPrivacy } > Datenschutzerklärung</ Link > zur
97100 Kenntnis genommen und willige ein.
0 commit comments