Fakultas Ilmu Komputer UI

Commit 36fb9814 authored by Doan Andreas Nathanael's avatar Doan Andreas Nathanael
Browse files

[GREEN] added registration UI

parent 9c8f476f
Pipeline #72014 passed with stages
in 15 minutes and 15 seconds
......@@ -6,7 +6,7 @@ import React, { FC } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { Icon, ListItem } from 'react-native-elements';
import { ScrollView } from 'react-native-gesture-handler';
import { DietelaProgram } from 'services/cart/models';
import { DietelaProgram } from 'services/dietelaQuiz/quizResult';
import { colors, layoutStyles } from 'styles';
interface IdProgram {
......
import React, { FC } from 'react';
import { Text } from 'react-native-elements';
import { useForm } from 'hooks';
import { fieldValidation, initialValues, textField } from './schema';
import { generateValidationSchema } from 'utils/form';
import { TextField } from 'components/form';
import { ScrollView } from 'react-native-gesture-handler';
import { layoutStyles } from 'styles';
import { BigButton } from 'components/core';
const ManualRegistrationPage: FC = () => <Text>Hai</Text>;
const isPasswordField = (name: string) =>
name === 'password1' || name === 'password2';
const ManualRegistrationPage: FC = () => {
const { getTextInputProps, handleSubmit, isSubmitting } = useForm({
initialValues,
validationSchema: generateValidationSchema(fieldValidation),
onSubmit: async (values) => {
console.log(values);
},
});
return (
<ScrollView contentContainerStyle={layoutStyles}>
{textField.map((fieldProps, i) => {
return (
<TextField
key={`field${i}`}
label={fieldProps.label}
required={fieldProps.required}
placeholder={fieldProps.placeholder}
{...getTextInputProps(fieldProps.name)}
secureTextEntry={isPasswordField(fieldProps.name)}
/>
);
})}
<BigButton
title="daftarkan akun"
onPress={handleSubmit}
loading={isSubmitting}
testID="submitButton"
/>
</ScrollView>
);
};
export default ManualRegistrationPage;
import { TextFieldSchema } from 'types/form';
import { FieldType, FieldValidation } from 'utils/form';
export const textField: TextFieldSchema[] = [
{
label: 'Nama',
placeholder: 'Masukkan nama Anda',
required: true,
name: 'name',
},
{
label: 'Email address',
placeholder: 'Masukkan email Anda',
required: true,
name: 'email',
},
{
label: 'Password',
placeholder: 'Masukkan password Anda',
required: true,
name: 'password1',
},
{
label: 'Konfirmasi password',
placeholder: 'Konfirmasi password Anda',
required: true,
name: 'password2',
},
];
export const initialValues = {
name: '',
email: '',
password1: '',
password2: '',
};
export const fieldValidation: FieldValidation[] = [
{
name: 'name',
required: true,
label: 'Nama',
type: FieldType.TEXT,
},
{
name: 'email',
required: true,
label: 'Email address',
type: FieldType.EMAIL,
},
{
name: 'password1',
required: true,
label: 'Password',
type: FieldType.PASSWORD,
},
{
name: 'password2',
required: true,
label: 'Konfirmasi password',
type: FieldType.CONFIRM_PASSWORD,
matches: 'password1',
},
];
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment