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