- Expo SDK 54, expo-router, NativeWind - 7 screens: login, tasks, calendar, goals, chat, settings, tabs - API client (api.hasdo.info), SecureStore auth, AuthContext - Tab navigation: Ukoly, Kalendar, Cile, Chat, Nastaveni - Pull-to-refresh, FAB, group colors, priority dots - Calendar grid with task dots - AI chat with keyboard avoiding - Web export verified (780 modules, 1.5MB bundle) - Bundle ID: info.hasdo.taskteam Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
61 lines
1.5 KiB
TypeScript
61 lines
1.5 KiB
TypeScript
import * as SecureStore from 'expo-secure-store';
|
|
import { Platform } from 'react-native';
|
|
|
|
const TOKEN_KEY = 'taskteam_token';
|
|
const USER_KEY = 'taskteam_user';
|
|
|
|
export async function getToken(): Promise<string | null> {
|
|
if (Platform.OS === 'web') {
|
|
return localStorage.getItem(TOKEN_KEY);
|
|
}
|
|
return SecureStore.getItemAsync(TOKEN_KEY);
|
|
}
|
|
|
|
export async function setToken(token: string): Promise<void> {
|
|
if (Platform.OS === 'web') {
|
|
localStorage.setItem(TOKEN_KEY, token);
|
|
return;
|
|
}
|
|
await SecureStore.setItemAsync(TOKEN_KEY, token);
|
|
}
|
|
|
|
export async function removeToken(): Promise<void> {
|
|
if (Platform.OS === 'web') {
|
|
localStorage.removeItem(TOKEN_KEY);
|
|
return;
|
|
}
|
|
await SecureStore.deleteItemAsync(TOKEN_KEY);
|
|
}
|
|
|
|
export async function getUser(): Promise<any | null> {
|
|
let raw: string | null;
|
|
if (Platform.OS === 'web') {
|
|
raw = localStorage.getItem(USER_KEY);
|
|
} else {
|
|
raw = await SecureStore.getItemAsync(USER_KEY);
|
|
}
|
|
if (!raw) return null;
|
|
try {
|
|
return JSON.parse(raw);
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
export async function setUser(user: any): Promise<void> {
|
|
const raw = JSON.stringify(user);
|
|
if (Platform.OS === 'web') {
|
|
localStorage.setItem(USER_KEY, raw);
|
|
return;
|
|
}
|
|
await SecureStore.setItemAsync(USER_KEY, raw);
|
|
}
|
|
|
|
export async function removeUser(): Promise<void> {
|
|
if (Platform.OS === 'web') {
|
|
localStorage.removeItem(USER_KEY);
|
|
return;
|
|
}
|
|
await SecureStore.deleteItemAsync(USER_KEY);
|
|
}
|