// @flow import React from 'react'; import { Form, FormField } from 'component/common/form'; import Button from 'component/button'; import Card from 'component/common/card'; import { setSavedPassword } from 'util/saved-passwords'; import usePersistedState from 'effects/use-persisted-state'; import I18nMessage from 'component/i18nMessage'; import { useHistory } from 'react-router'; import { SITE_HELP_EMAIL } from 'config'; type Props = { getSync: ((any, boolean) => void, ?string) => void, getSyncIsPending: boolean, email: string, passwordError: boolean, signOut: () => void, handleSyncComplete: (any, boolean) => void, }; function SyncPassword(props: Props) { const { getSync, getSyncIsPending, email, signOut, passwordError, handleSyncComplete } = props; const { push, location: { search }, } = useHistory(); const urlParams = new URLSearchParams(search); const redirect = urlParams.get('redirect'); const [password, setPassword] = React.useState(''); const [rememberPassword, setRememberPassword] = usePersistedState(true); function handleSubmit() { getSync((error, hasDataChanged) => { handleSyncComplete(error, hasDataChanged); if (!error) { push(redirect || '/'); setSavedPassword(password, rememberPassword); } }, password); } return (
); } export default SyncPassword;