Skip to content

Commit

Permalink
wip #39
Browse files Browse the repository at this point in the history
  • Loading branch information
Jovert Lota Palonpon committed Apr 7, 2019
1 parent 2c38626 commit c451610
Show file tree
Hide file tree
Showing 7 changed files with 372 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function sendResetLinkEmail(Request $request) : JsonResponse
$request->input('routeSuffix'),
':',
true
).$token;
).$token.'?email='.$user->email;

$resetLink = route('backoffice.welcome').'#'.$routeSuffix;

Expand Down
173 changes: 80 additions & 93 deletions resources/js/views/auth/passwords/Request.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { Formik, Form, withFormik } from 'formik';
import * as Yup from 'yup';
import { Grid, TextField, Button, Link, withStyles } from '@material-ui/core';

import { Auth as AuthLayout } from '../../layouts';
import * as NavigationUtils from '../../../utils/Navigation';
import * as UrlUtils from '../../../utils/URL';
import { Auth as AuthLayout } from '../../layouts';

class PasswordRequest extends Component {
state = {
Expand Down Expand Up @@ -37,22 +37,20 @@ class PasswordRequest extends Component {
routeSuffix,
});

if (response.status === 200) {
this.setState({
loading: false,
message: {
type: 'success',
title: 'Link Sent',
body: (
<h4>
Check your email to reset your account.
<br /> Thank you.
</h4>
),
action: () => history.push(`/signin?username=${email}`),
},
});
}
this.setState({
loading: false,
message: {
type: 'success',
title: 'Link Sent',
body: (
<h4>
Check your email to reset your account.
<br /> Thank you.
</h4>
),
action: () => history.push(`/signin?username=${email}`),
},
});
} catch (error) {
if (!error.response) {
this.setState({
Expand Down Expand Up @@ -95,8 +93,7 @@ class PasswordRequest extends Component {
}

render() {
const { classes, location, setErrors, errors: formErrors } = this.props;

const { classes, location } = this.props;
const { loading, message, email } = this.state;

return (
Expand All @@ -114,88 +111,78 @@ class PasswordRequest extends Component {
: email,
}}
onSubmit={this.handleRequestPasswordSubmit}
validate={values => {
setErrors({});
}}
validationSchema={Yup.object().shape({
email: Yup.string().required(
`The email field is required`,
Lang.get('validation.required', {
attribute: 'email',
}),
),
})}
>
{({ values, handleChange, errors, isSubmitting }) => {
if (formErrors && Object.keys(formErrors).length > 0) {
errors = formErrors;
}

return (
<Form>
<Grid container direction="column">
<Grid item className={classes.formGroup}>
<TextField
id="email"
type="email"
label="Email"
value={values.email}
onChange={handleChange}
variant="outlined"
fullWidth
error={errors.hasOwnProperty(
'email',
)}
helperText={
errors.hasOwnProperty(
'email',
) && errors.email
}
/>
</Grid>

<Grid item className={classes.formGroup}>
<Link
component={props => (
<RouterLink
{...props}
to={{
search: UrlUtils._queryString(
{
username: email,
},
),
pathname: NavigationUtils._route(
'auth.signin',
),
}}
/>
)}
>
{Lang.get('navigation.signin')}
</Link>
</Grid>
{({ values, handleChange, errors, isSubmitting }) => (
<Form>
<Grid container direction="column">
<Grid item className={classes.formGroup}>
<TextField
id="email"
type="email"
label="Email"
value={values.email}
onChange={handleChange}
variant="outlined"
fullWidth
error={errors.hasOwnProperty('email')}
helperText={
errors.hasOwnProperty('email') &&
errors.email
}
/>
</Grid>

<Grid container justify="space-between">
<Grid item />

<Grid item className={classes.formGroup}>
<Button
type="submit"
variant="contained"
color="primary"
disabled={
(errors &&
Object.keys(errors).length >
0) ||
isSubmitting
}
>
{Lang.get('navigation.send_link')}
</Button>
</Grid>
<Grid item className={classes.formGroup}>
<Link
component={props => (
<RouterLink
{...props}
to={{
search: UrlUtils._queryString(
{
username: email,
},
),
pathname: NavigationUtils._route(
'auth.signin',
),
}}
/>
)}
>
{Lang.get('navigation.signin')}
</Link>
</Grid>
</Form>
);
}}
</Grid>

<Grid container justify="space-between">
<Grid item />

<Grid item className={classes.formGroup}>
<Button
type="submit"
variant="contained"
color="primary"
disabled={
(errors &&
Object.keys(errors).length >
0) ||
isSubmitting
}
>
{Lang.get('navigation.send_link')}
</Button>
</Grid>
</Grid>
</Form>
)}
</Formik>
</AuthLayout>
);
Expand Down
Loading

0 comments on commit c451610

Please sign in to comment.