mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Fix linter errors
This commit is contained in:
1 parent
b832c5c6fd
commit
fcf779fe35
15 files changed
+93
-70
No files matched your search
@@ -0,0 +1,15 @@
|
||||
import { createContext } from 'react';
|
||||
|
||||
export interface AISettings {
|
||||
apiKey: string;
|
||||
baseUrl: string;
|
||||
model: string;
|
||||
}
|
||||
|
||||
export interface AISettingsContextType {
|
||||
settings: AISettings;
|
||||
updateSettings: (settings: Partial<AISettings>) => void;
|
||||
isConfigured: boolean;
|
||||
}
|
||||
|
||||
export const AISettingsContext = createContext<AISettingsContextType | undefined>(undefined);
|
||||
@@ -1,62 +0,0 @@
|
||||
import { createContext, useContext, useState, useEffect, ReactNode } from 'react';
|
||||
|
||||
export interface AISettings {
|
||||
apiKey: string;
|
||||
baseUrl: string;
|
||||
model: string;
|
||||
}
|
||||
|
||||
interface AISettingsContextType {
|
||||
settings: AISettings;
|
||||
updateSettings: (settings: Partial<AISettings>) => void;
|
||||
isConfigured: boolean;
|
||||
}
|
||||
|
||||
const AISettingsContext = createContext<AISettingsContextType | undefined>(undefined);
|
||||
|
||||
const DEFAULT_SETTINGS: AISettings = {
|
||||
apiKey: '',
|
||||
baseUrl: 'https://openrouter.ai/api/v1',
|
||||
model: 'anthropic/claude-sonnet-4',
|
||||
};
|
||||
|
||||
const STORAGE_KEY = 'ai-settings';
|
||||
|
||||
export function AISettingsProvider({ children }: { children: ReactNode }) {
|
||||
const [settings, setSettings] = useState<AISettings>(() => {
|
||||
const stored = localStorage.getItem(STORAGE_KEY);
|
||||
if (stored) {
|
||||
try {
|
||||
return { ...DEFAULT_SETTINGS, ...JSON.parse(stored) };
|
||||
} catch {
|
||||
return DEFAULT_SETTINGS;
|
||||
}
|
||||
}
|
||||
return DEFAULT_SETTINGS;
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(settings));
|
||||
}, [settings]);
|
||||
|
||||
const updateSettings = (newSettings: Partial<AISettings>) => {
|
||||
setSettings(prev => ({ ...prev, ...newSettings }));
|
||||
};
|
||||
|
||||
const isConfigured = Boolean(settings.apiKey);
|
||||
|
||||
return (
|
||||
<AISettingsContext.Provider value={{ settings, updateSettings, isConfigured }}>
|
||||
{children}
|
||||
</AISettingsContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
export function useAISettings() {
|
||||
const context = useContext(AISettingsContext);
|
||||
if (!context) {
|
||||
throw new Error('useAISettings must be used within AISettingsProvider');
|
||||
}
|
||||
return context;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { createContext } from 'react';
|
||||
import type LightningFS from '@isomorphic-git/lightning-fs';
|
||||
|
||||
export interface FSContextType {
|
||||
fs: LightningFS.PromisifiedFS;
|
||||
}
|
||||
|
||||
export const FSContext = createContext<FSContextType | undefined>(undefined);
|
||||
@@ -1,29 +0,0 @@
|
||||
import { createContext, useContext, type ReactNode } from 'react';
|
||||
import LightningFS from '@isomorphic-git/lightning-fs';
|
||||
|
||||
interface FSContextType {
|
||||
fs: LightningFS.PromisifiedFS;
|
||||
}
|
||||
|
||||
const FSContext = createContext<FSContextType | undefined>(undefined);
|
||||
|
||||
interface FSProviderProps {
|
||||
children: ReactNode;
|
||||
fs: LightningFS.PromisifiedFS;
|
||||
}
|
||||
|
||||
export function FSProvider({ children, fs }: FSProviderProps) {
|
||||
return (
|
||||
<FSContext.Provider value={{ fs }}>
|
||||
{children}
|
||||
</FSContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function useFS(): FSContextType {
|
||||
const context = useContext(FSContext);
|
||||
if (context === undefined) {
|
||||
throw new Error('useFS must be used within a FSProvider');
|
||||
}
|
||||
return context;
|
||||
}
|
||||
Reference in new issue
Block a user