mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 08:37:22 +00:00
Render dialog outside of accordion
This commit is contained in:
4 files changed
+154
-24
No files matched your search
@@ -8,6 +8,7 @@ import { Label } from '@/components/ui/label';
|
||||
import { Separator } from '@/components/ui/separator';
|
||||
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion';
|
||||
import { CreditsBadge } from '@/components/CreditsBadge';
|
||||
import { CreditsDialog } from '@/components/CreditsDialog';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||
import { useAISettings } from '@/hooks/useAISettings';
|
||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
@@ -91,6 +92,7 @@ export function AISettings() {
|
||||
const [customApiKey, setCustomApiKey] = useState('');
|
||||
const [customAuthMethod, setCustomAuthMethod] = useState<'api-key' | 'nostr'>('api-key');
|
||||
const [presetApiKeys, setPresetApiKeys] = useState<Record<string, string>>({});
|
||||
const [activeCreditsDialog, setActiveCreditsDialog] = useState<string | null>(null);
|
||||
|
||||
const handleAddPresetProvider = (preset: PresetProvider) => {
|
||||
const apiKey = presetApiKeys[preset.id] as string | undefined;
|
||||
@@ -144,6 +146,14 @@ export function AISettings() {
|
||||
updateProvider(name, connection);
|
||||
};
|
||||
|
||||
const handleOpenCreditsDialog = (providerId: string) => {
|
||||
setActiveCreditsDialog(providerId);
|
||||
};
|
||||
|
||||
const handleCloseCreditsDialog = () => {
|
||||
setActiveCreditsDialog(null);
|
||||
};
|
||||
|
||||
const configuredProviderIds = Object.keys(settings.providers);
|
||||
const availablePresets = PRESET_PROVIDERS.filter(preset => !configuredProviderIds.includes(preset.id));
|
||||
|
||||
@@ -204,7 +214,11 @@ export function AISettings() {
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<CreditsBadge providerId={providerId} connection={provider} />
|
||||
<CreditsBadge
|
||||
providerId={providerId}
|
||||
connection={provider}
|
||||
onOpenDialog={() => handleOpenCreditsDialog(providerId)}
|
||||
/>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
@@ -426,6 +440,20 @@ export function AISettings() {
|
||||
</Accordion>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Render credits dialog outside of accordion structure */}
|
||||
{activeCreditsDialog && (
|
||||
<CreditsDialog
|
||||
open={true}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) {
|
||||
handleCloseCreditsDialog();
|
||||
}
|
||||
}}
|
||||
providerId={activeCreditsDialog}
|
||||
connection={settings.providers[activeCreditsDialog]}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user