'use client'; import React, { useEffect, useState } from 'react'; import { Input, Button, Switch, AccordionItem, Accordion } from '@nextui-org/react'; import { Eye, EyeOff } from 'lucide-react'; import { useTranslation } from "@/shared/lib/useTranslation"; import { getGoogleRedirectUri } from '@/hooks/useLogin'; import { GoogleAuthConfig } from '@/shared/types/system'; interface GoogleAuthConfigFormProps { config: GoogleAuthConfig; onSave: (config: GoogleAuthConfig) => void; isLoading?: boolean; } export const GoogleAuthConfigForm: React.FC = ({ config, onSave, isLoading = false, }) => { const { t } = useTranslation(); const [formData, setFormData] = useState(config); const [showClientSecret, setShowClientSecret] = useState(false); useEffect(() => { setFormData(config); }, [config]); const handleInputChange = (field: keyof GoogleAuthConfig, value: string | boolean) => { setFormData(prev => ({ ...prev, [field]: value })); }; const handleSave = () => { onSave(formData); }; const isFormValid = formData.client_id.trim() !== ''; return (

{t('Google Login Settings')}

{t('Configure Google OAuth integration')}

}>
{/* enable google login */}
{t('Enable Google Login')} {t('Allow users to sign in with Google')}
{ handleInputChange('is_enabled', value); onSave({ ...formData, is_enabled: value }); }} color="primary" size='sm' />
{/* Google Client ID */} handleInputChange('client_id', e.target.value)} isRequired isDisabled={!formData.is_enabled} /> {/* Google Client Secret */} handleInputChange('client_secret', e.target.value)} type={showClientSecret ? "text" : "password"} endContent={ } isDisabled={!formData.is_enabled} /> {/* Redirect URI */}
{/* Action Buttons */} { formData.is_enabled && (
) }
); };