import { useState } from 'react'; import { useTranslation } from 'react-i18next'; import { Check } from 'lucide-react'; 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 { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogFooter, } from '@/components/ui/dialog'; interface AddCustomGitCredentialDialogProps { open: boolean; onOpenChange: (open: boolean) => void; onAdd: (credential: { name: string; origin: string; username: string; password: string; }) => void; existingOrigins: string[]; } export function AddCustomGitCredentialDialog({ open, onOpenChange, onAdd, existingOrigins, }: AddCustomGitCredentialDialogProps) { const { t } = useTranslation(); const [customName, setCustomName] = useState(''); const [customOrigin, setCustomOrigin] = useState(''); const [customUsername, setCustomUsername] = useState(''); const [customPassword, setCustomPassword] = useState(''); const handleAdd = () => { if (!customName.trim() || !customOrigin.trim() || !customUsername.trim() || !customPassword.trim()) return; onAdd({ name: customName.trim(), origin: customOrigin.trim(), username: customUsername.trim(), password: customPassword.trim(), }); // Reset form setCustomName(''); setCustomOrigin(''); setCustomUsername(''); setCustomPassword(''); onOpenChange(false); }; const isValid = customName.trim() && customOrigin.trim() && customUsername.trim() && customPassword.trim() && !existingOrigins.includes(customOrigin.trim()); const originExists = existingOrigins.includes(customOrigin.trim()); return ( {t('addCustomProvider')} Configure a custom Git server with your credentials
setCustomName(e.target.value)} />
setCustomOrigin(e.target.value)} />
setCustomUsername(e.target.value)} />
setCustomPassword(e.target.value)} />
{originExists && (

{t('credentialsExist')}

)}
); }