wip
This commit is contained in:
@@ -6,6 +6,8 @@ import { BrowserModeToggle } from './components/BrowserModeToggle';
|
||||
import { CheckoutConfirmationDialog } from './components/CheckoutConfirmationDialog';
|
||||
import { RaceCreationSuccessScreen } from './components/RaceCreationSuccessScreen';
|
||||
import type { HostedSessionConfig } from '../../../packages/automation/domain/types/HostedSessionConfig';
|
||||
import type { AuthenticationState } from '../../../packages/automation/domain/value-objects/AuthenticationState';
|
||||
import type { StartAutomationResponse } from '../main/preload';
|
||||
|
||||
interface SessionProgress {
|
||||
sessionId: string;
|
||||
@@ -16,7 +18,7 @@ interface SessionProgress {
|
||||
errorMessage: string | null;
|
||||
}
|
||||
|
||||
type AuthState = 'UNKNOWN' | 'AUTHENTICATED' | 'EXPIRED' | 'LOGGED_OUT' | 'CHECKING';
|
||||
type AuthState = AuthenticationState | 'CHECKING';
|
||||
type LoginStatus = 'idle' | 'waiting' | 'success' | 'error';
|
||||
|
||||
export function App() {
|
||||
@@ -84,7 +86,7 @@ export function App() {
|
||||
try {
|
||||
const result = await window.electronAPI.checkAuth();
|
||||
if (result.success && result.state) {
|
||||
setAuthState(result.state as AuthState);
|
||||
setAuthState(result.state);
|
||||
} else {
|
||||
setAuthError(result.error);
|
||||
setAuthState('UNKNOWN');
|
||||
@@ -103,7 +105,7 @@ export function App() {
|
||||
try {
|
||||
const result = await window.electronAPI.checkAuth();
|
||||
if (result.success && result.state) {
|
||||
setAuthState(result.state as AuthState);
|
||||
setAuthState(result.state);
|
||||
} else {
|
||||
setAuthError(result.error || 'Failed to check authentication');
|
||||
setAuthState('UNKNOWN');
|
||||
@@ -138,13 +140,7 @@ export function App() {
|
||||
|
||||
const handleStartAutomation = async (config: HostedSessionConfig) => {
|
||||
setIsRunning(true);
|
||||
const result = await window.electronAPI.startAutomation(config) as {
|
||||
success: boolean;
|
||||
sessionId?: string;
|
||||
error?: string;
|
||||
authRequired?: boolean;
|
||||
authState?: AuthState;
|
||||
};
|
||||
const result: StartAutomationResponse = await window.electronAPI.startAutomation(config);
|
||||
|
||||
if (result.success && result.sessionId) {
|
||||
setSessionId(result.sessionId);
|
||||
@@ -153,8 +149,8 @@ export function App() {
|
||||
|
||||
setIsRunning(false);
|
||||
|
||||
if ('authRequired' in result && result.authRequired) {
|
||||
const nextAuthState = result.authState as AuthState | undefined;
|
||||
if (result.authRequired) {
|
||||
const nextAuthState = result.authState;
|
||||
setAuthState(nextAuthState ?? 'EXPIRED');
|
||||
setAuthError(result.error ?? 'Authentication required before starting automation.');
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user