Files
imphnen-frontend-service/libs/utils/src/local-storage/index.ts
T

39 lines
799 B
TypeScript
Raw Normal View History

2025-04-03 12:21:10 +07:00
export type TPermissionItem = {
id: string;
name: string;
created_at: string;
updated_at: string;
};
type TRoleItem = {
id: string;
name: string;
created_at: string;
updated_at: string;
permissions: TPermissionItem[];
};
type TUserItem = {
id: string;
avatar: string;
birthdate: string;
email: string;
fullname: string;
gender: string;
is_active: boolean;
phone_number: string;
role: TRoleItem;
2025-11-25 01:47:56 +07:00
bio?: string;
location?: string;
skills?: string[];
2025-04-03 12:21:10 +07:00
};
export const SessionUser = {
2025-05-23 00:28:29 +07:00
set: (val?: TUserItem) => localStorage.setItem('users', JSON.stringify(val)),
2025-04-03 12:21:10 +07:00
get: (): TUserItem | undefined => {
const users = localStorage.getItem('users');
return users ? JSON.parse(users) : undefined;
},
remove: () => localStorage.removeItem('users'),
};