Cleanup: extract constants, fix typecheck, add ESLint, organize store types
- Remove unused initCount state from useAuthGate hook - Replace magic number with MAX_SAVES_PER_USER constant in saves route - Extract duplicated EMAIL_REGEX and MIN_PASSWORD_LENGTH in auth routes - Fix game-simulation typecheck failure by adding DOM lib to tsconfig - Extract store UI types (ActivePage, InfraNav, etc.) to store/types.ts - Fix let→const for non-reassigned arrays in servingPipeline - Fix useless initial assignments in reputationSystem - Fix ambiguous multiline array access in sanityChecks - Add minimal ESLint config with typescript-eslint - Add .planning/ and *.log to .gitignore Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -37,7 +37,6 @@ export function useAuthGate(): AuthGateState {
|
||||
const [admin, setAdmin] = useState(false);
|
||||
const [cloudSave, setCloudSave] = useState<CloudSaveInfo | null>(null);
|
||||
const [hasConflict, setHasConflict] = useState(false);
|
||||
const [initCount, setInitCount] = useState(0);
|
||||
|
||||
const init = useCallback(async () => {
|
||||
setLoading(true);
|
||||
@@ -98,7 +97,6 @@ export function useAuthGate(): AuthGateState {
|
||||
useState(() => { init(); });
|
||||
|
||||
const retry = useCallback(() => {
|
||||
setInitCount(c => c + 1);
|
||||
init();
|
||||
}, [init]);
|
||||
|
||||
|
||||
@@ -46,37 +46,9 @@ import {
|
||||
TECH_TREE, onModelDeployed,
|
||||
} from '@token-empire/game-engine';
|
||||
import { INITIAL_RIVALS } from '@token-empire/game-engine';
|
||||
import type { ActivePage, InfraNav, ModelsTab, UIState, GameNotification } from './types';
|
||||
|
||||
export type ActivePage = 'dashboard' | 'infrastructure' | 'research' | 'models'
|
||||
| 'market' | 'serving' | 'talent' | 'data' | 'competitors' | 'finance' | 'achievements' | 'leaderboard' | 'invitations' | 'settings';
|
||||
|
||||
export type InfraNavLevel = 'clusters' | 'cluster' | 'campus' | 'datacenter';
|
||||
|
||||
export interface InfraNav {
|
||||
level: InfraNavLevel;
|
||||
clusterId?: string;
|
||||
campusId?: string;
|
||||
datacenterId?: string;
|
||||
}
|
||||
|
||||
type ModelsTab = 'overview' | 'train' | 'models' | 'products';
|
||||
|
||||
interface UIState {
|
||||
activePage: ActivePage;
|
||||
notifications: GameNotification[];
|
||||
infraNav: InfraNav;
|
||||
modelsTab: ModelsTab;
|
||||
}
|
||||
|
||||
export interface GameNotification {
|
||||
id: string;
|
||||
title: string;
|
||||
message: string;
|
||||
type: 'info' | 'success' | 'warning' | 'danger';
|
||||
tick: number;
|
||||
read: boolean;
|
||||
action?: { label: string; page?: ActivePage; modelsTab?: ModelsTab };
|
||||
}
|
||||
export type { ActivePage, InfraNavLevel, InfraNav, ModelsTab, UIState, GameNotification } from './types';
|
||||
|
||||
function emptyDC(): Pick<DataCenter, 'networkSummary' | 'effectiveComputeRacks' | 'usedSlots' | 'usedPowerKW' | 'energyCostPerTick' | 'maintenanceCostPerTick' | 'currentUptime'> {
|
||||
return {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
export type ActivePage = 'dashboard' | 'infrastructure' | 'research' | 'models'
|
||||
| 'market' | 'serving' | 'talent' | 'data' | 'competitors' | 'finance' | 'achievements' | 'leaderboard' | 'invitations' | 'settings';
|
||||
|
||||
export type InfraNavLevel = 'clusters' | 'cluster' | 'campus' | 'datacenter';
|
||||
|
||||
export interface InfraNav {
|
||||
level: InfraNavLevel;
|
||||
clusterId?: string;
|
||||
campusId?: string;
|
||||
datacenterId?: string;
|
||||
}
|
||||
|
||||
export type ModelsTab = 'overview' | 'train' | 'models' | 'products';
|
||||
|
||||
export interface UIState {
|
||||
activePage: ActivePage;
|
||||
notifications: GameNotification[];
|
||||
infraNav: InfraNav;
|
||||
modelsTab: ModelsTab;
|
||||
}
|
||||
|
||||
export interface GameNotification {
|
||||
id: string;
|
||||
title: string;
|
||||
message: string;
|
||||
type: 'info' | 'success' | 'warning' | 'danger';
|
||||
tick: number;
|
||||
read: boolean;
|
||||
action?: { label: string; page?: ActivePage; modelsTab?: ModelsTab };
|
||||
}
|
||||
Reference in New Issue
Block a user