feat: create function to load user data from storage

This commit is contained in:
Vinicius Souza 2024-10-31 09:37:34 -03:00
parent 58f0fa0b30
commit 2fe80ecaab

View file

@ -6,3 +6,9 @@ import { USER_STORAGE } from './storageConfig';
export async function storageUserSave(user: UserDTO) {
await AsyncStorage.setItem(USER_STORAGE, JSON.stringify(user));
}
export async function storageUserGet() {
const storage = await AsyncStorage.getItem(USER_STORAGE);
const user: UserDTO = storage ? JSON.parse(storage) : {};
return user;
}