mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 08:23:34 +00:00
Add ToS agreement to AI Settings page
This commit is contained in:
2 files changed
+82
-22
No files matched your search
@@ -183,6 +183,8 @@ const resources = {
|
||||
authentication: 'Authentication',
|
||||
addCustomProviderButton: 'Add Custom Provider',
|
||||
providerExists: 'Provider with this name already exists',
|
||||
agreeToTermsOfService: 'I agree to {{providerName}}’s',
|
||||
termsOfService: 'Terms of Service',
|
||||
custom: 'Custom',
|
||||
connecting: 'Connecting...',
|
||||
connectToGitHub: 'Connect to GitHub',
|
||||
@@ -492,6 +494,8 @@ const resources = {
|
||||
authentication: 'Autenticação',
|
||||
addCustomProviderButton: 'Adicionar Provedor Personalizado',
|
||||
providerExists: 'Provedor com este nome já existe',
|
||||
agreeToTermsOfService: 'Concordo com {{providerName}}',
|
||||
termsOfService: 'Termos de Serviço',
|
||||
custom: 'Personalizado',
|
||||
connecting: 'Conectando...',
|
||||
connectToGitHub: 'Conectar ao GitHub',
|
||||
@@ -801,6 +805,8 @@ const resources = {
|
||||
authentication: '身份验证',
|
||||
addCustomProviderButton: '添加自定义提供商',
|
||||
providerExists: '此名称的提供商已存在',
|
||||
agreeToTermsOfService: '我同意{{providerName}}',
|
||||
termsOfService: '服务条款',
|
||||
custom: '自定义',
|
||||
connecting: '连接中...',
|
||||
connectToGitHub: '连接到GitHub',
|
||||
@@ -1110,6 +1116,8 @@ const resources = {
|
||||
authentication: 'Tabbatarwa',
|
||||
addCustomProviderButton: 'Ƙara Mai Samarwa na Musamman',
|
||||
providerExists: 'Mai samarwa da wannan suna ya riga ya wanzu',
|
||||
agreeToTermsOfService: 'Na yarda da {{providerName}}',
|
||||
termsOfService: 'Sharuɗɗan Sabis',
|
||||
custom: 'Na Musamman',
|
||||
connecting: 'Ana haɗawa...',
|
||||
connectToGitHub: 'Haɗu da GitHub',
|
||||
@@ -1419,6 +1427,8 @@ const resources = {
|
||||
authentication: 'Ijẹrisi',
|
||||
addCustomProviderButton: 'Fi Olupese Aṣa kun',
|
||||
providerExists: 'Olupese pẹlu orukọ yii ti wa tẹlẹ',
|
||||
agreeToTermsOfService: 'Mo gba {{providerName}}',
|
||||
termsOfService: 'Awọn Ofin Iṣẹ',
|
||||
custom: 'Aṣa',
|
||||
connecting: 'N so...',
|
||||
connectToGitHub: 'So si GitHub',
|
||||
@@ -1723,6 +1733,8 @@ const resources = {
|
||||
authentication: 'Nkwenye',
|
||||
addCustomProviderButton: 'Tinye Onye Na-enye Omenala',
|
||||
providerExists: 'Onye na-enye nwere aha a adịlarị',
|
||||
agreeToTermsOfService: 'Ekwenyere m na {{providerName}}',
|
||||
termsOfService: 'Usoro Ọrụ',
|
||||
custom: 'Omenala',
|
||||
connecting: 'Na-ejikọ...',
|
||||
connectToGitHub: 'Jikọọ na GitHub',
|
||||
|
||||
+70
-22
@@ -24,6 +24,7 @@ import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { PasswordInput } from '@/components/ui/password-input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion';
|
||||
import { CreditsBadge } from '@/components/CreditsBadge';
|
||||
import { CreditsDialog } from '@/components/CreditsDialog';
|
||||
@@ -161,6 +162,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 [presetTermsAgreements, setPresetTermsAgreements] = useState<Record<string, boolean>>({});
|
||||
const [activeCreditsDialog, setActiveCreditsDialog] = useState<string | null>(null);
|
||||
|
||||
const sensors = useSensors(
|
||||
@@ -173,6 +175,9 @@ export function AISettings() {
|
||||
const handleAddPresetProvider = (preset: PresetProvider) => {
|
||||
const apiKey = presetApiKeys[preset.id] as string | undefined;
|
||||
|
||||
// Check if user agreed to terms
|
||||
if (!presetTermsAgreements[preset.id]) return;
|
||||
|
||||
const newProvider: AIProvider = {
|
||||
id: preset.id,
|
||||
baseURL: preset.baseURL,
|
||||
@@ -188,11 +193,15 @@ export function AISettings() {
|
||||
// Auto-save: Add provider immediately to persistent storage
|
||||
setProvider(newProvider);
|
||||
|
||||
// Clear the API key input for this preset
|
||||
// Clear the API key input and terms agreement for this preset
|
||||
setPresetApiKeys(prev => ({
|
||||
...prev,
|
||||
[preset.id]: '',
|
||||
}));
|
||||
setPresetTermsAgreements(prev => ({
|
||||
...prev,
|
||||
[preset.id]: false,
|
||||
}));
|
||||
};
|
||||
|
||||
const handleAddCustomProvider = () => {
|
||||
@@ -362,30 +371,69 @@ export function AISettings() {
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex gap-2">
|
||||
{!preset.nostr && (
|
||||
<PasswordInput
|
||||
placeholder={preset.id === "routstr" ? t('enterCashuToken') : t('enterApiKey')}
|
||||
className="flex-1"
|
||||
value={presetApiKeys[preset.id] || ''}
|
||||
onChange={(e) => setPresetApiKeys(prev => ({
|
||||
<div className="space-y-2">
|
||||
<div className="flex gap-2">
|
||||
{!preset.nostr && (
|
||||
<PasswordInput
|
||||
placeholder={preset.id === "routstr" ? t('enterCashuToken') : t('enterApiKey')}
|
||||
className="flex-1"
|
||||
value={presetApiKeys[preset.id] || ''}
|
||||
onChange={(e) => setPresetApiKeys(prev => ({
|
||||
...prev,
|
||||
[preset.id]: e.target.value,
|
||||
}))}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' &&
|
||||
presetApiKeys[preset.id]?.trim() &&
|
||||
presetTermsAgreements[preset.id]) {
|
||||
handleAddPresetProvider(preset);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
onClick={() => handleAddPresetProvider(preset)}
|
||||
disabled={
|
||||
!presetTermsAgreements[preset.id] ||
|
||||
(!!preset.apiKeysURL && !presetApiKeys[preset.id]?.trim())
|
||||
}
|
||||
className={preset.nostr ? "w-full" : "h-10 px-4 ml-auto"}
|
||||
>
|
||||
{t('add')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* Terms of Service Agreement */}
|
||||
<div className="flex items-center gap-1.5">
|
||||
<Checkbox
|
||||
id={`agree-terms-${preset.id}`}
|
||||
checked={presetTermsAgreements[preset.id] || false}
|
||||
onCheckedChange={(checked) => setPresetTermsAgreements(prev => ({
|
||||
...prev,
|
||||
[preset.id]: e.target.value,
|
||||
[preset.id]: checked === true,
|
||||
}))}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' && presetApiKeys[preset.id]?.trim()) {
|
||||
handleAddPresetProvider(preset);
|
||||
}
|
||||
}}
|
||||
className="h-3 w-3"
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
onClick={() => handleAddPresetProvider(preset)}
|
||||
disabled={!!preset.apiKeysURL && !presetApiKeys[preset.id]?.trim()}
|
||||
className={preset.nostr ? "w-full" : "h-10 px-4 ml-auto"}
|
||||
>
|
||||
{t('add')}
|
||||
</Button>
|
||||
<label
|
||||
htmlFor={`agree-terms-${preset.id}`}
|
||||
className="text-xs text-muted-foreground leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer"
|
||||
>
|
||||
{t('agreeToTermsOfService', { providerName: preset.name })}{' '}
|
||||
{preset.tosURL ? (
|
||||
<a
|
||||
href={preset.tosURL}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-muted-foreground underline hover:text-foreground hover:no-underline"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{t('termsOfService')}
|
||||
</a>
|
||||
) : (
|
||||
t('termsOfService')
|
||||
)}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user