Add: Screen root
This commit is contained in:
2025-08-18 11:45:06 +08:00
parent 6f5d04e73f
commit 0b6c360500
4 changed files with 65 additions and 37 deletions

View File

@@ -1,5 +1,4 @@
import { MainColor } from "@/constants/color-palet"; import AppRoot from "@/screens/RootLayout/AppRoot";
import { Stack } from "expo-router";
import "react-native-gesture-handler"; import "react-native-gesture-handler";
import { SafeAreaProvider } from "react-native-safe-area-context"; import { SafeAreaProvider } from "react-native-safe-area-context";
import Toast from "react-native-toast-message"; import Toast from "react-native-toast-message";
@@ -8,28 +7,7 @@ export default function RootLayout() {
return ( return (
<> <>
<SafeAreaProvider> <SafeAreaProvider>
<Stack <AppRoot />
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>
</SafeAreaProvider> </SafeAreaProvider>
<Toast /> <Toast />
</> </>

View File

@@ -1,6 +1,6 @@
const API_BASE = (path: string) => { const API_BASE = (path: string) => {
const url = "https://stg-hipmi.wibudev.com/"; // const url = "https://stg-hipmi.wibudev.com/";
// const url = "http://10.169.174.254:3000/"; const url = "http://172.20.173.254:3000/";
return `${url}/${path}`; return `${url}/${path}`;
}; };

View File

@@ -32,9 +32,36 @@ export default function LoginView() {
setSelectedCountry(country); 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() { async function handleLogin() {
const callingCode = const isValid = await validateData();
selectedCountry?.callingCode.replace(/^\+/, "").trim() || ""; if (!isValid) return;
const callingCode = selectedCountry?.callingCode.replace(/^\+/, "") || "";
const fixNumber = inputValue.replace(/\s+/g, ""); const fixNumber = inputValue.replace(/\s+/g, "");
const realNumber = callingCode + fixNumber; const realNumber = callingCode + fixNumber;
@@ -47,6 +74,7 @@ export default function LoginView() {
text2: "Login berhasil", text2: "Login berhasil",
}); });
router.navigate(`/verification?kodeId=${response.kodeId}`); router.navigate(`/verification?kodeId=${response.kodeId}`);
// router.replace("/(application)/coba");
} else { } else {
Toast.show({ Toast.show({
type: "error", type: "error",
@@ -54,15 +82,6 @@ export default function LoginView() {
text2: response.message, 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 ( return (

View 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>
</>
);
}