API
Add: Screen root
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { MainColor } from "@/constants/color-palet";
|
||||
import { Stack } from "expo-router";
|
||||
import AppRoot from "@/screens/RootLayout/AppRoot";
|
||||
import "react-native-gesture-handler";
|
||||
import { SafeAreaProvider } from "react-native-safe-area-context";
|
||||
import Toast from "react-native-toast-message";
|
||||
@@ -8,28 +7,7 @@ export default function RootLayout() {
|
||||
return (
|
||||
<>
|
||||
<SafeAreaProvider>
|
||||
<Stack
|
||||
screenOptions={{
|
||||
headerStyle: { backgroundColor: MainColor.darkblue },
|
||||
headerTitleStyle: { color: MainColor.yellow, fontWeight: "bold" },
|
||||
headerTitleAlign: "center",
|
||||
}}
|
||||
>
|
||||
<Stack.Screen
|
||||
name="index"
|
||||
options={{ title: "", headerBackVisible: false }}
|
||||
/>
|
||||
<Stack.Screen name="+not-found" options={{ title: "" }} />
|
||||
<Stack.Screen
|
||||
name="verification"
|
||||
options={{ title: "", headerBackVisible: false }}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="register"
|
||||
options={{ title: "", headerBackVisible: false }}
|
||||
/>
|
||||
<Stack.Screen name="(application)" options={{ headerShown: false }} />
|
||||
</Stack>
|
||||
<AppRoot />
|
||||
</SafeAreaProvider>
|
||||
<Toast />
|
||||
</>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const API_BASE = (path: string) => {
|
||||
const url = "https://stg-hipmi.wibudev.com/";
|
||||
// const url = "http://10.169.174.254:3000/";
|
||||
// const url = "https://stg-hipmi.wibudev.com/";
|
||||
const url = "http://172.20.173.254:3000/";
|
||||
return `${url}/${path}`;
|
||||
};
|
||||
|
||||
|
||||
@@ -32,9 +32,36 @@ export default function LoginView() {
|
||||
setSelectedCountry(country);
|
||||
}
|
||||
|
||||
async function validateData() {
|
||||
if (inputValue.length === 0) {
|
||||
return Toast.show({
|
||||
type: "error",
|
||||
text1: "Masukan nomor anda",
|
||||
});
|
||||
}
|
||||
|
||||
if (selectedCountry === null) {
|
||||
return Toast.show({
|
||||
type: "error",
|
||||
text1: "Pilih negara",
|
||||
});
|
||||
}
|
||||
|
||||
if (inputValue.length < 9) {
|
||||
return Toast.show({
|
||||
type: "error",
|
||||
text1: "Nomor tidak valid",
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
async function handleLogin() {
|
||||
const callingCode =
|
||||
selectedCountry?.callingCode.replace(/^\+/, "").trim() || "";
|
||||
const isValid = await validateData();
|
||||
if (!isValid) return;
|
||||
|
||||
const callingCode = selectedCountry?.callingCode.replace(/^\+/, "") || "";
|
||||
const fixNumber = inputValue.replace(/\s+/g, "");
|
||||
const realNumber = callingCode + fixNumber;
|
||||
|
||||
@@ -47,6 +74,7 @@ export default function LoginView() {
|
||||
text2: "Login berhasil",
|
||||
});
|
||||
router.navigate(`/verification?kodeId=${response.kodeId}`);
|
||||
// router.replace("/(application)/coba");
|
||||
} else {
|
||||
Toast.show({
|
||||
type: "error",
|
||||
@@ -54,15 +82,6 @@ export default function LoginView() {
|
||||
text2: response.message,
|
||||
});
|
||||
}
|
||||
|
||||
// const randomAlfabet = Math.random().toString(36).substring(2, 8);
|
||||
// const randomNumber = Math.floor(Math.random() * 1000000);
|
||||
// const id = randomAlfabet + randomNumber + fixNumber;
|
||||
// console.log("login user id :", id);
|
||||
|
||||
// router.navigate("/verification");
|
||||
// router.replace("/(application)/coba");
|
||||
// router.navigate("/admin/dashboard")
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
31
screens/RootLayout/AppRoot.tsx
Normal file
31
screens/RootLayout/AppRoot.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
import { MainColor } from "@/constants/color-palet";
|
||||
import { Stack } from "expo-router";
|
||||
|
||||
export default function AppRoot() {
|
||||
return (
|
||||
<>
|
||||
<Stack
|
||||
screenOptions={{
|
||||
headerStyle: { backgroundColor: MainColor.darkblue },
|
||||
headerTitleStyle: { color: MainColor.yellow, fontWeight: "bold" },
|
||||
headerTitleAlign: "center",
|
||||
}}
|
||||
>
|
||||
<Stack.Screen
|
||||
name="index"
|
||||
options={{ title: "", headerBackVisible: false }}
|
||||
/>
|
||||
<Stack.Screen name="+not-found" options={{ title: "" }} />
|
||||
<Stack.Screen
|
||||
name="verification"
|
||||
options={{ title: "", headerBackVisible: false }}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="register"
|
||||
options={{ title: "", headerBackVisible: false }}
|
||||
/>
|
||||
<Stack.Screen name="(application)" options={{ headerShown: false }} />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user