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