Fakultas Ilmu Komputer UI

Commit 2b7b7df2 authored by Zafir Rasyidi Taufik's avatar Zafir Rasyidi Taufik
Browse files

[GREEN] Add district subdistrict division

parent 662d4e56
Pipeline #76096 passed with stage
in 19 minutes and 44 seconds
......@@ -6,7 +6,7 @@ import {ActivityIndicator, ScrollView, View, Modal, Image} from 'react-native';
import {Header, Field, Button, Text} from '../../components';
import error_img from './img/folder.png';
import {useFormState} from 'helpers';
import {KELURAHAN_VALUES} from './constants';
import {KECAMATAN_VALUES, KELURAHAN_VALUES} from './constants';
import {useNavigation} from '@react-navigation/native';
import {AppContext} from 'contexts';
import translateError from './utilities'
......@@ -23,7 +23,8 @@ const OfficerSignupForm = () => {
password: {type: 'password'},
email: {type: 'email'},
phone_number: {type: 'phone'},
area: {type: 'any'},
district: {type: 'any'},
sub_district: {type: 'any'},
});
const [serverHasError, setServerHasError] = useState(false);
......@@ -33,7 +34,8 @@ const OfficerSignupForm = () => {
password: '',
email: '',
phoneNumber: '',
area: '',
district: '',
sub_district: '',
})
const [modalVisible, setModalVisible] = useState(false);
......@@ -155,15 +157,29 @@ const OfficerSignupForm = () => {
<InputField>
<Field
id="area"
id="district"
type={3}
name="Lokasi Cabang"
placeholder="Pilih Lokasi Cabang"
name="Kecamatan"
placeholder="Pilih Kecamatan"
isRequired={true}
information={messageErrors.area}
value={form.fields.area.value || KELURAHAN_VALUES[0].value}
updateValue={val => setField('area', val)}
values={KELURAHAN_VALUES}
information={messageErrors.district}
value={form.fields.district.value || KECAMATAN_VALUES[0].value}
updateValue={val => setField('district', val)}
values={KECAMATAN_VALUES}
/>
</InputField>
<InputField>
<Field
id="sub_district"
type={3}
name="Kelurahan"
placeholder="Pilih Kelurahan"
isRequired={true}
information={messageErrors.sub_district}
value={form.fields.sub_district.value || KELURAHAN_VALUES[KECAMATAN_VALUES[0].value][0].value}
updateValue={val => setField('sub_district', val)}
values={(form.fields.district.value) ? KELURAHAN_VALUES[form.fields.district.value] : KELURAHAN_VALUES[KECAMATAN_VALUES[0].value]}
/>
</InputField>
<Button
......@@ -178,7 +194,8 @@ const OfficerSignupForm = () => {
password: form.fields.password.value,
email: form.fields.email.value,
phone_number: form.fields.phone_number.value,
area: form.fields.area.value
district: form.fields.district.value,
sub_district: form.fields.sub_district.value
})
if (response.status === 201) {
......@@ -194,7 +211,8 @@ const OfficerSignupForm = () => {
password: response.data.password || [],
email: response.data.email || [],
phoneNumber: response.data.phone_number || [],
area: response.data.area || [],
district: response.data.district || [],
sub_district: response.data.sub_district || [],
}
setMessageErrors({
......@@ -203,7 +221,8 @@ const OfficerSignupForm = () => {
password: translateError(errors.password[0] || ""),
email: translateError(errors.email[0] || ""),
phoneNumber: translateError(errors.phoneNumber[0] || ""),
area: translateError(errors.area[0] || ""),
district: translateError(errors.district[0] || ""),
sub_district: translateError(errors.sub_district[0] || ""),
})
} else if (response.status === 500) {
if (response.data.includes("IntegrityError")) {
......
......@@ -77,7 +77,8 @@ export default function useMainService(token: string) {
password: string;
email: string;
phone_number: string;
area: string;
district: string;
sub_district: string;
}
async function createUser(body: UserFormType) {
......
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