manual ui changes
This commit is contained in:
@@ -12,6 +12,7 @@ const PromptDisplay = () => {
|
||||
sessions: 0,
|
||||
needsRefill: true
|
||||
});
|
||||
const [drawButtonDisabled, setDrawButtonDisabled] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
fetchMostRecentPrompt();
|
||||
@@ -21,6 +22,7 @@ const PromptDisplay = () => {
|
||||
const fetchMostRecentPrompt = async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
setDrawButtonDisabled(false); // Re-enable draw button when returning to history view
|
||||
|
||||
try {
|
||||
// Try to fetch from actual API first
|
||||
@@ -51,6 +53,7 @@ const PromptDisplay = () => {
|
||||
};
|
||||
|
||||
const handleDrawPrompts = async () => {
|
||||
setDrawButtonDisabled(true); // Disable the button when clicked
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
setSelectedIndex(null);
|
||||
@@ -109,6 +112,7 @@ const PromptDisplay = () => {
|
||||
// The default view shows the most recent prompt from history (position 0)
|
||||
fetchMostRecentPrompt();
|
||||
fetchPoolStats();
|
||||
setDrawButtonDisabled(false); // Re-enable draw button after selection
|
||||
} else {
|
||||
const errorData = await response.json();
|
||||
setError(`Failed to add prompt to history: ${errorData.detail || 'Unknown error'}`);
|
||||
@@ -157,7 +161,7 @@ const PromptDisplay = () => {
|
||||
return (
|
||||
<div className="text-center p-8">
|
||||
<div className="spinner mx-auto"></div>
|
||||
<p className="mt-4">Loading prompt...</p>
|
||||
<p className="mt-4">Filling pool...</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -229,7 +233,7 @@ const PromptDisplay = () => {
|
||||
<div className="flex gap-2">
|
||||
{viewMode === 'drawn' && (
|
||||
<button
|
||||
className="btn btn-success flex-1"
|
||||
className="btn btn-success w-1/2"
|
||||
onClick={() => handleAddToHistory(selectedIndex !== null ? selectedIndex : 0)}
|
||||
disabled={selectedIndex === null}
|
||||
>
|
||||
@@ -237,7 +241,11 @@ const PromptDisplay = () => {
|
||||
{selectedIndex !== null ? 'Use Selected Prompt' : 'Select a Prompt First'}
|
||||
</button>
|
||||
)}
|
||||
<button className={`btn btn-primary ${viewMode === 'drawn' ? 'flex-1' : 'w-full'}`} onClick={handleDrawPrompts}>
|
||||
<button
|
||||
className={`btn btn-primary ${viewMode === 'drawn' ? 'w-1/2' : 'w-full'}`}
|
||||
onClick={handleDrawPrompts}
|
||||
disabled={drawButtonDisabled}
|
||||
>
|
||||
<i className="fas fa-dice"></i>
|
||||
{viewMode === 'history' ? 'Draw 3 New Prompts' : 'Draw 3 More Prompts'}
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user