refactor update field user_prefix
This commit is contained in:
@@ -18,10 +18,11 @@ const SignUp = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSignUp = async (values) => {
|
const handleSignUp = async (values) => {
|
||||||
const { fullname, name, email, phone, password, confirmPassword } = values;
|
const { user_fullname, user_name, user_email, user_phone, user_password, confirmPassword } =
|
||||||
|
values;
|
||||||
|
|
||||||
// Validasi confirm password
|
// Validasi confirm password
|
||||||
if (password !== confirmPassword) {
|
if (user_password !== confirmPassword) {
|
||||||
NotifAlert({
|
NotifAlert({
|
||||||
icon: 'error',
|
icon: 'error',
|
||||||
title: 'Password Tidak Sama',
|
title: 'Password Tidak Sama',
|
||||||
@@ -33,22 +34,22 @@ const SignUp = () => {
|
|||||||
|
|
||||||
// Validasi nomor telepon Indonesia
|
// Validasi nomor telepon Indonesia
|
||||||
const phoneRegex = /^(?:\+62|62|0)8[1-9][0-9]{6,11}$/;
|
const phoneRegex = /^(?:\+62|62|0)8[1-9][0-9]{6,11}$/;
|
||||||
if (!phoneRegex.test(phone)) {
|
if (!phoneRegex.test(user_phone)) {
|
||||||
NotifAlert({
|
NotifAlert({
|
||||||
icon: 'error',
|
icon: 'error',
|
||||||
title: 'Format Telepon Salah',
|
title: 'Format Telepon Salah',
|
||||||
message: 'Nomor telepon tidak valid (harus nomor Indonesia)',
|
message: 'Nomor telepon tidak valid (harus nomor Indonesia)',
|
||||||
});
|
});
|
||||||
form.resetFields(['phone']);
|
form.resetFields(['user_phone']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validasi password kompleks
|
// Validasi password kompleks
|
||||||
const passwordErrors = [];
|
const passwordErrors = [];
|
||||||
if (password.length < 8) passwordErrors.push('Minimal 8 karakter');
|
if (user_password.length < 8) passwordErrors.push('Minimal 8 karakter');
|
||||||
if (!/[A-Z]/.test(password)) passwordErrors.push('Harus ada huruf kapital');
|
if (!/[A-Z]/.test(user_password)) passwordErrors.push('Harus ada huruf kapital');
|
||||||
if (!/[0-9]/.test(password)) passwordErrors.push('Harus ada angka');
|
if (!/[0-9]/.test(user_password)) passwordErrors.push('Harus ada angka');
|
||||||
if (!/[!@#$%^&*(),.?":{}|<>]/.test(password))
|
if (!/[!@#$%^&*(),.?":{}|<>]/.test(user_password))
|
||||||
passwordErrors.push('Harus ada karakter spesial');
|
passwordErrors.push('Harus ada karakter spesial');
|
||||||
if (passwordErrors.length) {
|
if (passwordErrors.length) {
|
||||||
NotifAlert({
|
NotifAlert({
|
||||||
@@ -56,13 +57,19 @@ const SignUp = () => {
|
|||||||
title: 'Password Tidak Valid',
|
title: 'Password Tidak Valid',
|
||||||
message: passwordErrors.join(', '),
|
message: passwordErrors.join(', '),
|
||||||
});
|
});
|
||||||
form.resetFields(['password', 'confirmPassword']);
|
form.resetFields(['user_password', 'confirmPassword']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const res = await register({ fullname, name, email, phone, password });
|
const res = await register({
|
||||||
|
user_fullname,
|
||||||
|
user_name,
|
||||||
|
user_email,
|
||||||
|
user_phone,
|
||||||
|
user_password,
|
||||||
|
});
|
||||||
|
|
||||||
NotifOk({
|
NotifOk({
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
@@ -121,14 +128,14 @@ const SignUp = () => {
|
|||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label="Full Name"
|
label="Full Name"
|
||||||
name="fullname"
|
name="user_fullname"
|
||||||
rules={[{ required: true }]}
|
rules={[{ required: true }]}
|
||||||
>
|
>
|
||||||
<Input placeholder="Full Name" size="large" />
|
<Input placeholder="Full Name" size="large" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
<Form.Item label="Name" name="name" rules={[{ required: true }]}>
|
<Form.Item label="Name" name="user_name" rules={[{ required: true }]}>
|
||||||
<Input placeholder="Name" size="large" />
|
<Input placeholder="Name" size="large" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Col>
|
</Col>
|
||||||
@@ -138,7 +145,7 @@ const SignUp = () => {
|
|||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label="Email"
|
label="Email"
|
||||||
name="email"
|
name="user_email"
|
||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
@@ -151,13 +158,13 @@ const SignUp = () => {
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
<Form.Item label="Phone" name="phone" rules={[{ required: true }]}>
|
<Form.Item label="Phone" name="user-phone" rules={[{ required: true }]}>
|
||||||
<Input placeholder="Phone" size="large" />
|
<Input placeholder="Phone" size="large" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
<Form.Item label="Password" name="password" rules={[{ required: true }]}>
|
<Form.Item label="Password" name="user_password" rules={[{ required: true }]}>
|
||||||
<Input.Password placeholder="Password" size="large" />
|
<Input.Password placeholder="Password" size="large" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user