freshyo/apps/user-ui/hooks/useJWT.ts
2026-09-02 23:12:49 +05:30

25 lines
682 B
TypeScript
Executable file

// import { StorageService } from '@/lib/StorageService';
import {StorageService} from 'common-ui';
export const AUTH_TOKEN_KEY = 'authToken';
export const USER_ID_KEY = 'userId';
export async function saveUserId(userId:string) {
await StorageService.setItem(USER_ID_KEY, userId);
}
export async function getUserId() {
return await StorageService.getItem(USER_ID_KEY);
}
export async function saveAuthToken(token: string) {
await StorageService.setItem(AUTH_TOKEN_KEY, token);
}
export async function getAuthToken() {
return await StorageService.getItem(AUTH_TOKEN_KEY);
}
export async function deleteAuthToken() {
await StorageService.removeItem(AUTH_TOKEN_KEY);
}