diff --git a/app/_layout.tsx b/app/_layout.tsx index db994f2..1190c39 100644 --- a/app/_layout.tsx +++ b/app/_layout.tsx @@ -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 ( <> - - - - - - - + diff --git a/lib/api.ts b/lib/api.ts index 3b08fa1..35980f9 100644 --- a/lib/api.ts +++ b/lib/api.ts @@ -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}`; }; diff --git a/screens/Authentication/LoginView.tsx b/screens/Authentication/LoginView.tsx index 197b46e..fd713f2 100644 --- a/screens/Authentication/LoginView.tsx +++ b/screens/Authentication/LoginView.tsx @@ -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 ( diff --git a/screens/RootLayout/AppRoot.tsx b/screens/RootLayout/AppRoot.tsx new file mode 100644 index 0000000..e513fbf --- /dev/null +++ b/screens/RootLayout/AppRoot.tsx @@ -0,0 +1,31 @@ +import { MainColor } from "@/constants/color-palet"; +import { Stack } from "expo-router"; + +export default function AppRoot() { + return ( + <> + + + + + + + + + ); +}