"use client"; import React, { useEffect, useState } from "react"; import { Input, Button, Switch } from "@nextui-org/react"; import { Eye, EyeOff } from "lucide-react"; import { useTranslation } from "@/shared/lib/useTranslation"; import { getGoogleRedirectUri } from "@/shared/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 ( <>
{/* enable google login */}
{t("Enable Google Login")} {t("Allow users to sign in with Google")}
{ 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 && (
)} ); };