import React, { useState } from 'react'; import { State, useStoreState } from 'easy-peasy'; import { ApplicationState } from '@/state/types'; import { Form, Formik, FormikActions } from 'formik'; import Field from '@/components/elements/Field'; import * as Yup from 'yup'; import SpinnerOverlay from '@/components/elements/SpinnerOverlay'; interface Values { current: string; password: string; confirmPassword: string; } const schema = Yup.object().shape({ current: Yup.string().min(1).required('You must provide your current password.'), password: Yup.string().min(8).required(), confirmPassword: Yup.string().test('password', 'Password confirmation does not match the password you entered.', function (value) { return value === this.parent.password; }), }); export default () => { const user = useStoreState((state: State) => state.user.data); if (!user) { return null; } const submit = (values: Values, { setSubmitting }: FormikActions) => { setTimeout(() => setSubmitting(false), 1500); }; return ( { ({ isSubmitting, isValid }) => (
) }
); };