This commit is contained in:
2026-10-07 12:10:12 +03:00
parent e384bc4872
commit e676717ffb
28 changed files with 722 additions and 236 deletions
+45
View File
@@ -1,3 +1,5 @@
import type { AuthIntent, AuthSession, AuthStep } from '../auth/auth.models';
export type ClaimStage = 'idle' | 'check' | 'success';
export interface ClaimState {
@@ -17,10 +19,53 @@ export interface ProfileState {
joinedLabel: string;
}
export interface AuthState {
email: string;
accessToken: string | null;
tokenType: string;
refreshToken?: string;
expiresAt?: number;
authenticated: boolean;
step: AuthStep;
resendSeconds: number;
pending: boolean;
error: string;
sheetVisible: boolean;
intent: AuthIntent;
pendingLandmarkId: string | null;
codeRequestId: number;
}
export interface GorodarState {
collectedIds: string[];
photos: Record<string, string>;
collectedAt: Record<string, string>;
claim: ClaimState;
profile: ProfileState;
auth: AuthState;
}
export const RESEND_SECONDS = 60;
export function sessionToAuth(session: AuthSession | null): Pick<
AuthState,
'email' | 'accessToken' | 'tokenType' | 'refreshToken' | 'expiresAt' | 'authenticated'
> {
if (!session) {
return {
email: '',
accessToken: null,
tokenType: 'Bearer',
authenticated: false,
};
}
return {
email: session.email,
accessToken: session.accessToken,
tokenType: session.tokenType,
refreshToken: session.refreshToken,
expiresAt: session.expiresAt,
authenticated: true,
};
}