Files
front/src/app/state/gorodar.models.ts
T
2026-10-07 12:10:12 +03:00

72 lines
1.5 KiB
TypeScript

import type { AuthIntent, AuthSession, AuthStep } from '../auth/auth.models';
export type ClaimStage = 'idle' | 'check' | 'success';
export interface ClaimState {
landmarkId: string | null;
photo: string | null;
stage: ClaimStage;
step: number;
}
export interface ProfileState {
displayName: string;
firstName: string;
lastName: string;
city: string;
email: string;
phone: string;
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,
};
}