upd: profile

Deskripsi:
- profile sudah sesuai dg role user login dan id user login

No Issues
This commit is contained in:
amel
2025-04-24 14:44:03 +08:00
parent fcad450649
commit 716e021a7a
5 changed files with 46 additions and 22 deletions

View File

@@ -1,5 +1,6 @@
import Styles from "@/constants/Styles"
import { apiCheckPhoneLogin, apiSendOtp } from "@/lib/api"
import AsyncStorage from "@react-native-async-storage/async-storage"
import { useState } from "react"
import { Image, Text, ToastAndroid, View } from "react-native"
import { ButtonForm } from "../buttonForm"
@@ -25,6 +26,7 @@ export default function ViewLogin({ onValidate }: Props) {
const responseOtp = await apiSendOtp({ phone: `62${phone}`, otp })
if (responseOtp == 200) {
// localStorage.setItem('user', response.id)
await AsyncStorage.setItem('user', response.id);
return onValidate({ phone: `62${phone}`, otp })
}
}

View File

@@ -1,7 +1,7 @@
import Styles from "@/constants/Styles";
import { apiSendOtp } from "@/lib/api";
import { useAuthSession } from "@/providers/AuthProvider";
import CryptoES from "crypto-es";
import AsyncStorage from "@react-native-async-storage/async-storage";
import { useState } from "react";
import { Image, Text, ToastAndroid, View } from "react-native";
import { CodeField, Cursor, useBlurOnFulfill, useClearByFocusCell } from "react-native-confirmation-code-field";
@@ -20,14 +20,19 @@ export default function ViewVerification({ phone, otp }: Props) {
value,
setValue,
});
const { signIn } = useAuthSession();
const { signIn, encryptToken } = useAuthSession();
const login = (): void => {
var mytexttoEncryption = "contohLoginMobileDarmasaba"
const encrypted = CryptoES.AES.encrypt(mytexttoEncryption, "your password").toString();
signIn(encrypted);
const login = async () => {
const valueUser = await AsyncStorage.getItem('user');
if (valueUser != null) {
await AsyncStorage.removeItem('user');
const encrypted = await encryptToken(valueUser);
signIn(encrypted);
} else {
return ToastAndroid.show('Terjadi kesalahan', ToastAndroid.SHORT)
}
}
const onCheckOtp = () => {