Fakultas Ilmu Komputer UI

Commit 7bd58b65 authored by Nandhika Prayoga's avatar Nandhika Prayoga Committed by Josh Sudung
Browse files

Coldfix sprint 2

parent 205de235
import React, {useState, useEffect, useRef} from 'react';
import React, {useState, useEffect, useReducer, useRef} from 'react';
import styled, {ThemeProvider} from 'styled-components/native';
import {NavigationContainer} from '@react-navigation/native';
import {createStackNavigator} from '@react-navigation/stack';
......@@ -101,10 +101,9 @@ function cacheReducer(oldCache: CacheType, action: CacheAction): CacheType {
}
const App = () => {
const [cache, setCache] = useState<CacheType>(initialCacheState);
const [cache, cacheDispatch] = useReducer(cacheReducer, initialCacheState);
const [token, setToken] = useState();
const [user, setUser] = useState();
const [isFirstTimeHandleToken, setIsFirstTimeHandleToken] = useState(true);
const navigatorRef = useRef()
const mainService = useMainService(token);
......
......@@ -63,6 +63,12 @@ function Field({
const { colors } = useContext(ThemeContext) || {};
const [innerValue, setInnerValue] = useState(value);
useEffect(() => {
if (values && values.length > 0 && type === Type.Dropdown) {
setInnerValue(values[0].value)
}
}, [])
useEffect(() => {
updateValue(innerValue);
}, [innerValue]);
......
......@@ -45,7 +45,7 @@ const Header = ({
<HomeButton>
<Button
type={Button.Type.Outline}
onPress={() => navigation.navigate("home")}
onPress={() => global.isAuthenticated? navigation.navigate("home"): navigation.navigate("login")}
>
Beranda
</Button>
......
......@@ -27,7 +27,12 @@ const ContactInvestigationFormFinishPage = () => {
</Text>
</ContainerContent>
<ContainerButton>
<Button type={1} onPress={() => navigation.navigate('home')}>
<Button type={1} onPress={() => {
navigation.reset({
index: 0,
routes: [{name: 'home'}],
});
}}>
Kembali ke Beranda
</Button>
</ContainerButton>
......
......@@ -36,7 +36,12 @@ const OfficerSignupFormFinishPage = () => {
</FieldControl>
</ContainerContent>
<ContainerButton>
<Button type={1} onPress={() => navigation.navigate('login')}>
<Button type={1} onPress={() => {
navigation.reset({
index: 0,
routes: [{name: 'login'}],
})
}}>
Kembali ke Halaman Login
</Button>
</ContainerButton>
......
......@@ -191,7 +191,10 @@ const OfficerSignupForm = () => {
if (response.status === 201) {
setIsLoading(false);
navigation.navigate("officer-signup-finish");
navigation.reset({
index: 0,
routes: [{name: "officer-signup-finish"}],
});
} else if (response.status === 500) {
if (response.data.includes("IntegrityError")) {
setServerHasError(false);
......
......@@ -6,7 +6,7 @@ const END_POINTS = {
SIGNUP: '/signup',
ME: '/accounts/me/',
ACCOUNT: '/accounts/',
CREATE_CASE_SUBJECT: "cases/case-subjects",
CREATE_CASE_SUBJECT: "/cases/case-subjects",
CREATE_INVESTIGATION_CASE: "/cases/investigation-cases",
GET_LOG: "/logs",
LIST_POSITIVE_CASE: "/cases/positive-cases",
......
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