Fix richiesta apertura sessione
This commit is contained in:
@@ -4,6 +4,7 @@ import ChatHeader from "./ChatHeader";
|
||||
import ChatWindow from "./ChatWindow";
|
||||
import ChatInput from "./ChatInput";
|
||||
import SessionTable from "./SessionTable";
|
||||
import NoSessionBox from './NoSessionBox';
|
||||
|
||||
export default function ChatLayout({
|
||||
theme,
|
||||
@@ -75,7 +76,12 @@ export default function ChatLayout({
|
||||
</div>
|
||||
)}
|
||||
|
||||
<ChatInput onSend={onSend} loading={loading} />
|
||||
{/* Se non c'è sessionId, mostra il box per crearne una */}
|
||||
{sessionId ? (
|
||||
<ChatInput onSend={onSend} onStop={onStop} loading={loading} />
|
||||
) : (
|
||||
<NoSessionBox onCreateSession={onCreateSession} />
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// srv/NoSessionBox.jsx
|
||||
import React from "react";
|
||||
|
||||
export default function NoSessionBox({ onCreateSession }) {
|
||||
return (
|
||||
<div
|
||||
className="d-flex flex-column align-items-center justify-content-center text-center p-4"
|
||||
style={{ height: "100%", minHeight: "200px" }}
|
||||
>
|
||||
<h5 className="mb-3">Nessuna sessione attiva</h5>
|
||||
<p className="text-muted mb-4" style={{ maxWidth: "400px" }}>
|
||||
Per iniziare una nuova conversazione, crea una sessione.
|
||||
Potrai poi inviare messaggi e salvare la cronologia.
|
||||
</p>
|
||||
<button
|
||||
className="btn btn-success"
|
||||
onClick={onCreateSession}
|
||||
title="Crea una nuova sessione"
|
||||
>
|
||||
➕ Crea nuova sessione
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,11 @@ export function getUserId() {
|
||||
}
|
||||
|
||||
export function getSessionId() {
|
||||
// Legge sempre da localStorage
|
||||
return localStorage.getItem("sessionId") || null;
|
||||
}
|
||||
|
||||
export function getSessionIdForced() {
|
||||
// Always re‑read localStorage so latest value is returned
|
||||
let id = localStorage.getItem("sessionId");
|
||||
if (!id) {
|
||||
|
||||
Reference in New Issue
Block a user