fix: remove delete buttons from story cards and game page
This commit is contained in:
@@ -200,140 +200,6 @@
|
||||
gap: 0.4rem;
|
||||
}
|
||||
|
||||
.header-settings {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.settings-btn {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
font-size: 1rem;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.settings-btn:hover {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
}
|
||||
|
||||
.settings-menu {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
right: 0;
|
||||
margin-top: 0.5rem;
|
||||
background: #141414;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
border-radius: 12px;
|
||||
min-width: 240px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
|
||||
z-index: 100;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.settings-menu-header {
|
||||
padding: 0.75rem 1rem;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
|
||||
font-size: 0.85rem;
|
||||
color: #999;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.settings-menu-content {
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
.settings-item {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.75rem 1rem;
|
||||
background: none;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
color: #ddd;
|
||||
font-size: 0.9rem;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.settings-item:hover:not(:disabled) {
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
|
||||
.settings-item:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.settings-item.danger {
|
||||
color: #f87171;
|
||||
}
|
||||
|
||||
.settings-item.danger:hover:not(:disabled) {
|
||||
background: rgba(239, 68, 68, 0.12);
|
||||
}
|
||||
|
||||
.settings-item-hint {
|
||||
font-size: 0.75rem;
|
||||
color: #666;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.delete-confirm {
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
.delete-confirm p {
|
||||
margin: 0 0 0.75rem 0;
|
||||
font-size: 0.85rem;
|
||||
color: #f87171;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.delete-confirm-buttons {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.confirm-btn {
|
||||
flex: 1;
|
||||
padding: 0.6rem 1rem;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 0.85rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.confirm-btn.cancel {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.confirm-btn.cancel:hover {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.confirm-btn.delete {
|
||||
background: rgba(239, 68, 68, 0.2);
|
||||
color: #f87171;
|
||||
}
|
||||
|
||||
.confirm-btn.delete:hover {
|
||||
background: rgba(239, 68, 68, 0.35);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.stat-badge {
|
||||
padding: 0.35rem 0.65rem;
|
||||
border-radius: 16px;
|
||||
|
||||
+1
-78
@@ -8,7 +8,6 @@ import {
|
||||
getSession,
|
||||
createSession,
|
||||
saveSession as apiSaveSession,
|
||||
deleteSession as apiDeleteSession,
|
||||
getPlayerCharacter,
|
||||
type SessionListItem,
|
||||
} from "../services/api";
|
||||
@@ -64,8 +63,6 @@ export default function GamePage() {
|
||||
const [showScrollButton, setShowScrollButton] = useState(false);
|
||||
const [editingMessageId, setEditingMessageId] = useState<string | null>(null);
|
||||
const [editContent, setEditContent] = useState("");
|
||||
const [showSettings, setShowSettings] = useState(false);
|
||||
const [deleteConfirmStep, setDeleteConfirmStep] = useState(0);
|
||||
const abortControllerRef = useRef<AbortController | null>(null);
|
||||
const messagesEndRef = useRef<HTMLDivElement>(null);
|
||||
const messagesContainerRef = useRef<HTMLDivElement>(null);
|
||||
@@ -627,26 +624,6 @@ export default function GamePage() {
|
||||
setIsInitialLoading(false);
|
||||
};
|
||||
|
||||
const handleDeleteSession = async (sessionId: string) => {
|
||||
if (!id || sessionsList.length <= 1) {
|
||||
alert("Нельзя удалить единственную сессию");
|
||||
setDeleteConfirmStep(0);
|
||||
return;
|
||||
}
|
||||
|
||||
const success = await apiDeleteSession(id, sessionId);
|
||||
if (success) {
|
||||
const updatedList = sessionsList.filter((s) => s.id !== sessionId);
|
||||
setSessionsList(updatedList);
|
||||
|
||||
// Если удалили текущую сессию — переключаемся на другую
|
||||
if (sessionId === currentSessionId && updatedList.length > 0) {
|
||||
await handleSwitchSession(updatedList[0].id);
|
||||
}
|
||||
}
|
||||
setShowSessionMenu(false);
|
||||
};
|
||||
|
||||
const currentSessionName =
|
||||
sessionsList.find((s) => s.id === currentSessionId)?.name || "Сессия";
|
||||
|
||||
@@ -726,62 +703,8 @@ export default function GamePage() {
|
||||
<span className="stat-badge tokens">
|
||||
🎟️ {formatTokens(estimateTokens(session?.messages || []))}
|
||||
</span>
|
||||
</div> <div className="header-settings">
|
||||
<button
|
||||
className="settings-btn"
|
||||
onClick={() => {
|
||||
setShowSettings(!showSettings);
|
||||
setDeleteConfirmStep(0);
|
||||
}}
|
||||
title="Настройки"
|
||||
>
|
||||
⚙️
|
||||
</button>
|
||||
{showSettings && (
|
||||
<div className="settings-menu">
|
||||
<div className="settings-menu-header">Настройки сессии</div>
|
||||
<div className="settings-menu-content">
|
||||
{deleteConfirmStep === 0 && (
|
||||
<button
|
||||
className="settings-item danger"
|
||||
onClick={() => setDeleteConfirmStep(1)}
|
||||
disabled={sessionsList.length <= 1}
|
||||
>
|
||||
🗑️ Удалить текущую сессию
|
||||
{sessionsList.length <= 1 && (
|
||||
<span className="settings-item-hint">(единственная)</span>
|
||||
)}
|
||||
</button>
|
||||
)}
|
||||
{deleteConfirmStep === 1 && (
|
||||
<div className="delete-confirm">
|
||||
<p>Вы уверены? Это действие нельзя отменить.</p>
|
||||
<div className="delete-confirm-buttons">
|
||||
<button
|
||||
className="confirm-btn cancel"
|
||||
onClick={() => setDeleteConfirmStep(0)}
|
||||
>
|
||||
Отмена
|
||||
</button>
|
||||
<button
|
||||
className="confirm-btn delete"
|
||||
onClick={() => {
|
||||
if (currentSessionId) {
|
||||
handleDeleteSession(currentSessionId);
|
||||
setShowSettings(false);
|
||||
setDeleteConfirmStep(0);
|
||||
}
|
||||
}}
|
||||
>
|
||||
Удалить
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div> </header>
|
||||
</header>
|
||||
|
||||
<div className="game-content">
|
||||
<div
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { useAuth } from "../contexts/AuthContext";
|
||||
import { getStories, deleteStory as apiDeleteStory } from "../services/api";
|
||||
import { getStories } from "../services/api";
|
||||
import type { Story } from "../types";
|
||||
import "./StoriesPage.css";
|
||||
|
||||
@@ -35,15 +35,6 @@ export default function StoriesPage() {
|
||||
}
|
||||
}, [isAuthenticated, authLoading]);
|
||||
|
||||
const handleDelete = async (id: string) => {
|
||||
if (confirm("Удалить эту историю?")) {
|
||||
const success = await apiDeleteStory(id);
|
||||
if (success) {
|
||||
setStories(stories.filter((s) => s.id !== id));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const filteredStories = stories.filter(
|
||||
(story) =>
|
||||
story.title.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
||||
@@ -133,12 +124,6 @@ export default function StoriesPage() {
|
||||
<Link to={`/play/${story.id}`} className="btn btn-play">
|
||||
🎮 Играть
|
||||
</Link>
|
||||
<button
|
||||
onClick={() => handleDelete(story.id)}
|
||||
className="btn btn-delete"
|
||||
>
|
||||
🗑️
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user