fix : toast

Deskripsi:
- bisa custom posisi toast alert

No Issues
This commit is contained in:
2025-08-27 11:39:46 +08:00
parent 2651e4bd18
commit c01a1885c2
4 changed files with 6 additions and 8 deletions

View File

@@ -1,7 +1,6 @@
import ViewLogin from "@/components/auth/viewLogin"; import ViewLogin from "@/components/auth/viewLogin";
import ViewVerification from "@/components/auth/viewVerification"; import ViewVerification from "@/components/auth/viewVerification";
import Text from '@/components/Text'; import Text from '@/components/Text';
import ToastCustom from "@/components/toastCustom";
import { requestPermission } from "@/lib/useNotification"; import { requestPermission } from "@/lib/useNotification";
import { useAuthSession } from "@/providers/AuthProvider"; import { useAuthSession } from "@/providers/AuthProvider";
import { Redirect } from "expo-router"; import { Redirect } from "expo-router";

View File

@@ -28,14 +28,13 @@ export default function ViewLogin({ onValidate }: Props) {
const otp = Math.floor(1000 + Math.random() * 9000) const otp = Math.floor(1000 + Math.random() * 9000)
const responseOtp = await apiSendOtp({ phone: `62${phone}`, otp }) const responseOtp = await apiSendOtp({ phone: `62${phone}`, otp })
if (responseOtp == 200) { if (responseOtp == 200) {
// localStorage.setItem('user', response.id)
await AsyncStorage.setItem('user', response.id); await AsyncStorage.setItem('user', response.id);
return onValidate({ phone: `62${phone}`, otp }) return onValidate({ phone: `62${phone}`, otp })
} }
} }
return Toast.show({ type: 'small', text1: response.message, }) return Toast.show({ type: 'small', text1: response.message, position: 'top' })
} catch (error) { } catch (error) {
return Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) return Toast.show({ type: 'small', text1: 'Terjadi kesalahan', position: 'top' })
} finally { } finally {
setLoadingLogin(false) setLoadingLogin(false)
} }

View File

@@ -27,7 +27,7 @@ export default function ViewVerification({ phone, otp }: Props) {
const encrypted = await encryptToken(valueUser); const encrypted = await encryptToken(valueUser);
signIn(encrypted); signIn(encrypted);
} else { } else {
return Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) return Toast.show({ type: 'small', text1: 'Terjadi kesalahan', position: 'top' })
} }
} }
@@ -35,7 +35,7 @@ export default function ViewVerification({ phone, otp }: Props) {
if (value === otpFix.toString()) { if (value === otpFix.toString()) {
login() login()
} else { } else {
return Toast.show({ type: 'small', text1: 'Kode OTP tidak sesuai' }); return Toast.show({ type: 'small', text1: 'Kode OTP tidak sesuai', position: 'top' });
} }
} }

View File

@@ -3,9 +3,9 @@ import { View } from "react-native";
import Toast from "react-native-toast-message"; import Toast from "react-native-toast-message";
import Text from "./Text"; import Text from "./Text";
export default function ToastCustom() { export default function ToastCustom({ position }: { position?: 'top' | 'bottom' }) {
return ( return (
<Toast autoHide onPress={() => Toast.hide()} visibilityTime={1500} position="bottom" config={{ <Toast autoHide onPress={() => Toast.hide()} visibilityTime={1500} position={position || 'bottom'} config={{
small: ({ text1 }) => ( small: ({ text1 }) => (
<View style={[Styles.toastContainer]}> <View style={[Styles.toastContainer]}>
<Text style={{ fontSize: 12 }}>{text1}</Text> <Text style={{ fontSize: 12 }}>{text1}</Text>