Fakultas Ilmu Komputer UI

Commit fff55625 authored by Irwanto's avatar Irwanto
Browse files

Pbi 2 login: fix signup error

parent 85a8b133
......@@ -5,9 +5,11 @@ import styled from 'styled-components/native';
import {Button, Text, Field} from 'components';
import {useFormState} from 'helpers';
import {LocalStorage} from 'services';
import { useNavigation } from '@react-navigation/native';
const LoginPage = () => {
const navigation = useNavigation();
const [isLoading, setIsLoading] = useState(false)
const [isFirstTime, setIsFirstTime] = useState(true)
const { vh, setToken, services } = useContext(AppContext);
......
......@@ -190,7 +190,8 @@ const OfficerSignupForm = () => {
})
if (response.status === 201) {
navigation.navigate("officer-signup-finish")
setIsLoading(false);
navigation.navigate("officer-signup-finish");
} else if (response.status === 500) {
if (response.data.includes("IntegrityError")) {
setServerHasError(false);
......@@ -200,8 +201,8 @@ const OfficerSignupForm = () => {
setModalVisible(true);
}
}
setIsLoading(false)
setIsChecked(true)
setIsLoading(false);
setIsChecked(true);
}}>
Ajukan Akun
</Button>
......
......@@ -4,13 +4,13 @@ import { API_MAIN_URL } from 'react-native-dotenv';
const END_POINTS = {
SIGNUP: '/signup',
ME: '/accounts/me',
ME: '/accounts/me/',
ACCOUNT: '/accounts/',
CREATE_CASE_SUBJECT: "cases/case-subjects",
CREATE_INVESTIGATION_CASE: "/cases/investigation-cases",
GET_LOG: "/logs",
LIST_POSITIVE_CASE: "/cases/positive-cases",
LOGIN: '/auth/token/',
ACCOUNT: createEndpoint(["accounts"]),
};
enum Method {
......@@ -87,10 +87,7 @@ export default function useMainService(token: string) {
}
async function me() {
const endpoint = END_POINTS.ACCOUNT([
"me"
])
return fetchWithAuthentication(endpoint, Method.GET)
return fetchWithAuthentication(END_POINTS.ME, Method.GET);
}
interface UserFormType {
......@@ -103,11 +100,7 @@ export default function useMainService(token: string) {
}
async function createUser(body: UserFormType) {
const endpoint = END_POINTS.ACCOUNT([
null,
])
return fetchWithoutAuthentication(endpoint, Method.POST, body);
return fetchWithoutAuthentication(END_POINTS.ACCOUNT, Method.POST, body);
}
async function createCaseSubject(body: object) {
......
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