fix: TypeScript build errors
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import { Link, useNavigate } from "react-router-dom";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useAuth } from "../contexts/AuthContext";
|
||||
import {
|
||||
getPlayerCharacters,
|
||||
|
||||
@@ -2,7 +2,6 @@ import { useState, useEffect, useRef } from "react";
|
||||
import {
|
||||
useParams,
|
||||
Link,
|
||||
useNavigate,
|
||||
useSearchParams,
|
||||
} from "react-router-dom";
|
||||
import ReactMarkdown from "react-markdown";
|
||||
@@ -103,7 +102,6 @@ function detectLocation(messages: ChatMessage[]): string {
|
||||
export default function GamePage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const [searchParams] = useSearchParams();
|
||||
const navigate = useNavigate();
|
||||
const { isAuthenticated } = useAuth();
|
||||
const [story, setStory] = useState<Story | null>(null);
|
||||
const [session, setSession] = useState<GameSession | null>(null);
|
||||
@@ -372,11 +370,6 @@ export default function GamePage() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleQuickAction = (action: string) => {
|
||||
setInput(action);
|
||||
inputRef.current?.focus();
|
||||
};
|
||||
|
||||
if (isInitialLoading) {
|
||||
return (
|
||||
<div className="game-page">
|
||||
|
||||
@@ -125,7 +125,6 @@ export default function StoriesPage() {
|
||||
<p className="story-description">{story.description}</p>
|
||||
<div className="story-meta">
|
||||
<span>🌍 {story.world.name}</span>
|
||||
<span>👤 {story.player?.name || "Герой"}</span>
|
||||
</div>
|
||||
<div className="story-actions">
|
||||
<Link to={`/story/${story.id}`} className="btn btn-view">
|
||||
|
||||
@@ -99,7 +99,7 @@ export default function StoryDetailPage() {
|
||||
};
|
||||
|
||||
// Примерный подсчёт токенов (1 токен ≈ 3 символа для русского текста)
|
||||
const estimateTokens = (messages: typeof session.messages) => {
|
||||
const estimateTokens = (messages: typeof session?.messages) => {
|
||||
if (!messages || messages.length === 0) return 0;
|
||||
const totalChars = messages.reduce(
|
||||
(sum, msg) => sum + msg.content.length,
|
||||
|
||||
@@ -53,8 +53,8 @@ export function getSessions(): GameSession[] {
|
||||
const sessions = JSON.parse(data);
|
||||
return sessions.map((s: GameSession) => ({
|
||||
...s,
|
||||
createdAt: new Date(s.createdAt),
|
||||
updatedAt: new Date(s.updatedAt),
|
||||
createdAt: s.createdAt ? new Date(s.createdAt) : new Date(),
|
||||
updatedAt: s.updatedAt ? new Date(s.updatedAt) : new Date(),
|
||||
messages: s.messages.map((m) => ({
|
||||
...m,
|
||||
timestamp: new Date(m.timestamp),
|
||||
|
||||
Reference in New Issue
Block a user