Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Cek 123

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

import React, { useState } from 'react';

import { NavLink, useHistory } from 'react-router-dom';


import {Form, Input, Button, message} from 'antd';
import { useDispatch, useSelector } from 'react-redux';
import { AuthWrapper } from './style';
import { login } from '../../../../redux/authentication/actionCreator';
import { Checkbox } from '../../../../components/checkbox/checkbox';
import Heading from '../../../../components/heading/heading';
import DataService from "../../../../services/service";

const SignIn = () => {


const history = useHistory();
const dispatch = useDispatch();
const isLoading = useSelector(state => state.auth.loading);
const [form] = Form.useForm();
const [state, setState] = useState({
checked: null,
values: null,
});

const [post, setPost] = useState({


email : "",
password: ""
});
const success = () => {
message.success('Pendaftaran Berhasil');
};
const error = () => {
message.error('This is an error message');
};
const signIn= () => {
DataService.signIn({
email : post.email,
password: post.password
})

.then(response => {
// success()
// history.push("/");
success()
console.log(response);
history.push("/");

// console.log(post.password);
})
.catch(e => {
error()
console.log(e);
});
}

const handleInputChange = e => {


const newdata={...post}
newdata[e.target.id] = e.target.value
setPost(newdata)
};

const handleSubmit = () => {


// dispatch(login());
// history.push('/admin');
setState({ ...state, values });

};

const onChange = checked => {


setState({ ...state, checked });
};

return (
<AuthWrapper>
<p className="auth-notice">
Don&rsquo;t have an account? <NavLink to="/register">Sign up now</NavLink>
</p>
<div className="auth-contents">
<Form name="login" form={form} layout="vertical">
<Heading as="h3">
Sign in to <span className="color-secondary">Portal BEKEN</span>
</Heading>
<Form.Item
name="username"
rules={[{ message: 'Please input your username or Email!', required:
true }]}
// initialValue="name@beken.com"
label="Username or Email Address"
>
<Input
value={post.email}
id="email"
name="email"
onChange={(e)=>handleInputChange(e)}
placeholder="name@beken.com"
/>
</Form.Item>
<Form.Item name="password" label="Password">
<Input.Password
placeholder="******"
value={post.email}
id="password"
name="password"
onChange={(e)=>handleInputChange(e)}
/>
</Form.Item>
<div className="auth-form-action">
<Checkbox onChange={onChange}>Keep me logged in</Checkbox>
<NavLink className="forgot-pass-link" to="/forgotPassword">
Forgot password?
</NavLink>
</div>
<Form.Item>
<Button onClick={signIn} className="btn-signin" htmlType="submit"
type="primary" size="large">
{isLoading ? 'Loading...' : 'Sign In'}
</Button>
</Form.Item>
{/* <p className="form-divider">
<span>Or</span>
</p>
<ul className="social-login">
<li>
<Link className="google-signup" to="#">
<img src={require('../../../../static/img/google.png')} alt="" />
<span>Sign in with Google</span>
</Link>
</li>
<li>
<Link className="facebook-sign" to="#">
<FacebookOutlined />
</Link>
</li>
<li>
<Link className="twitter-sign" to="#">
<TwitterOutlined />
</Link>
</li>
</ul> */}
</Form>
</div>
</AuthWrapper>
);
};

export default SignIn;

You might also like