Files
classroomio/apps/dashboard/src/lib/utils/store/user.ts
T

49 lines
1.0 KiB
TypeScript
Raw Normal View History

import type { TProfile, TUser } from '@cio/db/types';
import { writable } from 'svelte/store';
2023-10-29 12:07:34 +00:00
2023-12-05 08:31:26 +03:00
interface UserStore {
2023-10-29 12:07:34 +00:00
openAuthModal: boolean;
fetchingUser: boolean;
isLoggedIn: boolean;
currentSession: TUser | undefined;
2023-10-29 12:07:34 +00:00
expiresAt: number;
2023-12-05 08:31:26 +03:00
}
2023-10-29 12:07:34 +00:00
// Using TProfile type from @cio/utils/types with optional id for store initialization
export type ProfileStore = Omit<TProfile, 'id'> & {
2023-10-30 04:52:00 +00:00
id: string | undefined;
};
2023-12-05 08:31:26 +03:00
export const defaultUserState: UserStore = {
openAuthModal: false,
fetchingUser: true,
2023-12-05 08:31:26 +03:00
isLoggedIn: false,
currentSession: undefined,
expiresAt: 0
};
export const defaultProfileState: TProfile = {
id: '',
2023-10-29 12:07:34 +00:00
fullname: '',
avatarUrl: '',
2024-11-12 12:37:25 +01:00
username: '',
email: null,
role: null,
goal: null,
source: null,
telegramChatId: null,
locale: 'en',
isEmailVerified: false,
verifiedAt: null,
canAddCourse: true,
isRestricted: false,
createdAt: '',
updatedAt: '',
metadata: null
2023-12-05 08:31:26 +03:00
};
export const user = writable<UserStore>(defaultUserState);
export const profile = writable<TProfile>(defaultProfileState);