2024-04-19 05:45:48 +01:00
|
|
|
import { LOCALE } from '../types';
|
2025-09-10 20:39:16 +01:00
|
|
|
import type { User } from '@supabase/supabase-js';
|
|
|
|
|
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: User | undefined;
|
|
|
|
|
expiresAt: number;
|
2023-12-05 08:31:26 +03:00
|
|
|
}
|
2023-10-29 12:07:34 +00:00
|
|
|
|
2025-11-01 15:49:29 +01:00
|
|
|
export interface ProfileStore {
|
2023-10-30 04:52:00 +00:00
|
|
|
id: string | undefined;
|
2023-10-29 12:07:34 +00:00
|
|
|
fullname: string;
|
|
|
|
|
avatar_url: string;
|
|
|
|
|
profile_url?: string;
|
|
|
|
|
username: string;
|
|
|
|
|
user_id: string;
|
|
|
|
|
email: string;
|
|
|
|
|
role: string;
|
|
|
|
|
goal: string;
|
|
|
|
|
source: string;
|
|
|
|
|
telegram_chat_id: number | null;
|
2024-04-19 05:45:48 +01:00
|
|
|
locale: LOCALE;
|
2024-03-22 06:30:24 +01:00
|
|
|
is_email_verified: boolean;
|
|
|
|
|
verified_at: string;
|
2023-12-05 08:31:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const defaultUserState: UserStore = {
|
|
|
|
|
openAuthModal: false,
|
2025-09-10 20:39:16 +01:00
|
|
|
fetchingUser: true,
|
2023-12-05 08:31:26 +03:00
|
|
|
isLoggedIn: false,
|
|
|
|
|
currentSession: undefined,
|
|
|
|
|
expiresAt: 0
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const defaultProfileState: ProfileStore = {
|
2023-10-29 12:07:34 +00:00
|
|
|
id: undefined,
|
|
|
|
|
fullname: '',
|
2024-11-12 12:37:25 +01:00
|
|
|
avatar_url: '',
|
|
|
|
|
username: '',
|
2023-10-29 12:07:34 +00:00
|
|
|
user_id: '',
|
|
|
|
|
email: '',
|
|
|
|
|
role: '',
|
|
|
|
|
goal: '',
|
|
|
|
|
source: '',
|
2024-03-22 06:30:24 +01:00
|
|
|
telegram_chat_id: null,
|
2024-04-19 05:45:48 +01:00
|
|
|
locale: LOCALE.EN,
|
2024-03-22 06:30:24 +01:00
|
|
|
is_email_verified: false,
|
|
|
|
|
verified_at: ''
|
2023-12-05 08:31:26 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const user = writable<UserStore>(defaultUserState);
|
|
|
|
|
|
|
|
|
|
export const profile = writable<ProfileStore>(defaultProfileState);
|